Fortress Forever

Fortress Forever (https://forums.fortress-forever.com/index.php)
-   Lua (https://forums.fortress-forever.com/forumdisplay.php?f=44)
-   -   Does the FF Lua script support read/write? (https://forums.fortress-forever.com/showthread.php?t=24150)

ddm999 06-23-2013 01:36 PM

Does the FF Lua script support read/write?
 
I tried using various methods of opening files in the Lua script, but seen as there's about 5 different methods of doing it in different programs using Lua, it's probably better to just ask.

If there is file support, what are the commands, and if there isn't, will we ever see it exist?

If it existed, it'd mean that Lua scripts can actually permanently save settings and the like, rather than them resetting to defaults every map change. :P

Making plugins would be much more viable with an easier way of changing settings in a file, as well as the ability for stuff to be changed in-game.

A few examples:
  • Showing player statistics.
  • Showing custom welcome messages if a player hasn't played on the server before.
  • Setting players listed in a file as 'admin' and allowing them access to more commands.
  • Easier for server admins to change settings out-of-game with a simple text file.
  • Custom variables not used by the game itself, but by the Lua script (say, a custom .cfg containing variables used to alter gameplay).
  • All server plugins able to be converted to Lua, making them easier to update, change, be make specific for a server.

Overall, adding file support gives the Lua script almost the same amount of flexibility as the actual game's code itself.

squeek. 06-24-2013 06:33 AM

I actually added this in 2.44 but no one's used it yet afaik.

Quote:

Originally Posted by 2.44 changelog
  • Added a way to persist Lua data across level changes
    • Functions added:
      • SaveMapData( luaobject ) // saves to maps/data/<mapname>.luadat
      • SaveMapData( luaobject, suffix ) // saves to maps/data/<mapname>_<suffix>.luadat
      • LoadMapData() // returns the loaded lua object from maps/data/<mapname>.luadat
      • LoadMapData( suffix ) // returns the loaded lua object from maps/data/<mapname>_<suffix>.luadat
      • SaveGlobalData( luaobject ) // saves to maps/data/global/global.luadat
      • SaveGlobalData( luaobject, suffix ) // saves to maps/data/global/global_<suffix>.luadat
      • LoadGlobalData() // returns the loaded lua object from maps/data/global/global.luadat
      • LoadGlobalData( suffix ) // returns the loaded lua object from maps/data/global/global_<suffix>.luadat
  • The suffix param gets stripped of all non-alphanumeric and non-underscore characters. The lua object is serialized into binary.
  • Only strings, numbers, booleans, and tables are able to be saved. All other object types are ignored for now (player objects/lua functions for example).

It serializes the table and saves it as binary, so you can't really edit the .luadat file with a text editor, though.

ddm999 06-24-2013 04:32 PM

That's really quite awesome.

Sucks that it's not easily editable like a .cfg though.
But it's easy enough to add chat commands to allow admins to change options, etc.

(why do i always look for things on the wiki and think its updated when it never is :P)

(now to add it to the wiki so next time i search for it its there)

http://www.fortress-forever.com/wiki...ving_functions

:D


All times are GMT. The time now is 11:15 PM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2020, vBulletin Solutions, Inc.