Bah, humbug.
I'm realy sorry about posting so much on this site, but, you know, i'm learning.
. I've got a script that just wont do what its told, the arrow wont move up or down. its realy piddling me off.
void main (void)
{
draw_status();
freeze(1);
if(&tifany==1)
{
int &tifanytwo = Create_sprite(110, 290, 16, 227, 1);
}
if(&fight==1)
{
int &arrowposition = 1;
int &arrow = create_sprite(510, 350, 0, 192, 2);
int &saya = say_xy("Hitpoints, &life", 90, 340);
int &sayb = say_xy("Attack", 550, 330);
int &sayc = say_xy("Magic", 550, 350);
int &sayd = say_xy("Item", 550, 370);
int &saye = say_xy("Flee", 550, 390);
sp_kill(&saya, 0);
sp_kill(&sayb, 0);
sp_kill(&sayc, 0);
sp_kill(&sayd, 0);
sp_kill(&saye, 0);
int &controlbox = create_sprite(58, 341, 0, 192, 1);
sp_depth_que(&controlbox, 5);
int &arrowy;
loop:
wait_for_button();
&arrowy = sp_y(&arrow, -1);
if (&result == 18)
&arrowy -= 20;
if (&result == 12)
&arrowy += 20;
if (&arrowy > 330)
&arrowy = 390;
if (&arrowy < 390)
&arrowy = 330;
sp_y(&arrowy, &cury);
goto loop;
}
}
}
Thank you all so much, all this help is realy great, and it's realy appretiated. thanks

void main (void)
{
draw_status();
freeze(1);
if(&tifany==1)
{
int &tifanytwo = Create_sprite(110, 290, 16, 227, 1);
}
if(&fight==1)
{
int &arrowposition = 1;
int &arrow = create_sprite(510, 350, 0, 192, 2);
int &saya = say_xy("Hitpoints, &life", 90, 340);
int &sayb = say_xy("Attack", 550, 330);
int &sayc = say_xy("Magic", 550, 350);
int &sayd = say_xy("Item", 550, 370);
int &saye = say_xy("Flee", 550, 390);
sp_kill(&saya, 0);
sp_kill(&sayb, 0);
sp_kill(&sayc, 0);
sp_kill(&sayd, 0);
sp_kill(&saye, 0);
int &controlbox = create_sprite(58, 341, 0, 192, 1);
sp_depth_que(&controlbox, 5);
int &arrowy;
loop:
wait_for_button();
&arrowy = sp_y(&arrow, -1);
if (&result == 18)
&arrowy -= 20;
if (&result == 12)
&arrowy += 20;
if (&arrowy > 330)
&arrowy = 390;
if (&arrowy < 390)
&arrowy = 330;
sp_y(&arrowy, &cury);
goto loop;
}
}
}
Thank you all so much, all this help is realy great, and it's realy appretiated. thanks
sp_depth_que(&controlbox, 5);
That command doesn't exist, it's sp_que to do that. Anyway:
sp_y(&arrowy, &cury);
That's sp_y(sprite, y-coordinate). Now, you've got &arrowy as sprite and &cury as coordinate. But &arrowy doesn't refer to a sprite, it's the y-coordinate of the sprite. I don't see &cury anywhere else in the script either. Provided the rest of the script works, it would be:
sp_y(&arrow, &arrowy);
That command doesn't exist, it's sp_que to do that. Anyway:
sp_y(&arrowy, &cury);
That's sp_y(sprite, y-coordinate). Now, you've got &arrowy as sprite and &cury as coordinate. But &arrowy doesn't refer to a sprite, it's the y-coordinate of the sprite. I don't see &cury anywhere else in the script either. Provided the rest of the script works, it would be:
sp_y(&arrow, &arrowy);
thanks, but it still doesnt work, what happens now is the arrow move up a bit.
int &arrowposition = 1;
int &arrow = create_sprite(510, 350, 0, 192, 2);
Variable naming bug. It occurs when a variable starts with the name of another variable. In this case &arrowposition starts with &arrow.
Try renaming &arrow to something else. Even &arroww is allowed. As long as there isn't any other variable that starts with the new name.
int &arrow = create_sprite(510, 350, 0, 192, 2);
Variable naming bug. It occurs when a variable starts with the name of another variable. In this case &arrowposition starts with &arrow.
Try renaming &arrow to something else. Even &arroww is allowed. As long as there isn't any other variable that starts with the new name.
cheers magicman. This is realy doing my head in though, now when i press a button the arrow disapears. thanks. (for the record, heres the script).
void main (void)
{
draw_status();
freeze(1);
if(&tifany==1)
{
int &tifanytwo = Create_sprite(110, 290, 16, 227, 1);
}
if(&fight==1)
{
int &arrow = create_sprite(510, 350, 0, 192, 2);
int &saya = say_xy("Hitpoints, &life", 90, 340);
int &sayb = say_xy("Attack", 550, 330);
int &sayc = say_xy("Magic", 550, 350);
int &sayd = say_xy("Item", 550, 370);
int &saye = say_xy("Flee", 550, 390);
sp_kill(&saya, 0);
sp_kill(&sayb, 0);
sp_kill(&sayc, 0);
sp_kill(&sayd, 0);
sp_kill(&saye, 0);
int &controlbox = create_sprite(58, 341, 0, 192, 1);
sp_depth_que(&controlbox, 5);
int &arrowy;
&yarrow = sp_y(&arrow, -1);
loop:
wait_for_button();
if (&result == 18)
&yarrow -= 20;
if (&result == 12)
&yarrow += 20;
if (&arrowy > 330)
&yarrow = 390;
if (&arrowy < 390)
&yarrow = 330;
sp_y(&arrow, &yarrow);
goto loop;
}
}
void main (void)
{
draw_status();
freeze(1);
if(&tifany==1)
{
int &tifanytwo = Create_sprite(110, 290, 16, 227, 1);
}
if(&fight==1)
{
int &arrow = create_sprite(510, 350, 0, 192, 2);
int &saya = say_xy("Hitpoints, &life", 90, 340);
int &sayb = say_xy("Attack", 550, 330);
int &sayc = say_xy("Magic", 550, 350);
int &sayd = say_xy("Item", 550, 370);
int &saye = say_xy("Flee", 550, 390);
sp_kill(&saya, 0);
sp_kill(&sayb, 0);
sp_kill(&sayc, 0);
sp_kill(&sayd, 0);
sp_kill(&saye, 0);
int &controlbox = create_sprite(58, 341, 0, 192, 1);
sp_depth_que(&controlbox, 5);
int &arrowy;
&yarrow = sp_y(&arrow, -1);
loop:
wait_for_button();
if (&result == 18)
&yarrow -= 20;
if (&result == 12)
&yarrow += 20;
if (&arrowy > 330)
&yarrow = 390;
if (&arrowy < 390)
&yarrow = 330;
sp_y(&arrow, &yarrow);
goto loop;
}
}
int &arrowy;
&yarrow = sp_y(&arrow, -1);
rename &arrowy to &yarrow and you'll be fine. At least, I hope
As you can see, it's easy to look over these things.
ADDITION:
Oh, and for the same reason, you'll have to watch out with
if(&tifany==1)
{
int &tifanytwo = Create_sprite(110, 290, 16, 227, 1);
too. &tifanytwo starts with &tifany.
&yarrow = sp_y(&arrow, -1);
rename &arrowy to &yarrow and you'll be fine. At least, I hope

ADDITION:
Oh, and for the same reason, you'll have to watch out with
if(&tifany==1)
{
int &tifanytwo = Create_sprite(110, 290, 16, 227, 1);
too. &tifanytwo starts with &tifany.
June 5th 2005, 09:02 AM

Spacehoggy


Hurragh! sort of. It almost works perfectly when you comment out the part that stops the arrow moving beyond a certian point. What in that part could be causing the the arrow to freeze? Thanks.
void main (void)
{
draw_status();
freeze(1);
if(&tifany==1)
{
int &2tifany2 = Create_sprite(110, 290, 16, 227, 1);
}
if(&fight==1)
{
int &arrow = create_sprite(510, 350, 0, 192, 2);
int &hit = say_xy("Hitpoints, &life", 90, 340);
int &att = say_xy("Attack", 550, 330);
int &mag = say_xy("Magic", 550, 350);
int &itm = say_xy("Item", 550, 370);
int &run = say_xy("Flee", 550, 390);
sp_kill(&hit, 0);
sp_kill(&att, 0);
sp_kill(&itm, 0);
sp_kill(&mag, 0);
sp_kill(&run, 0);
int &controlbox = create_sprite(58, 341, 0, 192, 1);
sp_depth_que(&controlbox, 5);
int &yarrow;
&yarrow = sp_y(&arrow, -1);
loop:
//if (&yarrow > 330)
//{
//&yarrow = 390;
//}
//if (&yarrow < 390)
//{
//&yarrow = 330;
//}
sp_y(&arrow, &yarrow);
wait_for_button();
if (&result == 18)
&yarrow -= 20;
if (&result == 12)
&yarrow += 20;
goto loop;
}
}
void main (void)
{
draw_status();
freeze(1);
if(&tifany==1)
{
int &2tifany2 = Create_sprite(110, 290, 16, 227, 1);
}
if(&fight==1)
{
int &arrow = create_sprite(510, 350, 0, 192, 2);
int &hit = say_xy("Hitpoints, &life", 90, 340);
int &att = say_xy("Attack", 550, 330);
int &mag = say_xy("Magic", 550, 350);
int &itm = say_xy("Item", 550, 370);
int &run = say_xy("Flee", 550, 390);
sp_kill(&hit, 0);
sp_kill(&att, 0);
sp_kill(&itm, 0);
sp_kill(&mag, 0);
sp_kill(&run, 0);
int &controlbox = create_sprite(58, 341, 0, 192, 1);
sp_depth_que(&controlbox, 5);
int &yarrow;
&yarrow = sp_y(&arrow, -1);
loop:
//if (&yarrow > 330)
//{
//&yarrow = 390;
//}
//if (&yarrow < 390)
//{
//&yarrow = 330;
//}
sp_y(&arrow, &yarrow);
wait_for_button();
if (&result == 18)
&yarrow -= 20;
if (&result == 12)
&yarrow += 20;
goto loop;
}
}
//if (&yarrow > 330)
//{
//&yarrow = 390;
//}
//if (&yarrow < 390)
//{
//&yarrow = 330;
//}
This code places the arrow at y:390 if the y-coordinate is greater than 330. Since the arrow is created at an y of 350, it'll pass the first if (350>330) and so it'll be put at 390. Now 390 is not smaller than 390, so it'll stay there. Possibilities after pressing a key are y:370 and y:410. Both'll pass the first if (both are greater than 330), so they'll be put at 390 again. Repeat.
I don't know if you wanted wrapping, or must the arrow just stop? Anyway, wrap:
if (&yarrow < 330)
{
&yarrow = 390;
}
if (&yarrow > 390)
{
&yarrow = 330;
}
And stop:
if (&yarrow < 330)
{
&yarrow = 330;
}
if (&yarrow > 390)
{
&yarrow = 390;
}
Your code looks like some sort of choice menu. You do know there are built-in choice menu functions in the Dink Engine, don't you?
//{
//&yarrow = 390;
//}
//if (&yarrow < 390)
//{
//&yarrow = 330;
//}
This code places the arrow at y:390 if the y-coordinate is greater than 330. Since the arrow is created at an y of 350, it'll pass the first if (350>330) and so it'll be put at 390. Now 390 is not smaller than 390, so it'll stay there. Possibilities after pressing a key are y:370 and y:410. Both'll pass the first if (both are greater than 330), so they'll be put at 390 again. Repeat.
I don't know if you wanted wrapping, or must the arrow just stop? Anyway, wrap:
if (&yarrow < 330)
{
&yarrow = 390;
}
if (&yarrow > 390)
{
&yarrow = 330;
}
And stop:
if (&yarrow < 330)
{
&yarrow = 330;
}
if (&yarrow > 390)
{
&yarrow = 390;
}
Your code looks like some sort of choice menu. You do know there are built-in choice menu functions in the Dink Engine, don't you?
Thank you, the arrow works perfectly. Yeah, it is a choice menu, but this a for a final fantasy style turn based dmod, and it looks much better this way. Than using the old menu. Just one more thing though, do you know why the writing doesent show up? (the hitpoints one does show up, but in the wrong place).
int &arrow = create_sprite(510, 350, 0, 192, 2);
int &hit = say_xy("`%Hitpoints, &life", 90, 340);
int &att = say_xy("`%Attack", 550, 330);
int &mag = say_xy("`%Magic", 550, 350);
int &itm = say_xy("`%Item", 550, 370);
int &run = say_xy("`%Flee", 550, 390);
sp_kill(&hit, 0);
sp_kill(&att, 0);
sp_kill(&itm, 0);
sp_kill(&mag, 0);
sp_kill(&run, 0);
Cheers.
int &arrow = create_sprite(510, 350, 0, 192, 2);
int &hit = say_xy("`%Hitpoints, &life", 90, 340);
int &att = say_xy("`%Attack", 550, 330);
int &mag = say_xy("`%Magic", 550, 350);
int &itm = say_xy("`%Item", 550, 370);
int &run = say_xy("`%Flee", 550, 390);
sp_kill(&hit, 0);
sp_kill(&att, 0);
sp_kill(&itm, 0);
sp_kill(&mag, 0);
sp_kill(&run, 0);
Cheers.
The text coordinates are different from normal sprite coordinates. I believe only the y-position is the same.
x,y
0,0 = centered on top
100,0 = 100 pix right of the center on top
-100,0 = 100 pix left of the center on top
0,100 = centered 100 pix from the top.
etc...
ADDITION:
&mag might collide with &magic. But I don't know for sure. &magic and &magic_cost/&magic_level don't seem to cause the bug. Probably because these variables are hardcoded into the engine.
x,y
0,0 = centered on top
100,0 = 100 pix right of the center on top
-100,0 = 100 pix left of the center on top
0,100 = centered 100 pix from the top.
etc...
ADDITION:
&mag might collide with &magic. But I don't know for sure. &magic and &magic_cost/&magic_level don't seem to cause the bug. Probably because these variables are hardcoded into the engine.
It depends on when the variable is defined. If you define (with make_global_int) &magic *after* &magic_level, it will be fine. And if you define &mag *after* the rest, it should work too.
Yay!
Can I ask another question though? What be the deal with the Wait_for_button(); command. First of all, how do you know which buttons are which, and when you do the if statement without the brackets, does it just execute the next line of code or what? If so, how do you make it go through more lines of code. Cheers
.




Can I ask another question though? What be the deal with the Wait_for_button(); command. First of all, how do you know which buttons are which, and when you do the if statement without the brackets, does it just execute the next line of code or what? If so, how do you make it go through more lines of code. Cheers

Well, the DinkC Reference mentions the numbers of several basic keys you could use (like Esc, Ctrl, Arrows and such). Then you can use various if statements to let the buttons do what you want. If you want to do it again, simply use a goto loop; to let the script do wait_for_button(); again. Of course, you'd need to add a button that exits the script as well
If statements without brackets do only one line of code though if you want to be safe, you can add the brackets. With brackets, you can run more lines of code when you press a button? (not sure if that's what you wanted to hear with your last question but ok).

If statements without brackets do only one line of code though if you want to be safe, you can add the brackets. With brackets, you can run more lines of code when you press a button? (not sure if that's what you wanted to hear with your last question but ok).
I've used wait_for_button succesfully, although I'm not entirely sure how it works. I just throw in a stop_wait_for_button after every if(&result == whatever) statement, although it's probably not neccesary. I can email you an interesting script where it's used, if you want.
Would you email it to me? I'm having a bit of trouble getting it to work, but i got the simple thingy up there to work with help. thanks. Would it not be easier to post it? Oh yeah, you might be planning on using it for a dmod. Thanks, my email is
Rorothimusthegreat@hotmail.com
Cheers.
Rorothimusthegreat@hotmail.com
Cheers.
I sent it to you but there's probably better examples out there. I can't remember having any problems figuring out how to use the command after reading the bible, but whatever, it's a cool usage anyways...
My email name (my RL name too, for that matter) is Cohen.
My email name (my RL name too, for that matter) is Cohen.