Category:Lua saving functions

From Fortress Forever Wiki
Jump to: navigation, search


Mapping for FF
The Basics

Setting up Hammer
Getting Started With Lua
Releasing a map

FF-specific Entities

Lua location system

Map Templates
FF Lua Documentation

Entity Typing
Entity Collections

Commands
Callbacks

The Lua saving functions (added in FF version 2.44) allow you to preserve Lua data across map changes.

There are separate commands for both map specific data and global (can be opened by any map) data.

LUA Command Description File Location
SaveMapData( luaobject ) saves the object 'luaobject' in a file named after the map name "maps/data/<mapname>.luadat"
SaveMapData( luaobject, suffix ) saves the object 'luaobject' in a file with 'suffix' placed after the map name "maps/data/<mapname>_<suffix>.luadat"
luaobject = LoadMapData() loads the object 'luaobject' in a file named after the map name "maps/data/<mapname>.luadat"
luaobject = LoadMapData( suffix ) loads the object 'luaobject' in a file with 'suffix' placed after the map name "maps/data/<mapname>_<suffix>.luadat"
SaveGlobalData( luaobject ) saves the object 'luaobject' in a file called "global" "maps/data/global/global.luadat"
SaveGlobalData( luaobject, suffix ) saves the object 'luaobject' in a file with 'suffix' placed after "global" "maps/data/global/global_<suffix>.luadat"
luaobject = LoadGlobalData() loads the object 'luaobject' in a file called "global" "maps/data/global/global.luadat"
luaobject = LoadGlobalData( suffix ) loads the object 'luaobject' in a file with 'suffix' placed after "global" "maps/data/global/global_<suffix>.luadat"


Bear in mind the following:

- The suffix param gets stripped of all non-alphanumeric and non-underscore characters.

- The Lua object is serialized into binary. You cannot open it in a text file, or you'll just see gibberish.

- 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).

- Only use the commands without a suffix when testing, or if it's part of your map. Releasing a script with a non-suffixed file means that file may be overwritten by other scripts or maps.

Pages in category "Lua saving functions"

The following 4 pages are in this category, out of 4 total.