tardis/init.lua

40 lines
1.0 KiB
Lua
Raw Normal View History

2017-03-22 18:25:17 -07:00
tardis = {}
tardis.count = 0
2017-04-04 18:58:09 -07:00
tardis.tardises = {}
2017-03-22 18:25:17 -07:00
2017-04-04 18:58:09 -07:00
local modname = minetest.get_current_modname()
2017-04-04 19:08:03 -07:00
local modpath = minetest.get_modpath (modname)
2017-04-04 18:58:09 -07:00
local worldpath = minetest.get_worldpath()
2017-03-22 18:25:17 -07:00
2017-04-04 19:08:03 -07:00
dofile (modpath .. "/remat.lua")
dofile (modpath .. "/demat.lua")
dofile (modpath .. "/functions.lua")
dofile (modpath .. "/nodes.lua")
2017-03-22 18:25:17 -07:00
2017-04-04 19:08:03 -07:00
local file = io.open (worldpath .. "/tardis.tardises", "r")
2017-03-22 18:25:17 -07:00
if file then
2017-07-26 22:12:38 -07:00
tardis.tardises = minetest.deserialize (file:read("*all"))
file:close()
2017-03-22 18:25:17 -07:00
end
2017-04-04 19:08:03 -07:00
minetest.register_chatcommand ("set_nav", {
2017-07-26 22:12:38 -07:00
description = "Sets the navigation coordinates for your TARDIS.",
func = function (name, param)
if (tardis.tardises [name] == nil) then
name.chat_send_player (name, "Must be owner!")
else
local owner = name
local player = minetest.get_player_by_name (name)
2017-04-04 18:58:09 -07:00
2017-07-26 22:12:38 -07:00
tardis.set_nav (player, owner)
2017-07-26 22:00:21 -07:00
end
2017-07-26 22:12:38 -07:00
end
2017-03-22 18:25:17 -07:00
})
2017-04-04 19:08:03 -07:00
minetest.register_on_shutdown( function()
2017-07-26 22:12:38 -07:00
local file = io.open (worldpath .. "/tardis.tardises", "w+")
file:write(minetest.serialize (tardis.tardises) )
file:close()
2017-04-04 19:08:03 -07:00
end )