T-Engine

Welcome to the t-engine Bug Tracker

Please note that this is a tracker for ToME 3 issues. Please list any ToME 2 issues on the ToME wiki.

For information on the wiki format used for the tickets and comments, see the Dokuwiki Syntax Reference.

Thanks,
Eric (sdltome-at-gmail:dot:com)

Tasklist

FS#200 - Items are an unsavable data type

Attached to Project: T-Engine
Opened by Lord Bucket (LordBucket) - Monday, 22 February 2010, 02:11 GMT-7
Last edited by Nerdanel (nerdanel) - Friday, 05 March 2010, 14:31 GMT-7
Task Type Bug Report
Category T-Engine
Status New
Assigned To No-one
Operating System All
Severity Medium
Priority Normal
Reported Version alpha19
Due in Version Undecided
Due Date Undecided
Percent Complete 0%
Votes 0
Private No

Details

Items native to the engine are not recognized as a savable data type. For example, this code:

declare_globals {
"swag",
}
swag = {}
add_loadsave("swag", {})
local obj = create_object(tv, sv)
swag[1] = obj

will generate this error:

error: Unsavable type userdata in swag[1]
stack traceback:
1:  function `error' [C]
2:  function `f' at line 120 [file `/engine/load2.lua']
3:  function `__savefile_recurse_one' at line 82 [file `/engine/load2.lua']
4:  function `__savefile_recurse_table' at line 95 [file `/engine/load2.lua']
5:  function `__savefile_recurse_one' at line 80 [file `/engine/load2.lua']
6:  function `__savefile_recurse' at line 73 [file `/engine/load2.lua']
7:  function <115:file `/engine/load2.lua'> at line 123
This task depends upon

Comment by Nerdanel (nerdanel) - Friday, 05 March 2010, 13:35 GMT-7

I looked at the code and this is the offending function:

function add_loadsave(name, default, preserve_from_birth)
	assert(name, "No variable name to save")
--	assert(default, "No default value")

	-- if it is a table we must create many entries
--[[	if type(default) == "table" then
		for k, e in default do
			add_loadsave(name.."."..k, e)
		end
	else ]]--
		__loadsave_name[__loadsave_max] = { name = name, default = default preserve_from_birth=preserve_from_birth }
		__loadsave_max = __loadsave_max + 1
	--end
end

The option to store tables like your "swag" is commented out, presumably due to not working for some reason. Hmmmm...

Loading...