The PokéCommunity Forums

The PokéCommunity Forums (https://www.pokecommunity.com/index.php)
-   Binary ROM Hacking (https://www.pokecommunity.com/forumdisplay.php?f=284)
-   -   Other Good ol' script freeze. [ANSWERED] (https://www.pokecommunity.com/showthread.php?t=325751)

Maglor May 7th, 2014 6:30 PM

Good ol' script freeze. [ANSWERED]
 
I was simply wondering if anyone could take a quick look at this script here which causes the player to freeze when stepping on the script tile. I would be ever grateful tho whoever spots my mishap.

Spoiler:

#dynamic 0x8003D1

#org @start
lock
checkflag 0x200
if 0x1 goto @done
applymovement 0xFF @move1
waitmovement 0x0
msgbox @talk1
callstd 0x5
applymovement 0x01 @move2
applymovement 0x02 @move3
applymovement 0x03 @move4
applymovement 0x04 @move5
waitmovement 0x0
setflag 0x200
release
end

#org @move1
#raw 0x11
#raw 0x11
#raw 0x11
#raw 0x11
#raw 0x11
#raw 0x11
#raw 0x11
#raw 0x12
#raw 0x12
#raw 0x11
#raw 0x11
#raw 0xFE

#org @talk1
= TEST.

#org @move2
#raw 0x10
#raw 0x10
#raw 0x10
#raw 0x10
#raw 0x10
#raw 0x10
#raw 0x60
#raw 0xFE

#org @move3
#raw 0x10
#raw 0x10
#raw 0x10
#raw 0x10
#raw 0x10
#raw 0x10
#raw 0x60
#raw 0xFE

#org @move4
#raw 0x10
#raw 0x10
#raw 0x10
#raw 0x10
#raw 0x10
#raw 0x10
#raw 0x60
#raw 0xFE

#org @move5
#raw 0x10
#raw 0x10
#raw 0x10
#raw 0x10
#raw 0x10
#raw 0x10
#raw 0x60
#raw 0xFE

#org @done
release
end

machomuu May 7th, 2014 6:36 PM

Try getting rid of the "lock" command.

Maglor May 7th, 2014 6:38 PM

Quote:

Originally Posted by machomuu (Post 8236801)
Try getting rid of the "lock" command.

I added the lock command after the freeze happened. So I've tested both with and without it, sadly, still a freeze. :/
(Just did an additional test to doublecheck, froze.)

Mystery Man May 7th, 2014 6:50 PM

The script looks fine to me. I have dealt with similar problems when the script does not have a var number. Have you read "Flags, Vars, & Script Tiles"? (click here and go to the Script Tiles part.)

Edit:
This is what I usually make my script tiles look like:
Spoiler:

This is taken directly from karatekid522's tutorial.
http://i1322.photobucket.com/albums/u563/karatekid552/Image_zps82de8a2e.png

machomuu May 7th, 2014 6:51 PM

Well apart from that, your message box has no type. It's far more simple to use a type than to use callstd for the same effect. But the freeze seems more like a script-to-map problem than anything else.

...You're using XSE, right? I'm not sure if some new script editor has come to take the crown in the past couple of years or not.

Maglor May 7th, 2014 7:05 PM

Quote:

Originally Posted by Mystery Man (Post 8236837)
The script looks fine to me. I have dealt with similar problems when the script does not have a var number. Have you read "Flags, Vars, & Script Tiles"? (click here and go to the Script Tiles part.)

Edit:
This is what I usually make my script tiles look like:
Spoiler:

This is taken directly from karatekid522's tutorial.
http://i1322.photobucket.com/albums/u563/karatekid552/Image_zps82de8a2e.png

So you are suggesting I remove the flag, which is only used due to the @done. And substitute it for a setvar which works, if I have understood it correctly as follows:
Instead of setflag, I put for example
setvar 4050 0x1

for then to set the scripts to var 4050 and value 0.


Quote:

Originally Posted by machomuu (Post 8236840)
...You're using XSE, right? I'm not sure if some new script editor has come to take the crown in the past couple of years or not.

I do indeed, XSE is still the king, atleast to my understanding. I'll try removing callstd 0x5 and rather put msgbox @talk1 0x5. As you said, doubt that is it as its really more of a simpler process rather than a bugcause.


EDIT.
Quote:

Originally Posted by Mystery Man (Post 8236900)
You could do that for efficiency, though I do not believe it to be necessary. As I said, I do not think anything is wrong with the script; however, I do believe the problem to be the script tile. If the var number of the script tile is 0000, the game freezes. So if it is 0000, change it to a safe var number (i.e. 4050 like in the image).

The event now works, I am very grateful, however, it repeats itself whenever I step on the tile. What I did was setting the scripts var to 4011 and value 0. At the end of the script I set var 4050 to 0x1. (when it is compiled it says setvar FAB, no idea why.) Ah yes, so this has solved the freeze, which I am truly happy about, now to solve the repeating script. Unless you immediently see what I have done wrong I guess I can troubleshoot in the tutorial you linked to.

Mystery Man May 7th, 2014 7:12 PM

Quote:

Originally Posted by Maglor (Post 8236874)
So you are suggesting I remove the flag, which is only used due to the @done. And substitute it for a setvar which works, if I have understood it correctly as follows:
Instead of setflag, I put for example
setvar 4050 0x1

for then to set the scripts to var 4050 and value 0.

You could do that for efficiency, though I do not believe it to be necessary. As I said, I do not think anything is wrong with the script; however, I do believe the problem to be the script tile. If the var number of the script tile is 0000, the game freezes. So if it is 0000, change it to a safe var number (i.e. 4050 like in the image).

machomuu May 7th, 2014 7:30 PM

I'll agree with Mystery. It repeats itself because you have no flag, and thus, there is nothing to tell it not to replay the script. The checkflag and the pointer to @done exist so that the script will initiate, but it will end immediately after the check (giving the illusion that the script doesn't initiate at all).

Mystery Man May 7th, 2014 7:33 PM

Quote:

Originally Posted by Maglor (Post 8236874)
The event now works, I am very grateful, however, it repeats itself whenever I step on the tile. What I did was setting the scripts var to 4011 and value 0. At the end of the script I set var 4050 to 0x1. (when it is compiled it says setvar FAB, no idea why.) Ah yes, so this has solved the freeze, which I am truly happy about, now to solve the repeating script. Unless you immediently see what I have done wrong I guess I can troubleshoot in the tutorial you linked to.

Variable numbers are in hex. As such, put the 0x before the var number in the script to tell XSE that it is in hex.

Change the script tile's var number to the one you used in the script. You used 0x4011, so change the script tile var number to that. I believe this is the reason it repeats itself -- if you want to use a variable number as a prevention for it to repeat itself, you would need to make the variable number in the script match that of the script tile. If it continues to repeat itself after doing that, change the var value you have on the script tile to the one you are using (var value 0000 --> 0001)

Maglor May 7th, 2014 7:40 PM

Script is working perfectly fine now. It repeated itself due to the Var number changed itself when compiling for some reason.
Thank you very much guys, I did learn a lot today. I can finally continue this hack.

Quick question though. Can I use the same var for different maps? or is it destructive to do so?

Christos May 8th, 2014 1:42 AM

Quote:

Originally Posted by Maglor (Post 8236970)
Script is working perfectly fine now. It repeated itself due to the Var number changed itself when compiling for some reason.
Thank you very much guys, I did learn a lot today. I can finally continue this hack.

Quick question though. Can I use the same var for different maps? or is it destructive to do so?

The scripts with variables set to them will only activate if their variable is the exact value as the one in the script. in your case 0. Once you set it to 1 when the script is executed, it won't be repeated unless you set it to 0 again. So, the only way to actually reuse a variable properly, is to have your next script check for the variable with a value 1 instead of 0, then set its value to 2 in the script and so on. However, these scripts shouldn't be able to be avoided, since if you miss the script where the variable's value becomes 1 then the script that checks for value of 1 won't be executed. So it is possible to reuse a variable, perhaps for storyline or linked event. By doing this, you would have plenty of variables left for other kinds of script events.

Maglor May 8th, 2014 3:46 AM

Quote:

Originally Posted by Spheal (Post 8237541)
The scripts with variables set to them will only activate if their variable is the exact value as the one in the script. in your case 0. Once you set it to 1 when the script is executed, it won't be repeated unless you set it to 0 again. So, the only way to actually reuse a variable properly, is to have your next script check for the variable with a value 1 instead of 0, then set its value to 2 in the script and so on. However, these scripts shouldn't be able to be avoided, since if you miss the script where the variable's value becomes 1 then the script that checks for value of 1 won't be executed. So it is possible to reuse a variable, perhaps for storyline or linked event. By doing this, you would have plenty of variables left for other kinds of script events.

Sounds good, cheers for answer. Var's have opened a new world for me, woopwoop.


All times are GMT -8. The time now is 9:12 AM.


Like our Facebook Page Follow us on Twitter © 2002 - 2018 The PokéCommunity™, pokecommunity.com.
Pokémon characters and images belong to The Pokémon Company International and Nintendo. This website is in no way affiliated with or endorsed by Nintendo, Creatures, GAMEFREAK, The Pokémon Company or The Pokémon Company International. We just love Pokémon.
All forum styles, their images (unless noted otherwise) and site designs are © 2002 - 2016 The PokéCommunity / PokéCommunity.com.
PokéCommunity™ is a trademark of The PokéCommunity. All rights reserved. Sponsor advertisements do not imply our endorsement of that product or service. User generated content remains the property of its creator.

Acknowledgements
Use of PokéCommunity Assets
vB Optimise by DragonByte Technologies Ltd © 2023.