The PokéCommunity Forums  

Go Back   The PokéCommunity Forums > Creative Discussions > Game Development > Pokémon Essentials
Sign Up Rules/FAQ Live Battle Blogs Mark Forums Read

Notices

Pokémon Essentials All questions and discussion about Pokémon Essentials, the Pokémon game kit for RPG Maker XP, go in here. Also contains links to the latest downloads and the Essentials Wiki.


Reply
 
Thread Tools
  #1    
Old July 30th, 2012, 06:56 AM
I-Like-Shiny-Pichu's Avatar
I-Like-Shiny-Pichu
Eevee
 
Join Date: Mar 2010
Location: Somewhere that might be near you, but most likely isn't.
Age: 18
Gender: Female
Nature: Lonely
Hi, I am in the process of scripting a Mystery Gift system for the latest version of essentials. All appears to be working well, provided I search for gifts after the game has been loaded. However, if I try and search before the game is loaded I get errors, and I believe this is due to it accessing variables (and changing them). My question is, how can I access (and modify) variables in a save file before pressing "continue" on the load screen? (I have a Mystery Gift button there as well as the other options) If anyone could help ASAP that would be great. Thanks in advance
__________________





Yandere and proud!

HCF

Co-Admin of HCF & TCC
Reply With Quote
  #2    
Old July 30th, 2012, 08:14 AM
venom12's Avatar
venom12
Pokemon Crystal Rain Relased
 
Join Date: Sep 2006
Age: 23
Gender: Male
Nature: Adamant
Send a message via Windows Live Messenger to venom12
So you need to search def pbTryLoadFile(savefile) in pokemonload

and add
$game_switches=Marshal.load(f)
$game_variables=Marshal.load(f)
__________________



Reply With Quote
  #3    
Old July 30th, 2012, 08:29 AM
I-Like-Shiny-Pichu's Avatar
I-Like-Shiny-Pichu
Eevee
 
Join Date: Mar 2010
Location: Somewhere that might be near you, but most likely isn't.
Age: 18
Gender: Female
Nature: Lonely
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'

Mainin `mainFunction'

Mainin `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...
__________________





Yandere and proud!

HCF

Co-Admin of HCF & TCC

Last edited by I-Like-Shiny-Pichu; July 30th, 2012 at 08:45 AM.
Reply With Quote
  #4    
Old July 30th, 2012, 09:00 AM
IceGod64's Avatar
IceGod64
My imagination.
 
Join Date: Oct 2008
Location: Castelia City
Age: 26
Gender: Male
Nature: Naive
When messing with the load scene, I recommend deleting your save file entirely. I.E, delete game.rxdata from C:\users\YOURNAME\saved games\

I don't know if that's the solution in this particular case, but perhaps.
__________________

Reply With Quote
  #5    
Old July 30th, 2012, 10:29 AM
I-Like-Shiny-Pichu's Avatar
I-Like-Shiny-Pichu
Eevee
 
Join Date: Mar 2010
Location: Somewhere that might be near you, but most likely isn't.
Age: 18
Gender: Female
Nature: Lonely
I shall delete my save file and see if it works after that

Edit: No, it still gives me the same error upon trying to display the contents of the variable.
__________________





Yandere and proud!

HCF

Co-Admin of HCF & TCC
Reply With Quote
  #6    
Old July 30th, 2012, 12:33 PM
Rai Rai's Avatar
Rai Rai
Master of everything!
 
Join Date: Aug 2010
Gender: Male
Quote:
Originally Posted by I-Like-Shiny-Pichu View Post
I shall delete my save file and see if it works after that

Edit: No, it still gives me the same error upon trying to display the contents of the variable.
Remove what venom12 said to add in pokemonload. If you're trying to access the game variables before the save file is loaded, then you will need to add in these two lines in the main script just under the line where it says $game_system = Game_System.new
$game_variables = Game_Variables.new
$game_switches = Game_Switches.new
__________________
Reply With Quote
  #7    
Old July 30th, 2012, 01:14 PM
I-Like-Shiny-Pichu's Avatar
I-Like-Shiny-Pichu
Eevee
 
Join Date: Mar 2010
Location: Somewhere that might be near you, but most likely isn't.
Age: 18
Gender: Female
Nature: Lonely
Thanks Rai Rai. It now (seems) to be loading the variables before the game is loaded. However, upon loading the game the variables are reset. Do I need to add something to my script so that this doesn't happen?
__________________





Yandere and proud!

HCF

Co-Admin of HCF & TCC
Reply With Quote
  #8    
Old July 30th, 2012, 01:35 PM
Rai Rai's Avatar
Rai Rai
Master of everything!
 
Join Date: Aug 2010
Gender: Male
Quote:
Originally Posted by I-Like-Shiny-Pichu View Post
Thanks Rai Rai. It now (seems) to be loading the variables before the game is loaded. However, upon loading the game the variables are reset. Do I need to add something to my script so that this doesn't happen?
Well, you could try open the save file, then dump the variable changes into it. Give me a few minutes and I'll post a reply with the commands you need.

EDIT:

Within the main script once more place the following code just after the snippet I gave you earlier.
Code:
    savefile=RTP.getSaveFileName("Game.rxdata")
    if safeExists?(RTP.getSaveFileName("Game.rxdata"))
      File.open(savefile){|f|
          $Trainer             = Marshal.load(f)
          Graphics.frame_count = Marshal.load(f)
          $game_system         = Marshal.load(f)
          Marshal.load(f) # PokemonSystem already loaded
          Marshal.load(f) # Current map id no longer needed
          $game_switches       = Marshal.load(f)
          $game_variables      = Marshal.load(f)
          $game_self_switches  = Marshal.load(f)
          $game_screen         = Marshal.load(f)
          $MapFactory          = Marshal.load(f)
          $game_map            = $MapFactory.map
          $game_player         = Marshal.load(f)
          $PokemonGlobal       = Marshal.load(f)
          metadata             = Marshal.load(f)
          $ItemData            = readItemList("Data/items.dat")
          $PokemonBag          = Marshal.load(f)
          $PokemonStorage      = Marshal.load(f)
      }
    end
That will load up everything before the game fully initializes the save file. To make it so that the game then keeps the changes I guess you would have to do something like the following in the section where your script is ending:

Code:
    savefile=(RTP.getSaveFileName("Game.rxdata"))
    if safeExist?(savefile)
      File.open(RTP.getSaveFileName("Game.rxdata"),"wb"{|f|
         Marshal.dump($game_variables,f)
         Marshal.dump($game_switches,f)
      }
    end
__________________

Last edited by Rai Rai; July 30th, 2012 at 01:42 PM.
Reply With Quote
  #9    
Old July 30th, 2012, 01:53 PM
I-Like-Shiny-Pichu's Avatar
I-Like-Shiny-Pichu
Eevee
 
Join Date: Mar 2010
Location: Somewhere that might be near you, but most likely isn't.
Age: 18
Gender: Female
Nature: Lonely
It is now giving me an error upon loading the game.."Cannot convert Game_Switches to integer". Any ideas what the problem is? Thanks so much for all your help so far, I can feel that we are very close to solving this
__________________





Yandere and proud!

HCF

Co-Admin of HCF & TCC
Reply With Quote
  #10    
Old July 30th, 2012, 02:06 PM
Rai Rai's Avatar
Rai Rai
Master of everything!
 
Join Date: Aug 2010
Gender: Male
Quote:
Originally Posted by I-Like-Shiny-Pichu View Post
It is now giving me an error upon loading the game.."Cannot convert Game_Switches to integer". Any ideas what the problem is? Thanks so much for all your help so far, I can feel that we are very close to solving this
I got a feeling it's because I made a little mistake on this part of the code:
Code:
    savefile=(RTP.getSaveFileName("Game.rxdata"))
    if safeExist?(savefile)
      File.open(RTP.getSaveFileName("Game.rxdata"),"wb"{|f|
         Marshal.dump($game_variables,f)
         Marshal.dump($game_switches,f)
      }
    end
Change this line File.open(RTP.getSaveFileName("Game.rxdata"),"wb"{|f| to File.open(RTP.getSaveFileName("Game.rxdata")),"wb"{|f|
I accidentally missed one bracket on the line XD. Hopefully that should fix it.

EDIT:
Ignore that, it seems the method for saving the file information is a bit different compared to what I was expecting. I'll add in a fix soon as I can.
__________________

Last edited by Rai Rai; July 30th, 2012 at 02:14 PM.
Reply With Quote
  #11    
Old July 30th, 2012, 02:09 PM
I-Like-Shiny-Pichu's Avatar
I-Like-Shiny-Pichu
Eevee
 
Join Date: Mar 2010
Location: Somewhere that might be near you, but most likely isn't.
Age: 18
Gender: Female
Nature: Lonely
No, I corrected that already (I realized you had made a typo). Upon deleting the now corrupted save file I noticed that it was only 1kb, which seems awfully small...maybe only part of the save file is being saved?

Edit: I replaced the commands you gave me with "pbSave" and it works..nearly...problem is, since it saves the map etc as well...it cannot load. I think I need to somehow edit just the variables line while keeping the rest of the save intact.
__________________





Yandere and proud!

HCF

Co-Admin of HCF & TCC
Reply With Quote
  #12    
Old July 31st, 2012, 04:22 AM
Maruno's Avatar
Maruno
Lead Dev of Pokémon Essentials
 
Join Date: Jan 2008
Location: England
So much dodgy advice...

The menu and game-loading all appear in the same method. What I would do is save the required data into a random unrelated variable (called sausage or something) when you use the Mystery Gift, and then after loading/starting a new game, add the MG data to whichever variables to need as you would normally (as if you were in the middle of a game).

There's no need to change when the save information is loaded. That's just too complicated for what you want to do.

I don't know what changes you've made to the code to incorporate the Mystery Gift function, so I can't be more specific. If you want directions, you can show us/me what you've done.
__________________
Reply With Quote
  #13    
Old July 31st, 2012, 06:34 AM
I-Like-Shiny-Pichu's Avatar
I-Like-Shiny-Pichu
Eevee
 
Join Date: Mar 2010
Location: Somewhere that might be near you, but most likely isn't.
Age: 18
Gender: Female
Nature: Lonely
All I've done to add the mystery gift currently is just replaced the options button (I don't want it there) with a button that calls the mystery gift script. I'm not entirely sure what you are telling me to do to be quite honest...As all the variables reset to what they were when the game was saved, I don't quite know how I can save all the information to a variable and then use that to set all the others. I could probably save all the information to a file and then load it from that when loading the game, but then the file is open to tampering (and I'm pretty sure there are people who would do that). Sorry for being such a pain, I'm quite new to scripting and learning as I go.
__________________





Yandere and proud!

HCF

Co-Admin of HCF & TCC
Reply With Quote
  #14    
Old July 31st, 2012, 08:01 AM
Maruno's Avatar
Maruno
Lead Dev of Pokémon Essentials
 
Join Date: Jan 2008
Location: England
The Mystery Gift script should return the information it gathered, rather than try to record it somewhere. That information can then hang around in the def pbStartLoadScreen until it has loaded the save/started a new game, and then you can add the Mystery Gift information to the appropriate variables.

It's hard to explain in an abstract manner (i.e. when you don't have the code itself to point at).

Alternatively, don't have the Mystery Gift there. Put it in the main game instead. It would be easier.
__________________
Reply With Quote
  #15    
Old July 31st, 2012, 09:12 AM
I-Like-Shiny-Pichu's Avatar
I-Like-Shiny-Pichu
Eevee
 
Join Date: Mar 2010
Location: Somewhere that might be near you, but most likely isn't.
Age: 18
Gender: Female
Nature: Lonely
If it will help, I can PM you the Mystery Gift script as it stands currently, its not yet complete as all it does is searches for the gift, checks if the player has the gift already etc.

Edit: This problem has now been solved via PM. This thread can now be closed if a mod wishes to do so.
__________________





Yandere and proud!

HCF

Co-Admin of HCF & TCC

Last edited by I-Like-Shiny-Pichu; August 2nd, 2012 at 03:50 AM.
Reply With Quote
Reply
Quick Reply

Sponsored Links
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Minimum Characters Per Post: 25



All times are UTC -8. The time now is 04:57 AM.


Style by Nymphadora, artwork by Sa-Dui.
Like our Facebook Page Follow us on Twitter © 2002 - 2014 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 - 2014 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.