quick question
Displaying 1-8 of 8 total.
1
Please enter a numerical value for the importance of this sticky.
Enter 0 to unsticky.
P-ville

how do you display the value of a variable on the screen? I tried using PrintString, but it didn't work.
Is there a specific funtion for displaying integers, or do I have to convert the integer into a string somehow?

Posted on 2006-12-09 12:10:16

Omni

You got it!

You must convert integers to strings, using the str() function.

mystring = str(mynumber);


You can then use the string in PrintString.

Posted on 2006-12-09 12:20:51

P-ville

thanks. I think it worked, but my program is acting up right now. It isn't working on some things that were working earlier, mainly it isn't registering "void" before the functions.

void autoexec()
{
SetAppName("Test version");
StartMenu();
}

void StartMenu()
{
int MenuBg = LoadImage("Images/TitleScreen.bmp");
int Cursor = LoadImage("images/cursor.bmp");
int MyFont = LoadFont("images/Font.bmp");
int cY = 1;
int cX = 1;
while(!b1)
{
Render();
Rectfill(0,0,320,240,RGB(4,4,4),screen);
Blit(0,0,MenuBg,screen);
TBlit((Cx*150)-120,162+(20*cY),Cursor,screen);
Printstring(50,182,screen,MyFont,"New Game");
Printstring(50,202,screen,MyFont,"Load Game");
Printstring(200,182,screen,MyFont,"");
Printstring(200,202,screen,MyFont,"Quit");
Showpage();
if(Up)
{
Unpress(5);
cY--;
if(cY<1)
cY=2;
}
if(Down)
{
Unpress(6);
cY++;
if(cY>2)
cY=1;
}
if(Left)
{
Unpress(7);
cX--;
if(cX<1)
cX=2;
}
if(Right)
{
Unpress(8);
cX++;
if(cX>2)
cX=1;
}
if(b1)
{
Unpress(1);
if(cX==1 && cY==1)
NewGame();
if(cX==2 && cY==2)
Exit("");
}
}
}

void NewGame()
{
HeroJoin();
int player;
int playergold;
int spawnx = 5;
int spawny = 3;
string TextUpper;
string TextMiddle;
string TextLower;
ClassMenu();
}
void ClassMenu()
{
int MenuBg = LoadImage("images/menu.bmp");
int Cursor = LoadImage("images/cursor.bmp");
int MyFont = LoadFont("images/Font.bmp");
int cY = 1;
while(character[0].classlevel == 0)
{
Render();
Rectfill(0,0,320,240,RGB(4,4,4),screen);
Blit(0,0,MenuBg,screen);
TBlit(72,30+(20*cY),Cursor,screen);
Printstring(30,20,screen,MyFont,"Select Character Class");
Printstring(90,50,screen,MyFont,"Archer");
Printstring(90,70,screen,MyFont,"Soldier");
Printstring(90,90,screen,MyFont,"Noble");
Printstring(90,110,screen,MyFont,"Sailor");
Printstring(90,130,screen,MyFont,"Conjuror");
Printstring(90,150,screen,MyFont,"Apprentice");
Printstring(90,170,screen,MyFont,"Nomad");
Printstring(90,190,screen,MyFont,"Mage");
ShowPage();
if(UP)
{
Unpress(5);
cY--;
if(cY<1)
cY=8;
}
if(DOWN)
{
Unpress(6);
cY++;
if(cY>8)
cY=1;
}
if(b1)
{
Unpress(1);
character[0].classlevel=1;
switch(cY)
{
case 1:
HeroArcher();

case 2:
HeroSoldier();

case 3:
HeroNoble();

case 4:
HeroSailor();

case 5:
HeroConjuror();

case 6:
HeroApprentice();

case 7:
HeroNomad();

case 8:
HeroMage();
}
}

}
Flags[F_CLASS_MENU] = 1;
current[P_MIDDLE].character = 0;
PartyCompile();
freeImage(MenuBg);
freeImage(Cursor);
HookButton(3,"PauseMenu");
Map("Cottage.map");
}


the problem according to the exit message is the "void" in autoexec.

Posted on 2006-12-10 00:33:42 (last edited on 2006-12-12 14:22:20)

P-ville

never mind, got it fixed. thanks for the help with the string function.

Posted on 2006-12-10 00:49:52

basil

Also: The way to do it all in the one command is
printstring(x,y,screen,font,""+str(variable)+"");
i.e. with some extra plusses and quotation marks. Used extensively.

Posted on 2006-12-10 03:42:20

P-ville

...and now the problem is back. Verge has a problem recognizing functions. My code is posted above, does anybody have an idea of what's wrong with it? It was working perfectly fine untill I added one line of code, then it stopped working normally.

Posted on 2006-12-11 18:07:26

Beni

There's more to your code than that right? There must be, because you call functions that are not in there, you #included some other files right?

If I type this in system.vc:
int MyFunc()
{

void autoexec()
{
}


I get the void error. Check the last file you include before you declare autoexec.

Posted on 2006-12-11 18:58:28

P-ville

you are correct, that was not the entire code, it was just the section I was working in and I knew the problem was in there somewhere.

I'm still really not sure what the problem was, but by moving around the functions I managed to get it working again. Hopefully this will be the last time that problem comes up, if not I will just end up fixing it through trial and error.

Posted on 2006-12-14 19:13:45


Displaying 1-8 of 8 total.
1
 
Newest messages

Ben McGraw's lovingly crafted this website from scratch for years.
It's a lot prettier this go around because of Jon Wofford.
Verge-rpg.com is a member of the lunarnet irc network, and would like to take this opportunity to remind you that regardless how babies taste, it is wrong to eat them.