The Dink Network

Windemere variable thing

June 20th 2005, 03:49 PM
goblinm.gif
The following is based on my probably flawed understanding of the Dink engine:

One of the good (bad) things about dink is that, basically, only one script runs at a time. This means that you can have globals like &current_sprite and &missile_target, because for example, when an arrow hits something, and its damage proc is run, there are no other damage procs running at that exact instant, so &missile_target is well defined...

If multiple scripts were running at once, then you'd have a problem... I suppose &missile_target could several values simultaneously, differentiated only by context, but then it'd hardly be a global...

So, does Windemere run scripts simultaneously? If not, do &current_sprite, &enemy_sprite, &missile_target, etc. stay? Or will they be replaced by something more stable?
June 20th 2005, 04:30 PM
fish.gif
Simeon
Peasant He/Him Netherlands
Any fool can use a computer. Many do. 
Well, the Dink engine is capable of running more than one script at the same time. If you have two sprites with the same script attached and you'll let them say something (so they'll both do it), both sprites talk so &current_sprite works like it should. Same thing when spawn()-ing a script, it'll run simultaneously as the script it was spawned from. Like you can see in redink1's Savegame Editor; a variable has a variable-name but also a scope: the scope is either 0 meaning a global variable or the number of the script that uses it. Same thing applies to the global ones I think. I haven't tested a script that fires two arrows when Dink fires (you'd also have to set the same distance to both target sprites and so on) but I don't think it'll cause trouble for the variables involved.. but it would have to be tested to be sure.
June 20th 2005, 05:01 PM
goblinm.gif
If the scripts ran at exactly the same time, wouldn't only one talk? I mean, &current_sprite can only have one value at any given moment, and I'd assume that's the value of the sprite whose script is running.
June 20th 2005, 05:09 PM
custom_king.png
redink1
King He/Him United States bloop
A mother ducking wizard 
Milo: I'm pretty sure those will be completely gone.

I think &current_sprite, &enemy_sprite, &missile_target are special variables. They're not real globals, so they'll work in whatever script calls them.

Simeon: Sort of. Dink isn't multi-threaded, so it can really only run one script at an exact instant. It runs one script and then the other in such a quick succession that you don't realize it.

If you do no-wait-infinite-loop, the game locks up, because it is devoting itself to running that one script until it gets to a wait or the end of the script function.

As it is, variable scoping in the Dink engine is not reliable. Try something like this:

void main(void)
{
int &rand = random(1,100);
say("&rand", &current_sprite);
}

And attach it to multiple sprites on the same screen. They'll all say the same number (... I think).
June 20th 2005, 05:19 PM
custom_magicman.gif
magicman
Peasant They/Them Netherlands duck
Mmmm, pizza. 
void main(void)
{
int &rand = random(1,100);
say("&rand", &current_sprite);
}


The last few posts. Saying isn't affected, speed etc is.
June 20th 2005, 05:29 PM
goblinm.gif
I did (almost) exactly that experiment once, and it does exchange variables, which has never made sense to me.

I see what your saying... &current_sprite isn't declared in main.c. The others are though, which explains why Seth is paranoid about them (in the missile scripts he likes to assign &missile_target to a local.)

I had just guessed that they all really existed, so that &missile_target still has a value even when there's no damage proc running. But I could be totally wrong, I should test it...
June 23rd 2005, 02:12 AM
dragon.gif
just one question...

what the heck is windemere!?
June 23rd 2005, 06:59 AM
fish.gif
Simeon
Peasant He/Him Netherlands
Any fool can use a computer. Many do. 
They say it's a duck-worshipping village in the original game...
June 23rd 2005, 07:31 AM
slimeg.gif
metatarasal
Bard He/Him Netherlands
I object 
It's either Charlies real estate in disguise, or it's a Dink source project.

the choice is yours...
June 23rd 2005, 07:36 AM
dragon.gif
i looked at one of the screenshots, with dink and another guy standing, but it wasn't a screen! (as i saw it...)

will dink still have screens?
and is it possible to make movies in your D-mod?

June 23rd 2005, 02:41 PM
wizardb.gif
merlin
Peasant He/Him
 
That's the wrong URL. I should probably take that site down. :-/

The new site's over here: http://windemere.dinkworld.com/
June 23rd 2005, 03:27 PM
slimeg.gif
metatarasal
Bard He/Him Netherlands
I object 
Okay, I'll change the link...