Hime-Works / Requests

Bug reports and requests that may require longer discussions and is not suitable to leave on the blog
http://himeworks.com/
GNU General Public License v2.0
7 stars 9 forks source link

Global Data #300

Open HimeWorks opened 9 years ago

HimeWorks commented 9 years ago

The engine provides save files by default. Save files store information about a specific instance of the game.

However, sometimes we might want to operate with data that is independent of the save files themselves, which you can call "global data"

There are several different scripts already

Engr. Adiktuzmiko: http://forums.rpgmakerweb.com/index.php?/topic/20304-game-custom-data-v126/ Skul_: http://www.rpgmakervxace.net/topic/6462-global-save-file-by-skul/

Just some examples. There are more out there.

In general, we need support for the following operations

  1. Storing values in the global save file. For example, you flip a switch in-game and it should be stored globally (so that other games know about it)
  2. Retrieving values from the global save file. For example, you want to know the value of a switch that may have been flipped by another game.
  3. Deleting values from the global save file.
Roguedeus commented 9 years ago

Looking forward to more of this.

HimeWorks commented 9 years ago

The actual storage of the file is pretty much up to you. You can use a text file, you can use ruby's serialization like other data files, you can encrypt it compress it all you want.

What's important for me is how you can access it. Because different people may have different security requirements, I would provide an interface that allows you to get and set data, and allow other scripters to implement them as needed.

I would provide an implementation that would use a similar format as the save files.

Let's consider accessing global data.

GlobalData.switch(1)
GlobalData.switch(1, true)

GlobalData.get_switch(1)
GlobalData.set_switch(1, true)

This is one way that you might expose data access by forcing them to go through the interface. Alternatively, you might do it like this

GlobalData.get(:switch, 1)
GlobalData.set(:switch, 1, true)

Where you provide a key as the type of data you want, and some arguments. There's no real difference between them.

HimeWorks commented 9 years ago

Another way to approach this is, instead of thinking of it as some complicated format, why not just think of it as a huge hash map?

GlobalData.set("switch1", true)
GlobalData.set("variable 3", 34)
GlobalData.set("main actor", $game_party.leader)

There's no real reason why it should be complicated: you just need to be able to store data somewhere and get it back right?

Roguedeus commented 9 years ago

thinking in getters and setters is how I originally learned to code... Working in IDE's made me think I was a better coder than a really was... :D

Back when I first started messing with RMVXA I wanted an easy way to record info outside the normal database and save file, but settled for a lot less.

I might have a lot of use for this, if/when you get it done.

HimeWorks commented 9 years ago

The way I have presented the solution, it's basically a huge hash map, rather than having pre-defined data types (eg: switch array, variable array, etc)

This basically means gamedevs will decide how to organize this data. But I'm not sure how user-friendly that might turn out to be.