The Dink Network

Hold

October 3rd 2009, 05:15 AM
custom_msdink.png
MsDink
Peasant She/Her New Zealand
Tag - Umm.. tag, you're it? 
Trying to find something on the hold function - pushing the rock out of the way and make it stay put - can someone please explain this to me... I am sure its there somewhere but I can't find it and I am not getting any younger *sigh*
October 3rd 2009, 05:33 AM
slimeg.gif
metatarasal
Bard He/Him Netherlands
I object 
The hold function? I don't think there is a hold function in Dink.

If you want a rock to be pushed out of the way permanently you'll have to use a global. Something like this:

void main(void)
{
  if (&story > 4)
  {
    sp_x(&current_sprite,500);
    draw_hard_map();
  }
}

void push(void)
{
  if (&story == 4)
  {
    int &ddir = sp_dir(1,-1);
    if (&ddir == 6)
    {
      freeze(1);
      sp_speed(&current_sprite,1);
      move_stop(&current_sprite,6,500,1);
      &story = 5;
      draw_hard_map();
      unfreeze(1);
    }
  }
}

October 3rd 2009, 05:47 AM
custom_msdink.png
MsDink
Peasant She/Her New Zealand
Tag - Umm.. tag, you're it? 
Thanks metatarasal, can you explain what part of that makes it stay in place - I am brain dead and just going round in circles, but if I can understand then I can play with it <-- grins sheepishly
Actually thought I might have a go at a really basic help file for technologically challenged dinkers like myself after i get this one finished. Its getting huge cause when i hit a scripting prob I start making more screens LOL soon it aint gunna fit *Grin*
October 3rd 2009, 05:56 AM
spike.gif
Have to? Unless the act of moving the rock is somehow important to other scripts, it's much neater to use editor_seq and/or editor_frame. Relatively simple and doesn't waste a global:

void main(void)
{
int &mahnum = sp_editor_num(&current_sprite);
int &mahseq = editor_seq(&mahnum,-1)
if (&mahseq == 1)

{
sp_x(&current_sprite,500);
draw_hard_map();
}
}

void push(void)
{
if (&mahseq == 0)
{
int &ddir = sp_dir(1,-1);
if (&ddir == 6)
{
freeze(1);
sp_speed(&current_sprite,1);
move_stop(&current_sprite,6,500,1);
editor_seq(&mahnum,1);
&mahseq = 1;

draw_hard_map();
unfreeze(1);
}
}
}
October 3rd 2009, 06:05 AM
custom_msdink.png
MsDink
Peasant She/Her New Zealand
Tag - Umm.. tag, you're it? 
That holds the rock in place and I can no longer push it anywhere... or am I supposed to blend it with what I am using? (Sorry I no comprendee) also - I didnt want dink to be able to push it till he was 6 strength (the easy way of not letting him into another section too soon) err well so I thought
October 3rd 2009, 06:41 AM
spike.gif
Yes, of course, it's just a demonstration script. How could we know exactly what you want?
October 3rd 2009, 06:48 AM
custom_msdink.png
MsDink
Peasant She/Her New Zealand
Tag - Umm.. tag, you're it? 
ok - which part of that makes the rock stay where it was pushed so Dink comes back the rock doesn't block his way?
ps thanks for your patience.....
October 3rd 2009, 07:48 AM
spike.gif
The bold part. More specificly,
editor_seq(&mahnum,1);
changes the value of the rock's editor sequence, and
int &mahseq = editor_seq(&mahnum,-1)
if (&mahseq == 1)
checks what that value is.
int &mahnum = sp_editor_num(&current_sprite);
is needed for both being able to see what the value of editor_seq is, and being able to change it reliably. Since editor_seq is changed when the player pushes the rock, by checking the value of editor_seq at the beginning of the script, we can tell whether the player has moved the rock before or not.

It's a few extra lines of complication and confusement, but the benfit is that you don't waste a global on something that really doesn't need it (all in all, you can only have about 200 different global variables- not to even mention how totally nasty clogging main.c with unnecessary globals looks like ).

Using a global variable works just as well, (&story = 5; changes the value, if (&story == 5) checks what that value is), you just have to declare the global first. In that example, the declaration line would be:
make_global_int("&story",0);
All the globals are usually declared in a dmod's main.c script. Check it out!

PS. Not sure whether that cleared anything up or just made it sound more complicated. Feel free to ask as many questions as you want, but reading some tutorials (the dinkC reference and metatarasal's introduction to dmod making are good ones to start with) would be a very good idea, too, especially concerning global variables and if statements and such; it's... pretty basic stuff, and the tutorials give a much broader overview and understanding of DinkC than answers to specific questions here on the board.
October 3rd 2009, 07:06 PM
custom_msdink.png
MsDink
Peasant She/Her New Zealand
Tag - Umm.. tag, you're it? 
Thanks for taking the time to baby step this Scratcher - yer a sweetie and I really appreciate it. I have looked thru heaps of scripting things (including the two you mentioned) but there's so much of it, it gets really confusing as to which part is relevant to what I am looking for. Plus the older stuff on here is for everything BUT win dink edit + and being a noobie I could spend days trying everything out and still not have an answer (like I did this time) so thanks for the help and I really appreciate it.