Picking stuff up so it never comes back
Me again, with another question, I haven't posted in a while as I don't have access to the net at the moment (I'm typing this using a wifi café thing)
How can you get dink to pick stuff up so that it never comes back again? Also, when he picks it up, it doesn't need to go into his inventory or change any of his stats or anything, it just needs to change a global variable.
My attempt doesn't quite work, it's a bit unstable (Sometimes it works, other times it doesn't). I was using this as a temporary bit of code so I could carry on making the rest of the D-Mod 'till I had a chance to ask/find out the proper method: (I'm afraid I don't know how to format it nicely)
void talk(void)
{
freeze(1);
if (&story < 7)
{
say("Hey, a skull! I wonder what it's doing here...", 1);
}
if (&story == 7)
{
say_stop("A skull is a type of bone, right?", 1);
wait(500);
sp_x(¤t_sprite, 750);
sp_y(¤t_sprite, 500);
editor_type(¤t_sprite, 1);
&wdbone += 1;
say_stop("`%<Got Skull>", 1);
wait(500);
say_stop("That brought my total number of bones up to &wdbone", 1);
}
unfreeze(1);
}
So yeah, any help appreciated
I think I might of found how to do it in the DinkC Reference, but I don't really understand it which stops me using it properly...
(Oh, and in case it affects anything {Though I don't see why it should} I am trying to do this using a skull sprite)
How can you get dink to pick stuff up so that it never comes back again? Also, when he picks it up, it doesn't need to go into his inventory or change any of his stats or anything, it just needs to change a global variable.
My attempt doesn't quite work, it's a bit unstable (Sometimes it works, other times it doesn't). I was using this as a temporary bit of code so I could carry on making the rest of the D-Mod 'till I had a chance to ask/find out the proper method: (I'm afraid I don't know how to format it nicely)
void talk(void)
{
freeze(1);
if (&story < 7)
{
say("Hey, a skull! I wonder what it's doing here...", 1);
}
if (&story == 7)
{
say_stop("A skull is a type of bone, right?", 1);
wait(500);
sp_x(¤t_sprite, 750);
sp_y(¤t_sprite, 500);
editor_type(¤t_sprite, 1);
&wdbone += 1;
say_stop("`%<Got Skull>", 1);
wait(500);
say_stop("That brought my total number of bones up to &wdbone", 1);
}
unfreeze(1);
}
So yeah, any help appreciated
I think I might of found how to do it in the DinkC Reference, but I don't really understand it which stops me using it properly...
(Oh, and in case it affects anything {Though I don't see why it should} I am trying to do this using a skull sprite)
void talk(void) { freeze(1); if (&story < 7) { say("Hey, a skull! I wonder what it's doing here...", 1); } if (&story == 7) { say_stop("A skull is a type of bone, right?", 1); wait(500); //following line will make the sprite invisible for now //you are still able to talk to it though //so we will have to remove it later. (If we do it now the script will crash as //it's attached to that sprite.) sp_nodraw(¤t_sprite, 1); //now increese the global &wdbone += 1; //And let's make sure it doesn't come back int &hold = sp_editor_num(¤t_sprite); if (&hold != 0) { editor_type(&hold, 1); } //That will make it stay gone.. say_stop("`%<Got Skull>", 1); wait(500); say_stop("That brought my total number of bones up to &wdbone", 1); unfreeze(1); //Now.. the sprite is still here, even though it's invisible and wont come back. //let's remove it. //but first make sure it's not hard, if it was before. sp_hard(¤t_sprite, 1); draw_hard_map(); sp_kill(¤t_sprite, 1); } unfreeze(1); }
Another way would be adding a void main with:
if(&wdbone > 1) { sp_hard(¤t_sprite, 1); draw_hard_map(); sp_kill(¤t_sprite, 1); }
NOTE: I haven't tested those scripts so you might wanna read them through for typos.
EDIT: I also thought the editor_type(¤t_sprite, 1); would work at first but appearntly sp_editor_num isn't the same as the sprite number. Weird.
No, not weird. editor sprite numbers are the order in which sprites where placed in the editor while sprite numbers are the order in which sprites are drawn on the screen. As Dink is always drawn first (Dink always has sprite number 1) this means that if no scripted sprites are placed first the sprite number is the sprite's editor number plus 1.
Thanks iplaydink, that did it
No typo's as far as I can see, either. Thanks! Have some bananas
No typo's as far as I can see, either. Thanks! Have some bananas
No problems, and thanks for the bananas, I'm going to throw them at a special somebody.
Carrying on from my earlier question (This is kinda in the same vein), could anyone tell me what's wrong with this piece of code? It's taken from void hit(void) and takes place just after a conversation, and this time the code is so dink can destroy a piece of a wall:
The code itself seems to work (the wall vanishes and is replaced with dust) however the hardness remains behind. I must of walked through that cave 20 times testing different bits of code by now
Bananas and stolen cookies to anyone that helps
Edit: Oh, and in case I didn't make it clear, the wall is hard, gets destroyed and leaves the dust sprite behind. The dust should not be hard. As far as I can tell it's the wall's hardness being left behind rather than the dust's hardness
fade_down(); wait(500); sp_nodraw(¤t_sprite, 1); playsound(9, 22050, 0, 1, 0); wait(500); playsound(9, 22050, 0, 1, 0); wait(200); playsound(9, 22050, 0, 1, 0); wait(500); playsound(9, 22050, 0, 1, 0); wait(100); playsound(12, 22050, 0, ¤t_sprite, 0); script_attach(1000); int &hold = sp_editor_num(¤t_sprite); if (&hold != 0) { editor_type(&hold, 1); } sp_hard(¤t_sprite, 1); draw_hard_map(); sp_kill(¤t_sprite, 1); int &dust; &dust = create_sprite(347, 093, 0, 80, 23); sp_nohit(&dust, 1); sp_nodraw(&dust, 0); wait(500); fade_up(); unfreeze(1); kill_this_task(); }
The code itself seems to work (the wall vanishes and is replaced with dust) however the hardness remains behind. I must of walked through that cave 20 times testing different bits of code by now
Bananas and stolen cookies to anyone that helps
Edit: Oh, and in case I didn't make it clear, the wall is hard, gets destroyed and leaves the dust sprite behind. The dust should not be hard. As far as I can tell it's the wall's hardness being left behind rather than the dust's hardness
Try moving sp_hard(); and draw_hard_map to before the editor typ things... right after script attach?
Might work :/
Might work :/
I tried that and... It works! Thank you so much!!
No problem, I've had soooo many problems like that, but sooner or later you learn how to encounter them.
Wait, I spoke too soon, that fixed the hardness thing, but now the wall comes back if I leave and re-enter the screen. *Sigh* Maybe I'll just leave it like that, nothing seems to be working for me today
Edit: Nevermind, I've fixed it now. I re-wrote the start of the code so that the wall is created within the script, and once it's destroyed it changes a Global Variable, so that the script doesn't re-create the wall when I re-enter the screen. Feels good to finally be free of that wall
Edit: Nevermind, I've fixed it now. I re-wrote the start of the code so that the wall is created within the script, and once it's destroyed it changes a Global Variable, so that the script doesn't re-create the wall when I re-enter the screen. Feels good to finally be free of that wall
It probably doesn't work because of script_attach(1000);. The script isn't attached to the wall sprite anymore, so you can't kill the wall sprite by using ¤t_sprite.
Try moving script_attach(1000); right after sp_kill(¤t_sprite,1);.
Try moving script_attach(1000); right after sp_kill(¤t_sprite,1);.
Scratcher's method also works, and saves me a Global Variable, so me thinks I'll his suggestion rather than my long-winded way of doing it. Thanks everyone for helping