diff options
author | orwell96 <mono96.mml@gmail.com> | 2016-11-03 11:27:17 +0100 |
---|---|---|
committer | orwell96 <mono96.mml@gmail.com> | 2016-11-03 11:27:17 +0100 |
commit | 245f07d32324183ae2f300435c07e4cb7520ebc2 (patch) | |
tree | fbc2ddb63b2c5f08de9a581f6fa17b0b3e8dfe80 /helpers.lua | |
parent | 31b579bc5c5e23eca78605ba082e7627334a468e (diff) | |
download | advtrains-245f07d32324183ae2f300435c07e4cb7520ebc2.tar.gz advtrains-245f07d32324183ae2f300435c07e4cb7520ebc2.tar.bz2 advtrains-245f07d32324183ae2f300435c07e4cb7520ebc2.zip |
Add a box wagon
Alongside with coding wagon inventories, and several bugfixes
Diffstat (limited to 'helpers.lua')
-rw-r--r-- | helpers.lua | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/helpers.lua b/helpers.lua index ef3752a..6a8175f 100644 --- a/helpers.lua +++ b/helpers.lua @@ -223,4 +223,27 @@ function advtrains.pos_median(pos1, pos2) end
function advtrains.abs_ceil(i)
return math.ceil(math.abs(i))*math.sign(i)
-end
\ No newline at end of file +end
+
+function advtrains.serialize_inventory(inv)
+ local ser={}
+ local liszts=inv:get_lists()
+ for lisztname, liszt in pairs(liszts) do
+ ser[lisztname]={}
+ for idx, item in ipairs(liszt) do
+ local istring=item:to_string()
+ if istring~="" then
+ ser[lisztname][idx]=istring
+ end
+ end
+ end
+ return minetest.serialize(ser)
+end
+function advtrains.deserialize_inventory(sers, inv)
+ local ser=minetest.deserialize(sers)
+ if ser then
+ inv:set_lists(ser)
+ return true
+ end
+ return false
+end
|