2019-03-23 13:15:13 -07:00
|
|
|
--[[
|
|
|
|
|
|
|
|
Signs Bot
|
|
|
|
=========
|
|
|
|
|
|
|
|
Copyright (C) 2019 Joachim Stolberg
|
|
|
|
|
|
|
|
LGPLv2.1+
|
|
|
|
See LICENSE.txt for more information
|
|
|
|
|
|
|
|
Signs Bot: Signs
|
|
|
|
|
|
|
|
]]--
|
|
|
|
|
|
|
|
-- for lazy programmers
|
|
|
|
local S = function(pos) if pos then return minetest.pos_to_string(pos) end end
|
|
|
|
local P = minetest.string_to_pos
|
|
|
|
local M = minetest.get_meta
|
|
|
|
|
|
|
|
-- Load support for intllib.
|
|
|
|
local MP = minetest.get_modpath("signs_bot")
|
|
|
|
local I,_ = dofile(MP.."/intllib.lua")
|
|
|
|
|
|
|
|
local function formspec(cmnd)
|
|
|
|
cmnd = minetest.formspec_escape(cmnd)
|
2019-04-06 10:13:37 -07:00
|
|
|
return "size[6,7]"..
|
2019-03-23 13:15:13 -07:00
|
|
|
default.gui_bg..
|
|
|
|
default.gui_bg_img..
|
|
|
|
default.gui_slots..
|
2019-04-06 10:13:37 -07:00
|
|
|
"label[0.2,0;"..cmnd.."]"..
|
|
|
|
"button_exit[4,6.3;2,1;exit;"..I("Exit").."]"
|
2019-03-23 13:15:13 -07:00
|
|
|
end
|
|
|
|
|
|
|
|
local function register_sign(def)
|
|
|
|
minetest.register_node("signs_bot:"..def.name, {
|
|
|
|
description = def.description,
|
|
|
|
inventory_image = def.image,
|
|
|
|
drawtype = "nodebox",
|
|
|
|
node_box = {
|
|
|
|
type = "fixed",
|
|
|
|
fixed = {
|
|
|
|
{ -1/16, -8/16, -1/16, 1/16, 4/16, 1/16},
|
|
|
|
{ -6/16, -5/16, -2/16, 6/16, 3/16, -1/16},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
paramtype2 = "facedir",
|
|
|
|
tiles = {
|
|
|
|
"default_wood.png",
|
|
|
|
"default_wood.png",
|
|
|
|
"default_wood.png",
|
|
|
|
"default_wood.png",
|
|
|
|
"default_wood.png",
|
|
|
|
"default_wood.png^"..def.image,
|
|
|
|
},
|
|
|
|
after_place_node = function(pos, placer)
|
|
|
|
local meta = minetest.get_meta(pos)
|
|
|
|
meta:set_string("signs_bot_cmnd", def.commands)
|
|
|
|
meta:set_string("formspec", formspec(def.commands))
|
|
|
|
end,
|
2019-03-26 14:40:04 -07:00
|
|
|
on_rotate = screwdriver.disallow,
|
2019-03-23 13:15:13 -07:00
|
|
|
paramtype = "light",
|
|
|
|
sunlight_propagates = true,
|
|
|
|
is_ground_content = false,
|
2019-03-31 11:35:58 -07:00
|
|
|
groups = {choppy = 2, oddly_breakable_by_hand = 2, flammable = 2, sign_bot_sign = 1},
|
2019-03-23 13:15:13 -07:00
|
|
|
sounds = default.node_sound_wood_defaults(),
|
|
|
|
})
|
|
|
|
end
|
|
|
|
|
2019-04-05 16:09:52 -07:00
|
|
|
signs_bot.register_sign = register_sign
|
|
|
|
|
|
|
|
|
|
|
|
|
2019-03-23 13:15:13 -07:00
|
|
|
register_sign({
|
|
|
|
name = "sign_right",
|
2019-03-24 11:03:12 -07:00
|
|
|
description = I('Sign "turn right"'),
|
2019-03-23 13:15:13 -07:00
|
|
|
commands = "turn_right",
|
|
|
|
image = "signs_bot_sign_right.png",
|
|
|
|
})
|
|
|
|
|
2019-03-29 12:20:51 -07:00
|
|
|
minetest.register_craft({
|
|
|
|
output = "signs_bot:sign_right 6",
|
|
|
|
recipe = {
|
|
|
|
{"group:wood", "default:stick", "group:wood"},
|
|
|
|
{"dye:yellow", "default:stick", "dye:black"},
|
|
|
|
{"", "", ""}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
2019-03-23 13:15:13 -07:00
|
|
|
register_sign({
|
|
|
|
name = "sign_left",
|
2019-03-24 11:03:12 -07:00
|
|
|
description = I('Sign "turn left"'),
|
2019-03-23 13:15:13 -07:00
|
|
|
commands = "turn_left",
|
|
|
|
image = "signs_bot_sign_left.png",
|
|
|
|
})
|
|
|
|
|
2019-03-29 12:20:51 -07:00
|
|
|
minetest.register_craft({
|
|
|
|
output = "signs_bot:sign_left 6",
|
|
|
|
recipe = {
|
|
|
|
{"group:wood", "default:stick", "group:wood"},
|
|
|
|
{"dye:yellow", "default:stick", ""},
|
|
|
|
{"dye:black", "", ""}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
2019-03-23 13:15:13 -07:00
|
|
|
register_sign({
|
|
|
|
name = "sign_take",
|
2019-03-24 11:03:12 -07:00
|
|
|
description = I('Sign "take item"'),
|
|
|
|
commands = "take_item 99\nturn_around",
|
2019-03-23 13:15:13 -07:00
|
|
|
image = "signs_bot_sign_take.png",
|
|
|
|
})
|
|
|
|
|
2019-03-29 12:20:51 -07:00
|
|
|
minetest.register_craft({
|
|
|
|
output = "signs_bot:sign_take 6",
|
|
|
|
recipe = {
|
|
|
|
{"group:wood", "default:stick", "group:wood"},
|
|
|
|
{"dye:yellow", "default:stick", ""},
|
|
|
|
{"", "dye:black", ""}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
2019-03-23 13:15:13 -07:00
|
|
|
register_sign({
|
|
|
|
name = "sign_add",
|
2019-03-24 11:03:12 -07:00
|
|
|
description = I('Sign "add item"'),
|
|
|
|
commands = "add_item 99\nturn_around",
|
2019-03-23 13:15:13 -07:00
|
|
|
image = "signs_bot_sign_add.png",
|
|
|
|
})
|
|
|
|
|
2019-03-29 12:20:51 -07:00
|
|
|
minetest.register_craft({
|
|
|
|
output = "signs_bot:sign_add 6",
|
|
|
|
recipe = {
|
|
|
|
{"group:wood", "default:stick", "group:wood"},
|
|
|
|
{"dye:yellow", "default:stick", ""},
|
|
|
|
{"", "", "dye:black"}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
2019-03-23 13:15:13 -07:00
|
|
|
register_sign({
|
|
|
|
name = "sign_stop",
|
2019-03-24 11:03:12 -07:00
|
|
|
description = I('Sign "stop"'),
|
2019-03-23 13:15:13 -07:00
|
|
|
commands = "stop",
|
|
|
|
image = "signs_bot_sign_stop.png",
|
|
|
|
})
|
2019-03-29 12:20:51 -07:00
|
|
|
|
|
|
|
minetest.register_craft({
|
|
|
|
output = "signs_bot:sign_stop 6",
|
|
|
|
recipe = {
|
|
|
|
{"group:wood", "default:stick", "group:wood"},
|
|
|
|
{"dye:black", "default:stick", "dye:yellow"},
|
|
|
|
{"", "", ""}
|
|
|
|
}
|
|
|
|
})
|