was/init.lua

61 lines
1.8 KiB
Lua
Raw Normal View History

2019-01-03 13:57:48 -08:00
was={
functions={},
2019-01-04 02:32:59 -08:00
function_packed={},
2019-01-09 00:29:35 -08:00
info={},
2019-01-03 13:57:48 -08:00
privs={},
user={},
userdata={},
2019-01-09 00:29:35 -08:00
symbols={},
2019-01-04 10:46:50 -08:00
symbols_characters="#@=?!&{}%*+-/$<>|~^",
2019-01-03 13:57:48 -08:00
}
dofile(minetest.get_modpath("was") .. "/api.lua")
2019-01-04 02:32:59 -08:00
dofile(minetest.get_modpath("was") .. "/register.lua")
2019-01-08 13:56:48 -08:00
dofile(minetest.get_modpath("was") .. "/gui.lua")
2019-01-03 13:57:48 -08:00
2019-01-07 13:06:01 -08:00
--minetest.register_chatcommand("was", {
-- description = "World action script gui",
-- func = function(name, param)
-- was.gui(name)
-- return true
-- end,
--})
2019-01-03 13:57:48 -08:00
2019-01-08 13:56:48 -08:00
minetest.register_privilege("was", {
description = "Full access to functions",
give_to_singleplayer= false,
})
2019-01-04 11:47:35 -08:00
minetest.register_node("was:computer", {
description = "Computer",
tiles = {"default_steel_block.png"},
groups = {oddly_breakable_by_hand = 3,was_component=1},
after_place_node = function(pos, placer)
local meta = minetest.get_meta(pos)
meta:set_string("owner",placer:get_player_name() or "")
2019-01-07 06:16:06 -08:00
meta:get_inventory():set_size("storage", 50)
2019-01-04 11:47:35 -08:00
end,
on_rightclick = function(pos, node, player, itemstack, pointed_thing)
local meta=minetest.get_meta(pos)
local name=player:get_player_name() or ""
if meta:get_string("owner")==name or minetest.check_player_privs(name, {protection_bypass=true}) then
2019-01-04 15:30:48 -08:00
if meta:get_string("owner")=="" then
return
end
2019-01-04 11:47:35 -08:00
local text=minetest.deserialize(meta:get_string("text"))
was.gui(name,"",{text=text})
if was.user[name] and not was.user[name].nodepos then
was.user[name].nodepos=pos
end
end
end,
can_dig = function(pos, player)
local meta=minetest.get_meta(pos)
local name=player:get_player_name() or ""
2019-01-07 06:16:06 -08:00
if meta:get_inventory():is_empty("storage") and (meta:get_string("owner")==name or minetest.check_player_privs(name, {protection_bypass=true})) then
2019-01-04 11:47:35 -08:00
return true
end
end,
2019-01-08 13:56:48 -08:00
})