Read my post above again, I edited it because...
Game Custom Data v1.26
RGSS3 Scripts (RMVX Ace)Do you mean like this? If I put it above the def self.create_game_objects it results in another error, so I put it below it but above "create_game_objects_customdata"
module DataManager class <<self; alias create_game_objects_customdata create_game_objects; end def self.create_game_objects $adik_custom_data[😛ersistent_switches] = {} $adik_custom_data[😛ersistent_variables] = {} create_game_objects_customdata CustomData.get🙂persistent_switches).each {|key,value| $game_switches[key] = value} unless CustomData.get🙂persistent_switches).nil? CustomData.get🙂persistent_variables).each {|key,value| $game_variables[key] = value} unless CustomData.get🙂persistent_variables).nil? endendIt still didn't make the switch persistent, though.
module DataManager class <<self; alias create_game_objects_customdata create_game_objects; end def self.create_game_objects $adik_custom_data[😛ersistent_switches] = {} $adik_custom_data[😛ersistent_variables] = {} create_game_objects_customdata CustomData.get🙂persistent_switches).each {|key,value| $game_switches[key] = value} unless CustomData.get🙂persistent_switches).nil? CustomData.get🙂persistent_variables).each {|key,value| $game_variables[key] = value} unless CustomData.get🙂persistent_variables).nil? endendIt still didn't make the switch persistent, though.
Hmmm... Wait no. loading of the file happens before that so it still overwrites the loaded array...
do it like this
do it like this
Code:
module DataManager class <<self; alias create_game_objects_customdata create_game_objects; end def self.create_game_objects $adik_custom_data[:persistent_switches] = {} if $adik_custom_data[:persistent_switches].nil? $adik_custom_data[:persistent_variables] = {} if $adik_custom_data[:persistent_variables].nil? create_game_objects_customdata CustomData.get(:persistent_switches).each {|key,value| $game_switches[key] = value} unless CustomData.get(:persistent_switches).nil? CustomData.get(:persistent_variables).each {|key,value| $game_variables[key] = value} unless CustomData.get(:persistent_variables).nil? endend
Yep, that one works! 😀
Thank you very much for the help!
Thank you very much for the help!
I don't know if I am doing something wrong. So doses this script have a limit of how many variables it save because every time I try to save more than 3 global variables it unsaves an older one
Can you show me what you're doing exactly? It should be able to save any amount as long as the setup is correct
here is how I set them up
@AgentN107
And how did you know its unsaving other stuff when you did it? I need to also see how you're loading/reading the values that you have saved/set. Also include the step by step on how you reach that usage (like if you saved the game, exited, then loaded a saved file first before testing the loading of values)
Here's a possible explanation though just based from what you've written and how I intended it to be used and my working knowledge of RGSS3.
Can you also explain what you're trying to do exactly? It would be easier to explain to you how to do it if I know what it is exactly that you want to do.
And how did you know its unsaving other stuff when you did it? I need to also see how you're loading/reading the values that you have saved/set. Also include the step by step on how you reach that usage (like if you saved the game, exited, then loaded a saved file first before testing the loading of values)
Here's a possible explanation though just based from what you've written and how I intended it to be used and my working knowledge of RGSS3.
Normally, you'd give the get/set method a string or a symbol to use as a key, not a variable.. like
What might be happening here is that since you're giving it $game_system.note11, which is a variable, as the key, it is possibly using the actual value of note11 as the key, which might be the same value as the other "notes" in which case you saved three times on the same key.
for example, if before you called those lines, all the three "note" variables are true, then you're practically calling
Code:
CustomData.set("note11",true)
What might be happening here is that since you're giving it $game_system.note11, which is a variable, as the key, it is possibly using the actual value of note11 as the key, which might be the same value as the other "notes" in which case you saved three times on the same key.
for example, if before you called those lines, all the three "note" variables are true, then you're practically calling
Code:
CustomData.set(true,true)
CustomData.set(true,true)
CustomData.set(true,true)
Can you also explain what you're trying to do exactly? It would be easier to explain to you how to do it if I know what it is exactly that you want to do.
That fixed it but just in case I will explain the use. So I am using it for a global item system and used the global variables from that for all collectabls found system these systems use events and conditional branchs.
Hey, there! Thank you so much for this script!
I'm getting an error message for the Persistent Data add-on, though. It doesn't have any issues if I remove the add on, and I've run this in a vanilla game with no other scripts.
I'm getting an error message for the Persistent Data add-on, though. It doesn't have any issues if I remove the add on, and I've run this in a vanilla game with no other scripts.
Remove the keyword do in the line the error points you at.
EDIT: Looks like someone else reported this error on page 3 back in 2015, yet the fix was never applied to the pastebin.
Code:
CustomData.get(:persistent_switches).each {|key,value| $game_switches[key] = value}
CustomData.get(:persistent_variables).each {|key,value| $game_variables[key] = value}
EDIT: Looks like someone else reported this error on page 3 back in 2015, yet the fix was never applied to the pastebin.
Yeah, I somehow forgot to actually update the add-on script so it has some errors..
Thank you @KK20 ! I removed the do's, at which point (when I launched) the game gave an error that 'each' was undefined. So I removed those, and the game ran, but broke again when I tried to increase the variable I'd set.
For reference, line 78's code is:
For reference, line 78's code is:
Code:
x = $adik_custom_data[:persistent_variables][variable_id] = value
Just refer to the posts in page 3. Everything you mentioned has already been discussed.
I went through and looked at pages 3 and 4, but I'm honestly confused as to what lines of code are the 'fixed' ones...
I applied each change as I found it, deleting the last, and got errors every time. The last one (that worked for Sapiboong) still gave an error for me, which I've attached below. It's a long piece of code, so in the editor it's just 1 line that extends far beyond the given text page--not sure if that could cause anything to break?
But then I'm not sure how to format it properly, either. (I tried and it broke even more >~< so I undid those changes.)
I applied each change as I found it, deleting the last, and got errors every time. The last one (that worked for Sapiboong) still gave an error for me, which I've attached below. It's a long piece of code, so in the editor it's just 1 line that extends far beyond the given text page--not sure if that could cause anything to break?
But then I'm not sure how to format it properly, either. (I tried and it broke even more >~< so I undid those changes.)
Going to assume the corrected module is in this post.
https://forums.rpgmakerweb.com/index.php?threads/game-custom-data-v1-26.20304/page-4#post-420188
Replace module DataManager with this one:
https://forums.rpgmakerweb.com/index.php?threads/game-custom-data-v1-26.20304/page-4#post-420188
Replace module DataManager with this one:
Code:
module DataManager
class <<self; alias create_game_objects_customdata create_game_objects; end
def self.create_game_objects
$adik_custom_data[:persistent_switches] = {} if $adik_custom_data[:persistent_switches].nil?
$adik_custom_data[:persistent_variables] = {} if $adik_custom_data[:persistent_variables].nil?
create_game_objects_customdata
CustomData.get(:persistent_switches).each {|key,value| $game_switches[key] = value} unless CustomData.get(:persistent_switches).nil?
CustomData.get(:persistent_variables).each {|key,value| $game_variables[key] = value} unless CustomData.get(:persistent_variables).nil?
end
end
Seems like I should really work on an official fix and update the script on pastebin.. I'll do that later today, hopefully it will be finished quickly.
Edit: Updated the add-on script.. It should now work correctly even when loading a save file created before adding the script.. I realized I never actually initialized the persistent switch/var hash/array on the earlier versions..
Edit: Updated the add-on script.. It should now work correctly even when loading a save file created before adding the script.. I realized I never actually initialized the persistent switch/var hash/array on the earlier versions..
Thank you guys so much! It's working 100% now! ヽ(>∀<☆)ノYou are amazing!
I just have 1 final question, in case I ever need it in the future; how do you write a 'key'? What's it supposed to look like?
I just have 1 final question, in case I ever need it in the future; how do you write a 'key'? What's it supposed to look like?
From what I know, hashes can take either integers, strings or symbols...
like
hash[1]
hash["string"]
hash[:symbol]
In the add-on script, I used symbols...
like
hash[1]
hash["string"]
hash[:symbol]
In the add-on script, I used symbols...
Okay, thank you~! <3
Original thread: https://forums.rpgmakerweb.com/threads/game-custom-data-v1-26.20304/