• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Lua Some questions about Storage and Global variables

Pteryx

Member
Joined
Mar 5, 2014
Messages
196
Reaction score
20
I've seen Storage used a lot in scripts, but I'm still not sure what can be stored in them. Some background info and questions below.

Note: I don't expect complete answers to all the questions at once. If anyone can answer one or two of them please do so.

As far as I can figure out:
  • There's "player-centric" storage, which uses the player's creatureId and an integer between 1 and 65K to index storage slots - so 64K different slots are available per player. I've only seen integer values stored in these.
  • There's game-level storage, which has a single key, presumably also an integer in the range 1-64, so 64K extra slots in total.
  • The game will save Storage values whenever the game state is saved if a parameter is set for this parameter saveGlobalStorage in config.lua is set to "yes".
Q1. Is it possible to save other values than integers in Storage? Tables would be nice, but strings would be a nice complement to integers
Q2. Is there anything inaccurate in what I wrote above (excluding what can be stored - i.e. Q1)?


I've never seen global variable used in a script, but I read a post in one of the technical forums written by someone who'd done a performance test on them (he said they're 6x faster than Storage). The same article said that there are multiple distinct Lua runtime contexts, suggesting that it's not possible to use standard Lua facilities to communicate between scripts (not a serious functional restriction because of Storage)

Q3. Are there in fact multiple separate Lua contexts in TFS 1.0?
Q4. Can a global variable hold a Lua Table?
Q5. Is there a way to have the game store the values of global variables to disk?
Q6. Is there an API for TFS 1.0 global variables?
 
Last edited:
I know this is an old thread, but I'm trying to learn about storage usage and google redirected me to this thread.
I would appreciate if someone could answers some the questions above: Q1 and Q3

I know that that saveGlobalStorage doesn't exist anymore.

Also, in the newest versions of tfs, the storages won't save its values after server reset so why should they be used instead of global variables? Can there really be any problems with lua contexts as said above?
 
Last edited:
Back
Top