mods that hopefully work for a TechAge-based pack
This commit is contained in:
@@ -0,0 +1,85 @@
|
||||
-- ancient_bones/ancient_bones.lua
|
||||
|
||||
-- Load support for MT game translation.
|
||||
local S = core.get_translator("ancient_bones")
|
||||
|
||||
ancient_bones_object = {}
|
||||
|
||||
local bones_formspec =
|
||||
"size[8,9]" ..
|
||||
"list[current_name;main;0,0.3;8,4;]" ..
|
||||
"list[current_player;main;0,4.85;8,1;]" ..
|
||||
"list[current_player;main;0,6.08;8,3;8]" ..
|
||||
"listring[current_name;main]" ..
|
||||
"listring[current_player;main]" ..
|
||||
default.get_hotbar_bg(0,4.85)
|
||||
|
||||
local bones_def = {
|
||||
description = S("Ancient Bones"),
|
||||
tiles = {
|
||||
"bones_top.png^[transform2",
|
||||
"bones_bottom.png",
|
||||
"bones_side.png",
|
||||
"bones_side.png",
|
||||
"bones_rear.png",
|
||||
"bones_front.png"
|
||||
},
|
||||
paramtype2 = "facedir",
|
||||
groups = {dig_immediate = 2},
|
||||
sounds = default.node_sound_gravel_defaults(),
|
||||
|
||||
on_metadata_inventory_take = function(pos, listname, index, stack, player)
|
||||
local meta = core.get_meta(pos)
|
||||
if meta:get_inventory():is_empty("main") then
|
||||
local inv = player:get_inventory()
|
||||
if inv:room_for_item("main", {name = "bones:bones"}) then
|
||||
inv:add_item("main", {name = "bones:bones"})
|
||||
else
|
||||
core.add_item(pos, "bones:bones")
|
||||
end
|
||||
core.remove_node(pos)
|
||||
end
|
||||
end,
|
||||
|
||||
on_punch = function(pos, node, player)
|
||||
local inv = core.get_meta(pos):get_inventory()
|
||||
local player_inv = player:get_inventory()
|
||||
local has_space = true
|
||||
|
||||
for i = 1, inv:get_size("main") do
|
||||
local stk = inv:get_stack("main", i)
|
||||
if player_inv:room_for_item("main", stk) then
|
||||
inv:set_stack("main", i, nil)
|
||||
player_inv:add_item("main", stk)
|
||||
else
|
||||
has_space = false
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
-- remove bones if player emptied them
|
||||
if has_space then
|
||||
if player_inv:room_for_item("main", {name = "bones:bones"}) then
|
||||
player_inv:add_item("main", {name = "bones:bones"})
|
||||
else
|
||||
core.add_item(pos,"bones:bones")
|
||||
end
|
||||
core.remove_node(pos)
|
||||
end
|
||||
end,
|
||||
}
|
||||
|
||||
function ancient_bones_object.register_ancient_bones(d)
|
||||
local def = table.copy(d)
|
||||
def.on_construct = function(pos)
|
||||
local meta = core.get_meta(pos)
|
||||
meta:set_string("infotext", S("Ancient Bones"))
|
||||
meta:set_string("formspec", bones_formspec)
|
||||
local inv = meta:get_inventory()
|
||||
inv:set_size("main", 8*4)
|
||||
end
|
||||
|
||||
core.register_node("ancient_bones:ancient_bones", def)
|
||||
end
|
||||
|
||||
ancient_bones_object.register_ancient_bones(bones_def)
|
||||
Reference in New Issue
Block a user