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)
-   -   Script Yes/No Scripts (https://www.pokecommunity.com/showthread.php?t=410375)

Ace Trainer Slash July 4th, 2018 2:55 PM

Yes/No Scripts
 
Hello :)

I tried making my very first Yes/No script a few days ago, but there seems to be an error.
The Script is in spoilers.
The error is that whenever I click the 'No' option in-game, it wouldn't do anything, and if I clicked the A button, it would loop the Yes/No script for some reason. When I click the 'Yes' option in game however, it works as intended to.
Any ideas on what I have made an error in via script?

Spoiler:
#dynamic 0x800000

#org @start
lock
faceplayer
msgbox @question 0x5
compare 0x800D 0x1
if 0x1 goto @yes
compare 0x800D 0x0
if 0x0 goto @no
end

#org @yes
msgbox @dedenne 0x6
release
end

#org @no
msgbox @excuse 0x6
release
end

#org @question
= Hi there, you like Dedenne?

#org @dedenne
= Oh, you like Dedenne?\n Truly Excellent!

#org @excuse
= Excuse me?!\nDon't talk to me\lagain!

DrFuji July 4th, 2018 3:50 PM

You've used the 'if' statement for @no incorrectly. When you're checking for an exact number in a variable (in this case, 0x0 as that's what's returned when you say no) you need to have the if statement be 0x1 like this:

Spoiler:
...
compare 0x800D 0x0
if 0x1 goto @no
end


This value is has the following meanings:

Code:

Lower Than (0x0)
Equals (0x1)
Greater Than (0x2)
Lower than or Equal to (0x3)
Greater than or Equal to (0x4)
Not exactly equal to (0x5)


You can also rewrite this script to make it shorter and less of a hassle. Since you're using a Yes/No msgbox you only need to make one check to find out the player's answer. Once you've branched the script off to @yes there's no need to check 0x800D again for @no as its a binary question. Here's what it should look like:

Spoiler:
#dynamic 0x800000

#org @start
lock
faceplayer
msgbox @question 0x5
compare 0x800D 0x1
if 0x1 goto @yes
msgbox @excuse 0x6
release
end

#org @yes
msgbox @dedenne 0x6
release
end

#org @question
= Hi there, you like Dedenne?

#org @dedenne
= Oh, you like Dedenne?\nTruly Excellent!

#org @excuse
= Excuse me?!\nDon't talk to me again!

Ace Trainer Slash July 4th, 2018 4:45 PM

Oh... Ok then!
Thankyou for correcting my error, and the extra insights of making the script shorter. :)
This will prove helpful to me in the future the next time I attempt Yes/No scripts! :D


All times are GMT -8. The time now is 9:14 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.