new storage system
parent
26706cc642
commit
91a371add1
|
@ -255,33 +255,6 @@ aliveai.team=function(ob,change_team)
|
|||
return
|
||||
end
|
||||
|
||||
aliveai.save=function(name,data)
|
||||
if type(name)~="string" or type(data)~="table" then return end
|
||||
local r=io.open(minetest.get_worldpath() .. "/aliveai", "r")
|
||||
local d
|
||||
if r then
|
||||
d=minetest.serialize(r:read("*a"))
|
||||
r:close()
|
||||
else
|
||||
d={}
|
||||
end
|
||||
d[name]=data
|
||||
d=minetest.serialize(d)
|
||||
local w=io.open(minetest.get_worldpath() .. "/aliveai", "w")
|
||||
w:write(d)
|
||||
w:close()
|
||||
end
|
||||
|
||||
aliveai.load=function(name)
|
||||
if type(name)~="string" then return end
|
||||
local r=io.open(minetest.get_worldpath() .. "/aliveai", "r")
|
||||
if not r then return nil end
|
||||
local d=minetest.deserialize(r:read("*a"))
|
||||
r:close()
|
||||
if not d or d=="" then return {} end
|
||||
return d[name]
|
||||
end
|
||||
|
||||
aliveai.add_mine=function(self,nodes,num,need)
|
||||
num=num or 1
|
||||
if not self.mine then
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
aliveai={
|
||||
version=26,
|
||||
version=26.1,
|
||||
--========================options==============================
|
||||
grant_invisiable=true,
|
||||
spawning=true, --spawning by self
|
||||
|
@ -40,9 +40,15 @@ aliveai={
|
|||
mesecons=minetest.get_modpath("mesecons")~=nil,
|
||||
loaddata={}, --functions
|
||||
savedata={}, --functions
|
||||
|
||||
team_player={},
|
||||
farming={},
|
||||
storage=minetest.get_mod_storage(),
|
||||
save=function(key,newdata)
|
||||
aliveai.storage:set_string(key,minetest.serialize(newdata))
|
||||
end,
|
||||
load=function(key)
|
||||
return minetest.deserialize(aliveai.storage:get_string(key)) or {}
|
||||
end,
|
||||
--========================options==============================
|
||||
-- new food databas, checks what players eats, then save it
|
||||
food= {["default:apple"]=2,["farming:bread"]=5,["mobs:meat"]=8,["mobs:meat_raw"]=3,["mobs:chicken_raw"]=2,["mobs:chicken_cooked"]=6,["mobs:chicken_egg_fried"]=2,["mobs:chicken_raw"]=2},
|
||||
|
|
Loading…
Reference in New Issue