Thanks once again Venom12, though the game now seems to think the variables are set to something different than they should be (0). I'll try with a new save file and let you know if it works then.
Edit: Just checked and the game still seems to think these variables are set to something other than 0, even though 0 is default. I'm not sure why since it works fine once the game has been loaded. Any ideas?
Edit 2: Upon trying to find out what the variable was set to (by displaying it in a message) I got the following error:
---------------------------
Pokemon Essentials
---------------------------
Exception: TypeError
Message: can't clone FalseClass
PBIntl:654:in `clone'
PBIntl:654:in `_INTL'
MysteryGift:36:in `pbMysteryGiftSearch'
PokemonLoad:645:in `pbStartLoadScreen'
PokemonLoad:521:in `loop'
PokemonLoad:647:in `pbStartLoadScreen'
DebugIntro:6:in `main'
Main:43:in `mainFunctionDebug'
Main

in `mainFunction'
Main

in `pbCriticalCode'
This exception was logged in ./errorlog.txt.
Press Ctrl+C to copy this message to the clipboard.
---------------------------
OK
---------------------------
The exact script I used works when displaying the wonder card message, so the script is not at fault. I'm not sure what is at fault though...