1. altering the database code to use MariaDB (or Postgre SQL or even MySQL) or similar distributed-server-friendly dedicated DBMS; and
2. altering the player persistence code to use DB tables rather than filesystem files which update more slowly and probably contribute to the "inventory lag" and are not friendly to multiple-server deployments; and
3. providing a persistence API for scripts to persist player data in some standardized manner. creating "inventories" in a mod to store a new health/hunger/money/whatever stat seems hackish at best. A possible ocnsideration is a generalized API that initializes a template as an abstracted player-centric persistence object usable in lualand via attributes and having under-the-hood code persisting attribute alteration (to the DBMS or files depending on feasibility of point #2) on the object automatically.
Any thoughts on these ideas?
EDIT2:
example API use case:
- Code: Select all
--
-- prototype: playerdata.new(modname,template,resetFlag)
--
-- modname - the name of the mod and should be the same as the name used initially
-- by the mod to register the mod with the engine
--
-- template - an object whose keys will used to synchronize return object
-- with the corresponding persisted data
--
-- resetFlag - false: values are defaults if not persisted data currently exists
-- (data survives server restart)
-- - true: values always reset to match whether current data exists or not
-- (data reset on server restart)
-- mystats["this"] and mystats["foo"] become per-player persistent attributes
mystats=playerdata.new({"this"="that","foo"="bar"},false)
-- mod may now use/alter mystats["foo"] and mystats["this"]
-- as desired, values are per-character and will automatically
-- persist unless resetFlag was true (in which case they reset
-- to the defaults on server restart)
-- EDIT: as far as I know the internal api code knows only
-- which player is involved with a current script's execution
-- but not the mod originating the call
-- mystats should be kept as a global by the mod's init.lua
-- (or a script called from init.lua) within the mod's namespace
-- (allowing a uniform way for other mods to access
-- eg: thismod["mystats"] accessed from thatmod)