need some help
July 28th 2010, 01:42 PM

developer


hey, i'm developing with dink, but I'm having some trouble, please help
i have a rock, and when the player pushes it, it should move to a location depending on the value of a variable, for example the player's strength.
So the script is as follows:
however, the rock will not move at all. is it possible to use variables like that in this game or not? What would be even better if i could put
if anyone can help me it would be much appreciated.
i have a rock, and when the player pushes it, it should move to a location depending on the value of a variable, for example the player's strength.
So the script is as follows:
void main(void) { int &direct; sp_speed(¤t_sprite, 1); sp_hard(¤t_sprite, 0); draw_hard_map(); } void push(void) { &direct = sp_dir(1, -1); if (&mydir == 6) { move(¤t_sprite, 6, &strength, 1); } }
however, the rock will not move at all. is it possible to use variables like that in this game or not? What would be even better if i could put
move(¤t_sprite, 6, &location += 5, 1);in the script, so i could make a variable storing the current location of the rock (in coordinates) so the player can push the rock 5 pixels per time.
if anyone can help me it would be much appreciated.
July 28th 2010, 01:45 PM

developer


oh, the &mydir in line 12 should be &direct (or vice versa), but it still doesn't work.
You can use the variables like that, however the 3rd bit in move() is the x or y coordinate to move to, not the amount of pixels to move. It's the y position if you're moving up or down and the x position for any other direction.
So if &strength is 5, that is trying to move the rock to 5 pixels from the left of the screen. If it's already further away than that (as is likely
) then it won't move at all.
Your 2nd idea is what you need to do but you can't stick it all together like that, seperate it out:
Edit: Or if you're basing it on strength or something then you could also do this of course:
So if &strength is 5, that is trying to move the rock to 5 pixels from the left of the screen. If it's already further away than that (as is likely

Your 2nd idea is what you need to do but you can't stick it all together like that, seperate it out:
&location = sp_x(¤t_sprite, -1); &location += 5; move(¤t_sprite, 6, &location, 1);
Edit: Or if you're basing it on strength or something then you could also do this of course:
&location += &strength;
July 28th 2010, 04:13 PM

developer


i see. it's not working how I had in mind though. i would like the rock to move 5 pixels to the right everytime the player pushes it. i have made this now:
the rock begins at x=350, so when the player pushes the rock, it moves 5 pixels (to 355) but when pushed again, the rock doesnt move again. also the hardness of the rock stays in the old position instead of the new position...
void main(void) { int &direction; &location = sp_x(¤t_sprite, -1) sp_speed(¤t_sprite, 1); sp_hard(¤t_sprite, 0); draw_hard_map(); } void push(void) { &direction = sp_dir(1, -1); if (&direction == 6) { if (&location == 350) { move(¤t_sprite, 6, 355, 1); draw_hard_map(); &location = sp_x(¤t_sprite, -1) &location += 5; } } if (&location > 350) { move(¤t_sprite, 6, &location, 1); draw_hard_map(); &location = sp_x(¤t_sprite, -1) &location += 5; } }
the rock begins at x=350, so when the player pushes the rock, it moves 5 pixels (to 355) but when pushed again, the rock doesnt move again. also the hardness of the rock stays in the old position instead of the new position...
July 28th 2010, 05:47 PM

developer


just for testing purposes, i have now done this:
i have checked and when pushing it the first time, &location has value 355. but the script never runs this part when pushed for the second time:
i have worked with some editors before but this engine doesnt seem to make much sense...
void main(void) { int &direction; &location = sp_x(¤t_sprite, -1); sp_speed(¤t_sprite, 1); sp_hard(¤t_sprite, 0); draw_hard_map(); } void push(void) { if (&location > 350) { move(¤t_sprite, 6, 400, 1); draw_hard_map(); } if (&location < 351) { move(¤t_sprite, 6, 355, 1); draw_hard_map(); &location += 5; } }
i have checked and when pushing it the first time, &location has value 355. but the script never runs this part when pushed for the second time:
void push(void) { if (&location > 350) { move(¤t_sprite, 6, 400, 1); draw_hard_map(); }
i have worked with some editors before but this engine doesnt seem to make much sense...
Just copy the pushable rock's script from the original game. And seek the difference.
July 28th 2010, 06:17 PM

developer


please dont reply if you dont know what youre talking about...
Whatever. Another one to believe to be Skorn or hell7fire1.
July 28th 2010, 06:45 PM

developer


i dont want to argue, i am trying to make it so when the player pushes a rock at any time, the rock moves 5 pixels. in the original scripts you always move the rock to a predefined spot. do you understand the difference?
Try using move_stop(), that might fix the hardness problem. You're also missing the semicolon at the end of the &location = sp_x(¤t_sprite, -1) lines.
You don't actually need those lines apart from the first one, &location is set to the rock's position anyway. No difference, just unnecessary
The main problem is the extra closing bracket on line 22. The bit after that is never running if you're facing in direction 6.
(Edit: Not extra, just in the wrong place. Should be 3 at the end.)
About your testing, are you sure that the script never runs that part? Because if the rock is already at 400 then nothing will noticeably happen.
A good thing to do when testing scripts is stick lines in that tell you what is happening, for example
You don't actually need those lines apart from the first one, &location is set to the rock's position anyway. No difference, just unnecessary

The main problem is the extra closing bracket on line 22. The bit after that is never running if you're facing in direction 6.
(Edit: Not extra, just in the wrong place. Should be 3 at the end.)
About your testing, are you sure that the script never runs that part? Because if the rock is already at 400 then nothing will noticeably happen.
A good thing to do when testing scripts is stick lines in that tell you what is happening, for example
//stuff say_stop("stuff just happened", 1); say_stop("location is &location", 1); //more stuff say_stop("more stuff should've happened, I hope it did", 1); //etc
Try using move_stop() instead of move(). That way the hardness will only update after the rock has moved. With move(), it updates at the same time as the rock starts to move, so it will be at the very same spot. If you use move_stop(), though, you'd also probably want to freeze Dink or take some other cautionary measure so that it's not possible for the player to interrupt the script and duck the rock up, figuratively speaking.
Is &location a global variable? I don't think what you are trying to do would work with a local.
Is &location a global variable? I don't think what you are trying to do would work with a local.
July 28th 2010, 07:15 PM

developer


yes, &local is a global. and thanks sparrowhawk for the help, but the last script is still not working. and yes, i am sure the rock is not moving to coordinate 400.
I know this is a stupid question but better to make sure about everything, cause sometimes it's the simple stuff. Are you sure the rock is not already placed to coordinates where the coordinate is over 400?
July 28th 2010, 07:29 PM

developer


the rock is placed at coordinate 350. i have a button script that returns the value of the &location variable everytime i press b, so i can check it, and i see that the last script i posted somehow does not work, as it doesn't run this part:
i have read that there are numerous bugs in the engine still, maybe the entire dinkc part should be fixed
if (&location > 350) etc...
i have read that there are numerous bugs in the engine still, maybe the entire dinkc part should be fixed

Nah, that's just something you are doing wrong.
This script works fine if you change move() to move_stop() and move the bracket to the right place, just tested.
Trying the other one now.....
Ok that one works too, just change it to move_stop again. As Scratcher said, that will make it update the hardness when it has reached the new position instead of when it starts moving. The script isn't running because you're not actually pushing the sprite, just the leftover hardness next to it.
Trying the other one now.....
Ok that one works too, just change it to move_stop again. As Scratcher said, that will make it update the hardness when it has reached the new position instead of when it starts moving. The script isn't running because you're not actually pushing the sprite, just the leftover hardness next to it.
Indeed. There are some bugs in the engine, but nothing quite so fundamental that simple commands suddenly wouldn't work.
EDIT: Unless we are talking about FreeDink, of course... That one could still have all manner of nasty bugs.
EDIT: Unless we are talking about FreeDink, of course... That one could still have all manner of nasty bugs.
July 28th 2010, 07:59 PM

developer


ah yes, it works perfectly with move_stop, thanks guys.
i suppose you are not familiar with implementing this in platform dink? i have done so and it works as well, but when the player pushes the rock he falls through the platform and dies. anyone have any idea? i might need to create a new topic for it...
i suppose you are not familiar with implementing this in platform dink? i have done so and it works as well, but when the player pushes the rock he falls through the platform and dies. anyone have any idea? i might need to create a new topic for it...