The Dink Network

Vision and variables

October 14th 2013, 02:25 AM
duck.gif
Toof
Peasant He/Him
I disagree. 
Can you connect sprite vision to some other variable value except &story?
October 14th 2013, 03:21 AM
slimeg.gif
metatarasal
Bard He/Him Netherlands
I object 
Sure, you can connect it to any variable you like. Setting a value for the vision should be done in the script attached to a screen and putting in something like this:

void main(void)
{
if (&dead == 4)
{
&vision = 4;
}
}


Where &dead can be any variable you like, you could even do this if you like:

void main(void)
{
if (12 == 4)
{
&vision = 4;
}
}


It's kinda pointless, but hey more power to you!
October 14th 2013, 05:03 AM
custom_coco.gif
cocomonkey
Bard He/Him United States
Please Cindy, say the whole name each time. 
Heyyy, I'm pretty sure 12 never equals 4.

Pretty sure.

Visions are picky! Don't try to do anything fancy with them, just set them with a global variable at the start of the script attached to the screen. Trying to set the vision in ANY other way does not work. I learned this the hard way.
October 14th 2013, 08:04 AM
wizardb.gif
Kyle
Peasant He/Him Belgium
 
You can reload the screen to trigger it, but it will result in a short flicker.
October 14th 2013, 01:15 PM
peasantm.gif
shevek
Peasant They/Them Netherlands
Never be afraid to ask, but don't demand an answer 
I'm pretty sure 12 never equals 4.

Maybe in your math framework it doesn't, but this is DinkC we're talking about. Anything can happen.

Visions are picky!

Not really, but you should realize what they do. When a screen loads, this is what happens:

First the screen's script is run. It can change the value of the &vision variable however it likes. It can change it multiple times as well, and there is no restriction on how it is changed; nothing is done with it yet. If the script does an (implicit or explicit) wait, it has terminated for the purpose of this discussion; it will continue later, but that is not relevant here.

Then the sprites are loaded; sprites which don't match the then current value of &vision will be ignored.

After this, the &vision variable is not used anymore.

This means that if you want to do something with a vision, you must do it in the screen script before any wait. Any other place is allowed, but pointless. There is a DinkC function whose name suggests that it was meant for changing visions without reloading the screen (I don't remember what it's called), but that doesn't work.
October 14th 2013, 01:34 PM
custom_coco.gif
cocomonkey
Bard He/Him United States
Please Cindy, say the whole name each time. 
It's called force_vision, and yep, it does nothing.
October 14th 2013, 06:15 PM
duck.gif
Toof
Peasant He/Him
I disagree. 
Uh... So wait, IF I attach a script that Meta has written up there ( the script attached to a screen, with additional variable ) it will change the vision value for that screen or for the entire dmod? I'm guessing for the entire dmod... I'm kinda busy right now, don't have the time to check it myself, sorry
October 14th 2013, 06:19 PM
spike.gif
It will just change for that one screen. Vision isn't permanent in any way, you will have to set the vision each time you enter a screen or it will default back to 0.
October 14th 2013, 06:23 PM
duck.gif
Toof
Peasant He/Him
I disagree. 
I didn't knew that. I thought that vision is permanent. That solves my problem. Just to put it in a good use now.

Oh, and congrats to Shevek. You've finally got an account . Or you were just lazy to type the password .
October 14th 2013, 06:30 PM
wizardg.gif
leprochaun
Peasant He/Him Japan bloop
Responsible for making things not look like ass 
The &vision global is hardcoded to reset to zero upon a screenchange.

It's either really nice or really annoying. Depends on how many screens have different visions.
October 14th 2013, 06:40 PM
duck.gif
Toof
Peasant He/Him
I disagree. 
Or maybe it doesn't solve my problem. One more question I'll have to deal with later. If sprite ( in this case, staircase ) has hardness and warp function ( obviously ), the hardness, and warp will remain there even if the staircase is not yet visible ( because of the vision value), right?
October 14th 2013, 06:57 PM
wizardg.gif
leprochaun
Peasant He/Him Japan bloop
Responsible for making things not look like ass 
No. If you place a sprite one vision 1 in the editor, that sprite will not appear, it hardness will not be drawn, and it most certainly will not have a warp function while on a different vision.