The Dink Network

Weird issue with screenlocks.

September 5th 2016, 05:34 AM
custom_skull.gif
Skull
Peasant He/Him Finland bloop
A Disembodied Sod 
Just noticed this issue today, don't know if anyone else has ever. Basically, add this script to a screen:

void main(void)
{
int &myy;
&myy = sp_y(1, -1);

	if (&myy > 150)
	{
	screenlock(1);
	}
}


Try entering from the below or above screens. Works like it's supposed to, right? The screenlock only activates when you enter from the above screen.

But try entering from the screens to the right and left, and it suddenly gets reversed. If you enter, say, from the right, you now need to be below Y150, for the screenlock to activate. Seems to make no sense. And you can't get rid of the error anyhow. I tried every method within the same script, including both adding an X coordinate to make sure the screenlock never appeared if I entered from the right, and then adding one to unlock the screen if I did. Neither worked. I ended up having to place a separate sprite to make sure once Dink touches it the screen will unlock.

Note that I didn't actually try this on a script added to a screen, so it might work perfectly fine there. I encountered it in an enemy script. Shouldn't make any difference, though.

The X and Y coordinates seem to be completely messed up, anyway. When you script something to be "greater than", it actually counts as "lesser than" and vice versa. I mean, shouldn't the above script make the screenlock appear when Dink is below the specified coordinate, because in Dink, the number of Y increases the further you go down. However, it makes the screenlock appear when you're above it. It's not that bad once you get used to it, but kinda messy.
September 5th 2016, 08:18 AM
spike.gif
Add a wait(1) at the top and it should work. Currently, the script runs before Dink's coordinates are updated for the new screen, so his Y will be what it was on the bottom of the above screen (something like 401). Same thing with X, it's gonna be 620+ on the left side of the screen, and below zero on the right side.

It's actually a pretty useful feature, since you can use it to detect which direction Dink entered the current screen from.
September 5th 2016, 08:40 AM
peasantmb.gif
yeoldetoast
Peasant They/Them Australia
LOOK UPON MY DEFORMED FACE! 
I think the Martridge hut screen script uses it to play the proper music upon entering the screen since it shares it with the Edge of the World.
September 5th 2016, 10:04 AM
custom_skull.gif
Skull
Peasant He/Him Finland bloop
A Disembodied Sod 
Add a wait(1) at the top and it should work. Currently, the script runs before Dink's coordinates are updated for the new screen, so his Y will be what it was on the bottom of the above screen (something like 401). Same thing with X, it's gonna be 620+ on the left side of the screen, and below zero on the right side.

That actually works without the wait(1); command. But just tried it and it doesn't fix this problem. I think you might've misunderstood the issue. It's that if you come from either the right or the left screen, the script somehow reverses itself. If I want the screenlock to appear when I enter the screen above its halfway point, and not when I enter below its halfway point, it'll work just fine entering from the above and the below screens. However, if I enter from the left- or the right-side screen, the screenlock will now appear if I enter below the halfway point, but not if I enter above it.

Actually, now that I looked at it, the reversal only seems to happen entering from the right-side screen. Entering from the left-side screen will cause screenlock no matter what Y position you'll enter. Not sure if this is just some weird issue only I'm running into, or if it's actually a real fault from the original game.

EDIT: Nevermind. You were right, Scratcher. I literally did nothing different this time, and the wait(1); command suddenly started working. Also fixed the whole "greater than"/"lesser than" problem, which hadn't crossed my mind for some reason. Weird how it didn't work at first. Thanks for solving this mystery for me.
September 5th 2016, 10:40 AM
spike.gif
I think what's happening is that you've got the coordinates reversed in the original script. if (&myy > 150) SHOULD activate only when you're in the bottom-half of the screen, but because of the 'feature' I mentioned, Dink's Y is actually reversed (400+ at the top, -0 at the bottom), and therefore the script works in reverse too.

However, when you enter from the left or right, the Y coordinate doesn't change between screens at all, so the script is actually working correctly.

Adding a wait(1) at the top should make it so that the screenlock only activates when Dink is at the bottom end of the screen. If you then change the if check to if (&myy < 150), it should only activate when Dink's at the top part of the screen.

If not... well, DinkC I guess.