Hammer and sieve added
|
@ -0,0 +1,278 @@
|
|||
--[[
|
||||
|
||||
TechAge
|
||||
=======
|
||||
|
||||
Copyright (C) 2019 Joachim Stolberg
|
||||
|
||||
LGPLv2.1+
|
||||
See LICENSE.txt for more information
|
||||
|
||||
TA2/TA3/TA4 Chest
|
||||
|
||||
]]--
|
||||
|
||||
-- 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
|
||||
-- Techage Related Data
|
||||
local TRD = function(pos) return (minetest.registered_nodes[minetest.get_node(pos).name] or {}).techage end
|
||||
|
||||
-- Load support for intllib.
|
||||
local MP = minetest.get_modpath("techage")
|
||||
local I,_ = dofile(MP.."/intllib.lua")
|
||||
|
||||
local PlayerActions = {}
|
||||
local InventoryState = {}
|
||||
|
||||
|
||||
local function store_action(pos, player, action, stack)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local name = player and player:get_player_name() or ""
|
||||
local number = meta:get_string("number")
|
||||
local item = stack:get_name().." "..stack:get_count()
|
||||
PlayerActions[number] = {name, action, item}
|
||||
end
|
||||
|
||||
local function send_off_command(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local dest_num = meta:get_string("dest_num")
|
||||
local own_num = meta:get_string("number")
|
||||
local owner = meta:get_string("owner")
|
||||
techage.send_message(dest_num, owner, nil, "off", own_num)
|
||||
end
|
||||
|
||||
|
||||
local function send_command(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local dest_num = meta:get_string("dest_num")
|
||||
if dest_num ~= "" then
|
||||
local own_num = meta:get_string("number")
|
||||
local owner = meta:get_string("owner")
|
||||
techage.send_message(dest_num, owner, nil, "on", own_num)
|
||||
minetest.after(1, send_off_command, pos)
|
||||
end
|
||||
end
|
||||
|
||||
local function allow_metadata_inventory_put(pos, listname, index, stack, player)
|
||||
if minetest.is_protected(pos, player:get_player_name()) then
|
||||
return 0
|
||||
end
|
||||
store_action(pos, player, "put", stack)
|
||||
send_command(pos)
|
||||
return stack:get_count()
|
||||
end
|
||||
|
||||
local function allow_metadata_inventory_take(pos, listname, index, stack, player)
|
||||
if minetest.is_protected(pos, player:get_player_name()) then
|
||||
return 0
|
||||
end
|
||||
store_action(pos, player, "take", stack)
|
||||
send_command(pos)
|
||||
return stack:get_count()
|
||||
end
|
||||
|
||||
local function can_dig(pos, player)
|
||||
if minetest.is_protected(pos, player:get_player_name()) then
|
||||
return false
|
||||
end
|
||||
local inv = minetest.get_meta(pos):get_inventory()
|
||||
return inv:is_empty("main")
|
||||
end
|
||||
|
||||
local function after_dig_node(pos, oldnode, oldmetadata, digger)
|
||||
techage.remove_node(pos)
|
||||
end
|
||||
|
||||
local function formspec2()
|
||||
return "size[9,8]"..
|
||||
default.gui_bg..
|
||||
default.gui_bg_img..
|
||||
default.gui_slots..
|
||||
"list[context;main;0.5,0;8,4;]"..
|
||||
"list[current_player;main;0.5,4.3;8,4;]"..
|
||||
"listring[context;main]"..
|
||||
"listring[current_player;main]"
|
||||
end
|
||||
|
||||
minetest.register_node("techage:chest_ta2", {
|
||||
description = I("TA2 Protected Chest"),
|
||||
tiles = {
|
||||
-- up, down, right, left, back, front
|
||||
"techage_filling_ta2.png^techage_frame_ta2.png",
|
||||
"techage_filling_ta2.png^techage_frame_ta2.png",
|
||||
"techage_filling_ta2.png^techage_frame_ta2.png^techage_appl_chest_back_ta3.png",
|
||||
"techage_filling_ta2.png^techage_frame_ta2.png^techage_appl_chest_back_ta3.png",
|
||||
"techage_filling_ta2.png^techage_frame_ta2.png^techage_appl_chest_back_ta3.png",
|
||||
"techage_filling_ta2.png^techage_frame_ta2.png^techage_appl_chest_front_ta3.png",
|
||||
},
|
||||
|
||||
on_construct = function(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
inv:set_size('main', 32)
|
||||
end,
|
||||
|
||||
after_place_node = function(pos, placer)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local number = techage.add_node(pos, "techage:chest_ta2")
|
||||
meta:set_string("number", number)
|
||||
meta:set_string("owner", placer:get_player_name())
|
||||
meta:set_string("formspec", formspec2())
|
||||
meta:set_string("infotext", I("TA2 Protected Chest").." "..number)
|
||||
end,
|
||||
|
||||
can_dig = can_dig,
|
||||
after_dig_node = after_dig_node,
|
||||
allow_metadata_inventory_put = allow_metadata_inventory_put,
|
||||
allow_metadata_inventory_take = allow_metadata_inventory_take,
|
||||
|
||||
paramtype2 = "facedir",
|
||||
groups = {choppy=2, cracky=2, crumbly=2},
|
||||
is_ground_content = false,
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
})
|
||||
|
||||
local function formspec3()
|
||||
return "size[10,8]"..
|
||||
default.gui_bg..
|
||||
default.gui_bg_img..
|
||||
default.gui_slots..
|
||||
"list[context;main;0,0;10,4;]"..
|
||||
"list[current_player;main;1,4.3;8,4;]"..
|
||||
"listring[context;main]"..
|
||||
"listring[current_player;main]"
|
||||
end
|
||||
|
||||
minetest.register_node("techage:chest_ta3", {
|
||||
description = I("TA3 Protected Chest"),
|
||||
tiles = {
|
||||
-- up, down, right, left, back, front
|
||||
"techage_filling_ta3.png^techage_frame_ta3.png",
|
||||
"techage_filling_ta3.png^techage_frame_ta3.png",
|
||||
"techage_filling_ta3.png^techage_frame_ta3.png^techage_appl_chest_back_ta3.png",
|
||||
"techage_filling_ta3.png^techage_frame_ta3.png^techage_appl_chest_back_ta3.png",
|
||||
"techage_filling_ta3.png^techage_frame_ta3.png^techage_appl_chest_back_ta3.png",
|
||||
"techage_filling_ta3.png^techage_frame_ta3.png^techage_appl_chest_front_ta3.png",
|
||||
},
|
||||
|
||||
on_construct = function(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
inv:set_size('main', 40)
|
||||
end,
|
||||
|
||||
after_place_node = function(pos, placer)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local number = techage.add_node(pos, "techage:chest_ta3")
|
||||
meta:set_string("number", number)
|
||||
meta:set_string("owner", placer:get_player_name())
|
||||
meta:set_string("formspec", formspec3())
|
||||
meta:set_string("infotext", I("TA3 Protected Chest").." "..number)
|
||||
end,
|
||||
|
||||
can_dig = can_dig,
|
||||
after_dig_node = after_dig_node,
|
||||
allow_metadata_inventory_put = allow_metadata_inventory_put,
|
||||
allow_metadata_inventory_take = allow_metadata_inventory_take,
|
||||
|
||||
paramtype2 = "facedir",
|
||||
groups = {choppy=2, cracky=2, crumbly=2},
|
||||
is_ground_content = false,
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
})
|
||||
|
||||
local function formspec4()
|
||||
return "size[10,9]"..
|
||||
default.gui_bg..
|
||||
default.gui_bg_img..
|
||||
default.gui_slots..
|
||||
"list[context;main;0,0;10,5;]"..
|
||||
"list[current_player;main;1,5.3;8,4;]"..
|
||||
"listring[context;main]"..
|
||||
"listring[current_player;main]"
|
||||
end
|
||||
|
||||
minetest.register_node("techage:chest_ta4", {
|
||||
description = I("TA4 Protected Chest"),
|
||||
tiles = {
|
||||
-- up, down, right, left, back, front
|
||||
"techage_filling_ta4.png^techage_frame_ta4_top.png",
|
||||
"techage_filling_ta4.png^techage_frame_ta4.png",
|
||||
"techage_filling_ta4.png^techage_frame_ta4.png^techage_appl_chest_back_ta4.png",
|
||||
"techage_filling_ta4.png^techage_frame_ta4.png^techage_appl_chest_back_ta4.png",
|
||||
"techage_filling_ta4.png^techage_frame_ta4.png^techage_appl_chest_back_ta4.png",
|
||||
"techage_filling_ta4.png^techage_frame_ta4.png^techage_appl_chest_front_ta4.png",
|
||||
},
|
||||
|
||||
on_construct = function(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
inv:set_size('main', 50)
|
||||
end,
|
||||
|
||||
after_place_node = function(pos, placer)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local number = techage.add_node(pos, "techage:chest_ta4")
|
||||
meta:set_string("number", number)
|
||||
meta:set_string("owner", placer:get_player_name())
|
||||
meta:set_string("formspec", formspec4())
|
||||
meta:set_string("infotext", I("TA4 Protected Chest").." "..number)
|
||||
end,
|
||||
|
||||
can_dig = can_dig,
|
||||
after_dig_node = after_dig_node,
|
||||
allow_metadata_inventory_put = allow_metadata_inventory_put,
|
||||
allow_metadata_inventory_take = allow_metadata_inventory_take,
|
||||
|
||||
paramtype2 = "facedir",
|
||||
groups = {choppy=2, cracky=2, crumbly=2},
|
||||
is_ground_content = false,
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
type = "shapeless",
|
||||
output = "techage:chest_ta2",
|
||||
recipe = {"default:chest", "techage:tubeS", "default:steel_ingot"}
|
||||
})
|
||||
|
||||
techage.register_node("techage:chest_ta2", {"techage:chest_ta3", "techage:chest_ta4"}, {
|
||||
on_pull_item = function(pos, in_dir, num)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
return techage.get_items(inv, "main", num)
|
||||
end,
|
||||
on_push_item = function(pos, in_dir, stack)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
return techage.put_items(inv, "main", stack)
|
||||
end,
|
||||
on_unpull_item = function(pos, in_dir, stack)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
return techage.put_items(inv, "main", stack)
|
||||
end,
|
||||
|
||||
on_recv_message = function(pos, topic, payload)
|
||||
if topic == "state" then
|
||||
local meta = minetest.get_meta(pos)
|
||||
return techage.get_inv_state(meta, "main")
|
||||
elseif topic == "player_action" then
|
||||
local meta = minetest.get_meta(pos)
|
||||
local number = meta:get_string("number")
|
||||
return PlayerActions[number]
|
||||
elseif topic == "set_numbers" then
|
||||
if techage.check_numbers(payload) then
|
||||
local meta = minetest.get_meta(pos)
|
||||
meta:set_string("dest_num", payload)
|
||||
local number = meta:get_string("number")
|
||||
meta:set_string("infotext", I("TA2 Protected Chest").." "..number.." connected with "..payload)
|
||||
return true
|
||||
end
|
||||
else
|
||||
return "unsupported"
|
||||
end
|
||||
end,
|
||||
})
|
|
@ -21,7 +21,7 @@ local N = minetest.get_node
|
|||
local TRD = function(pos) return (minetest.registered_nodes[minetest.get_node(pos).name] or {}).techage end
|
||||
|
||||
-- Load support for intllib.
|
||||
local MP = minetest.get_modpath("tubelib2")
|
||||
local MP = minetest.get_modpath("techage")
|
||||
local I,_ = dofile(MP.."/intllib.lua")
|
||||
|
||||
local SRC_INV_SIZE = 8
|
||||
|
|
|
@ -0,0 +1,266 @@
|
|||
--[[
|
||||
|
||||
TechAge
|
||||
=======
|
||||
|
||||
Copyright (C) 2019 Joachim Stolberg
|
||||
|
||||
LGPLv2.1+
|
||||
See LICENSE.txt for more information
|
||||
|
||||
TA2/TA3/TA4 Gravel Sieve, sieving gravel to find ores
|
||||
|
||||
]]--
|
||||
|
||||
-- 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
|
||||
-- Techage Related Data
|
||||
local TRD = function(pos) return (minetest.registered_nodes[minetest.get_node(pos).name] or {}).techage end
|
||||
|
||||
-- Load support for intllib.
|
||||
local MP = minetest.get_modpath("techage")
|
||||
local I,_ = dofile(MP.."/intllib.lua")
|
||||
|
||||
local STANDBY_TICKS = 10
|
||||
local COUNTDOWN_TICKS = 10
|
||||
local CYCLE_TIME = 4
|
||||
|
||||
local function formspec(self, pos, mem)
|
||||
return "size[8,8]"..
|
||||
default.gui_bg..
|
||||
default.gui_bg_img..
|
||||
default.gui_slots..
|
||||
"list[context;src;0,0;3,3;]"..
|
||||
"item_image[0,0;1,1;default:gravel]"..
|
||||
"image[0,0;1,1;techage_form_mask.png]"..
|
||||
"image[3.5,1;1,1;techage_form_arrow.png]"..
|
||||
"image_button[3.5,2;1,1;".. self:get_state_button_image(mem) ..";state_button;]"..
|
||||
"list[context;dst;5,0;3,3;]"..
|
||||
"list[current_player;main;0,4;8,4;]"..
|
||||
"listring[context;dst]"..
|
||||
"listring[current_player;main]"..
|
||||
"listring[context;src]"..
|
||||
"listring[current_player;main]"..
|
||||
default.get_hotbar_bg(0, 4)
|
||||
end
|
||||
|
||||
local function allow_metadata_inventory_put(pos, listname, index, stack, player)
|
||||
if minetest.is_protected(pos, player:get_player_name()) then
|
||||
return 0
|
||||
end
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
if listname == "src" then
|
||||
return stack:get_count()
|
||||
elseif listname == "dst" then
|
||||
return 0
|
||||
end
|
||||
end
|
||||
|
||||
local function allow_metadata_inventory_move(pos, from_list, from_index, to_list, to_index, count, player)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
local stack = inv:get_stack(from_list, from_index)
|
||||
return allow_metadata_inventory_put(pos, to_list, to_index, stack, player)
|
||||
end
|
||||
|
||||
local function allow_metadata_inventory_take(pos, listname, index, stack, player)
|
||||
if minetest.is_protected(pos, player:get_player_name()) then
|
||||
return 0
|
||||
end
|
||||
return stack:get_count()
|
||||
end
|
||||
|
||||
|
||||
-- determine ore based on the calculated probability
|
||||
local function get_random_ore()
|
||||
for ore, probability in pairs(techage.ore_probability) do
|
||||
if math.random(probability) == 1 then
|
||||
local item = ItemStack(ore)
|
||||
return item
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function sieving(pos, trd, mem, inv)
|
||||
local gravel = ItemStack("default:gravel")
|
||||
|
||||
if not inv:contains_item("src", gravel) then
|
||||
trd.State:idle(pos, mem)
|
||||
return
|
||||
end
|
||||
|
||||
local dst = get_random_ore()
|
||||
if not dst then
|
||||
-- move gravel or sieved gravel to dst
|
||||
mem.gravel_cnt = (mem.gravel_cnt or 0) + 1
|
||||
if (mem.gravel_cnt % 2) == 0 then
|
||||
dst = gravel
|
||||
else
|
||||
dst = ItemStack("techage:sieved_gravel")
|
||||
end
|
||||
end
|
||||
if not inv:room_for_item("dst", dst) then
|
||||
--trd.State:blocked(pos, mem)
|
||||
trd.State:idle(pos, mem)
|
||||
return
|
||||
end
|
||||
|
||||
inv:add_item("dst", dst)
|
||||
inv:remove_item("src", gravel)
|
||||
trd.State:keep_running(pos, mem, COUNTDOWN_TICKS)
|
||||
end
|
||||
|
||||
local function keep_running(pos, elapsed)
|
||||
local mem = tubelib2.get_mem(pos)
|
||||
local trd = TRD(pos)
|
||||
local inv = M(pos):get_inventory()
|
||||
sieving(pos, trd, mem, inv)
|
||||
return trd.State:is_active(mem)
|
||||
end
|
||||
|
||||
local function on_receive_fields(pos, formname, fields, player)
|
||||
if minetest.is_protected(pos, player:get_player_name()) then
|
||||
return
|
||||
end
|
||||
local mem = tubelib2.get_mem(pos)
|
||||
TRD(pos).State:state_button_event(pos, mem, fields)
|
||||
end
|
||||
|
||||
local function can_dig(pos, player)
|
||||
if minetest.is_protected(pos, player:get_player_name()) then
|
||||
return false
|
||||
end
|
||||
local inv = M(pos):get_inventory()
|
||||
return inv:is_empty("dst") and inv:is_empty("src")
|
||||
end
|
||||
|
||||
|
||||
local tiles = {}
|
||||
-- '#' will be replaced by the stage number
|
||||
-- '{power}' will be replaced by the power PNG
|
||||
tiles.pas = {
|
||||
-- up, down, right, left, back, front
|
||||
"techage_appl_sieve_top.png^techage_frame_ta#_top.png",
|
||||
"techage_filling_ta#.png^techage_frame_ta#.png",
|
||||
"techage_filling_ta#.png^techage_frame_ta#.png^techage_appl_outp.png",
|
||||
"techage_filling_ta#.png^techage_frame_ta#.png^techage_appl_inp.png",
|
||||
"techage_filling_ta#.png^techage_appl_sieve.png^techage_frame_ta#.png",
|
||||
"techage_filling_ta#.png^techage_appl_sieve.png^techage_frame_ta#.png",
|
||||
}
|
||||
tiles.act = {
|
||||
-- up, down, right, left, back, front
|
||||
{
|
||||
image = "techage_appl_sieve4_top.png^techage_frame4_ta#_top.png",
|
||||
backface_culling = false,
|
||||
animation = {
|
||||
type = "vertical_frames",
|
||||
aspect_w = 32,
|
||||
aspect_h = 32,
|
||||
length = 2.0,
|
||||
},
|
||||
},
|
||||
"techage_filling_ta#.png^techage_frame_ta#.png",
|
||||
"techage_filling_ta#.png^techage_frame_ta#.png^techage_appl_outp.png",
|
||||
"techage_filling_ta#.png^techage_frame_ta#.png^techage_appl_inp.png",
|
||||
"techage_filling_ta#.png^techage_appl_sieve.png^techage_frame_ta#.png",
|
||||
"techage_filling_ta#.png^techage_appl_sieve.png^techage_frame_ta#.png",
|
||||
}
|
||||
tiles.def = {
|
||||
-- up, down, right, left, back, front
|
||||
"techage_appl_sieve_top.png^techage_frame_ta#_top.png",
|
||||
"techage_filling_ta#.png^techage_frame_ta#.png",
|
||||
"techage_filling_ta#.png^techage_frame_ta#.png^techage_appl_outp.png^techage_appl_defect.png",
|
||||
"techage_filling_ta#.png^techage_frame_ta#.png^techage_appl_inp.png^techage_appl_defect.png",
|
||||
"techage_filling_ta#.png^techage_appl_sieve.png^techage_frame_ta#.png^techage_appl_defect.png",
|
||||
"techage_filling_ta#.png^techage_appl_sieve.png^techage_frame_ta#.png^techage_appl_defect.png",
|
||||
}
|
||||
|
||||
local tubing = {
|
||||
on_pull_item = function(pos, in_dir, num)
|
||||
local meta = minetest.get_meta(pos)
|
||||
if meta:get_int("pull_dir") == in_dir then
|
||||
local inv = M(pos):get_inventory()
|
||||
return techage.get_items(inv, "dst", num)
|
||||
end
|
||||
end,
|
||||
on_push_item = function(pos, in_dir, stack)
|
||||
local meta = minetest.get_meta(pos)
|
||||
if meta:get_int("push_dir") == in_dir or in_dir == 5 then
|
||||
local inv = M(pos):get_inventory()
|
||||
return techage.put_items(inv, "src", stack)
|
||||
end
|
||||
end,
|
||||
on_unpull_item = function(pos, in_dir, stack)
|
||||
local meta = minetest.get_meta(pos)
|
||||
if meta:get_int("pull_dir") == in_dir then
|
||||
local inv = M(pos):get_inventory()
|
||||
return techage.put_items(inv, "dst", stack)
|
||||
end
|
||||
end,
|
||||
on_recv_message = function(pos, topic, payload)
|
||||
local resp = TRD(pos).State:on_receive_message(pos, topic, payload)
|
||||
if resp then
|
||||
return resp
|
||||
else
|
||||
return "unsupported"
|
||||
end
|
||||
end,
|
||||
on_node_load = function(pos)
|
||||
TRD(pos).State:on_node_load(pos)
|
||||
end,
|
||||
on_node_repair = function(pos)
|
||||
return TRD(pos).State:on_node_repair(pos)
|
||||
end,
|
||||
}
|
||||
|
||||
local node_name_ta2, node_name_ta3, node_name_ta4 =
|
||||
techage.register_consumer("gravelsieve", I("Gravel Sieve"), tiles, {
|
||||
drawtype = "nodebox",
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
{-8/16, -8/16, -8/16, 8/16, 8/16, -6/16},
|
||||
{-8/16, -8/16, 6/16, 8/16, 8/16, 8/16},
|
||||
{-8/16, -8/16, -8/16, -6/16, 8/16, 8/16},
|
||||
{ 6/16, -8/16, -8/16, 8/16, 8/16, 8/16},
|
||||
{-6/16, -8/16, -6/16, 6/16, 4/16, 6/16},
|
||||
},
|
||||
},
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = {-8/16, -8/16, -8/16, 8/16, 8/16, 8/16},
|
||||
},
|
||||
cycle_time = CYCLE_TIME,
|
||||
standby_ticks = STANDBY_TICKS,
|
||||
has_item_meter = true,
|
||||
aging_factor = 10,
|
||||
formspec = formspec,
|
||||
tubing = tubing,
|
||||
after_place_node = function(pos, placer)
|
||||
local inv = M(pos):get_inventory()
|
||||
inv:set_size('src', 9)
|
||||
inv:set_size('dst', 9)
|
||||
end,
|
||||
can_dig = can_dig,
|
||||
node_timer = keep_running,
|
||||
on_receive_fields = on_receive_fields,
|
||||
allow_metadata_inventory_put = allow_metadata_inventory_put,
|
||||
allow_metadata_inventory_move = allow_metadata_inventory_move,
|
||||
allow_metadata_inventory_take = allow_metadata_inventory_take,
|
||||
groups = {choppy=2, cracky=2, crumbly=2},
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
num_items = {0,1,2,4},
|
||||
power_consumption = {0,2,3,4},
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = node_name_ta2,
|
||||
recipe = {
|
||||
{"group:wood", "default:tin_ingot", "group:wood"},
|
||||
{"tubelib:tubeS", "default:steel_ingot", "tubelib:tubeS"},
|
||||
{"group:wood", "default:tin_ingot", "group:wood"},
|
||||
},
|
||||
})
|
|
@ -20,7 +20,7 @@ local M = minetest.get_meta
|
|||
local TRD = function(pos) return (minetest.registered_nodes[minetest.get_node(pos).name] or {}).techage end
|
||||
|
||||
-- Load support for intllib.
|
||||
local MP = minetest.get_modpath("tubelib2")
|
||||
local MP = minetest.get_modpath("techage")
|
||||
local I,_ = dofile(MP.."/intllib.lua")
|
||||
|
||||
local STANDBY_TICKS = 10
|
||||
|
@ -141,8 +141,8 @@ tiles.pas = {
|
|||
"techage_filling_ta#.png^techage_frame_ta#.png",
|
||||
"techage_filling_ta#.png^techage_frame_ta#.png^techage_appl_outp.png",
|
||||
"techage_filling_ta#.png^techage_frame_ta#.png^techage_appl_inp.png",
|
||||
"techage_filling_ta#.png^{power}^techage_frame_ta#.png",
|
||||
"techage_filling_ta#.png^{power}^techage_frame_ta#.png",
|
||||
"techage_filling_ta#.png^techage_appl_grinder2.png^techage_frame_ta#.png",
|
||||
"techage_filling_ta#.png^techage_appl_grinder2.png^techage_frame_ta#.png",
|
||||
}
|
||||
tiles.act = {
|
||||
-- up, down, right, left, back, front
|
||||
|
@ -159,8 +159,8 @@ tiles.act = {
|
|||
"techage_filling_ta#.png^techage_frame_ta#.png",
|
||||
"techage_filling_ta#.png^techage_frame_ta#.png^techage_appl_outp.png",
|
||||
"techage_filling_ta#.png^techage_frame_ta#.png^techage_appl_inp.png",
|
||||
"techage_filling_ta#.png^{power}^techage_frame_ta#.png",
|
||||
"techage_filling_ta#.png^{power}^techage_frame_ta#.png",
|
||||
"techage_filling_ta#.png^techage_frame_ta#.png",
|
||||
"techage_filling_ta#.png^techage_frame_ta#.png",
|
||||
}
|
||||
tiles.def = {
|
||||
-- up, down, right, left, back, front
|
||||
|
@ -168,8 +168,8 @@ tiles.def = {
|
|||
"techage_filling_ta#.png^techage_frame_ta#.png",
|
||||
"techage_filling_ta#.png^techage_frame_ta#.png^techage_appl_outp.png^techage_appl_defect.png",
|
||||
"techage_filling_ta#.png^techage_frame_ta#.png^techage_appl_inp.png^techage_appl_defect.png",
|
||||
"techage_filling_ta#.png^{power}^techage_frame_ta#.png^techage_appl_defect.png",
|
||||
"techage_filling_ta#.png^{power}^techage_frame_ta#.png^techage_appl_defect.png",
|
||||
"techage_filling_ta#.png^techage_frame_ta#.png^techage_appl_defect.png",
|
||||
"techage_filling_ta#.png^techage_frame_ta#.png^techage_appl_defect.png",
|
||||
}
|
||||
|
||||
local tubing = {
|
||||
|
@ -182,7 +182,7 @@ local tubing = {
|
|||
end,
|
||||
on_push_item = function(pos, in_dir, stack)
|
||||
local meta = minetest.get_meta(pos)
|
||||
if meta:get_int("push_dir") == in_dir then
|
||||
if meta:get_int("push_dir") == in_dir or in_dir == 5 then
|
||||
local inv = M(pos):get_inventory()
|
||||
return techage.put_items(inv, "src", stack)
|
||||
end
|
||||
|
@ -212,6 +212,21 @@ local tubing = {
|
|||
|
||||
local node_name_ta2, node_name_ta3, node_name_ta4 =
|
||||
techage.register_consumer("grinder", I("Grinder"), tiles, {
|
||||
drawtype = "nodebox",
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
{-8/16, -8/16, -8/16, 8/16, 8/16, -6/16},
|
||||
{-8/16, -8/16, 6/16, 8/16, 8/16, 8/16},
|
||||
{-8/16, -8/16, -8/16, -6/16, 8/16, 8/16},
|
||||
{ 6/16, -8/16, -8/16, 8/16, 8/16, 8/16},
|
||||
{-6/16, -8/16, -6/16, 6/16, 6/16, 6/16},
|
||||
},
|
||||
},
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = {-8/16, -8/16, -8/16, 8/16, 8/16, 8/16},
|
||||
},
|
||||
cycle_time = CYCLE_TIME,
|
||||
standby_ticks = STANDBY_TICKS,
|
||||
has_item_meter = true,
|
||||
|
|
|
@ -30,7 +30,7 @@ local M = minetest.get_meta
|
|||
local TRD = function(pos) return (minetest.registered_nodes[minetest.get_node(pos).name] or {}).techage end
|
||||
local TRDN = function(node) return (minetest.registered_nodes[node.name] or {}).techage end
|
||||
-- Load support for intllib.
|
||||
local MP = minetest.get_modpath("tubelib2")
|
||||
local MP = minetest.get_modpath("techage")
|
||||
local I,_ = dofile(MP.."/intllib.lua")
|
||||
|
||||
local STANDBY_TICKS = 10
|
||||
|
@ -64,6 +64,7 @@ end
|
|||
local function on_rightclick(pos, node, clicker)
|
||||
local mem = tubelib2.get_mem(pos)
|
||||
if not minetest.is_protected(pos, clicker:get_player_name()) then
|
||||
print("on_rightclick", TRD(pos).State:is_active(mem), mem.techage_state)
|
||||
if TRD(pos).State:is_active(mem) then
|
||||
TRD(pos).State:stop(pos, mem)
|
||||
else
|
||||
|
@ -77,190 +78,101 @@ local function after_dig_node(pos, oldnode, oldmetadata, digger)
|
|||
TRDN(oldnode).State:after_dig_node(pos, oldnode, oldmetadata, digger)
|
||||
end
|
||||
|
||||
local function register_pusher(stage, num_items)
|
||||
local State = techage.NodeStates:new({
|
||||
node_name_passive= "techage:ta"..stage.."_pusher",
|
||||
node_name_active = "techage:ta"..stage.."_pusher_active",
|
||||
node_name_defect = "techage:ta"..stage.."_pusher_defect",
|
||||
infotext_name = "TA"..stage..I(" Pusher"),
|
||||
local tiles = {}
|
||||
-- '#' will be replaced by the stage number
|
||||
-- '{power}' will be replaced by the power PNG
|
||||
tiles.pas = {
|
||||
"techage_filling_ta#.png^techage_frame_ta#_top.png^techage_appl_arrow.png",
|
||||
"techage_filling_ta#.png^techage_frame_ta#.png",
|
||||
"techage_filling_ta#.png^techage_frame_ta#.png^techage_appl_outp.png",
|
||||
"techage_filling_ta#.png^techage_frame_ta#.png^techage_appl_inp.png",
|
||||
"techage_appl_pusher.png^[transformR180]^techage_frame_ta#.png",
|
||||
"techage_appl_pusher.png^techage_frame_ta#.png",
|
||||
}
|
||||
tiles.act = {
|
||||
-- up, down, right, left, back, front
|
||||
"techage_filling_ta#.png^techage_frame_ta#_top.png^techage_appl_arrow.png",
|
||||
"techage_filling_ta#.png^techage_frame_ta#.png",
|
||||
"techage_filling_ta#.png^techage_frame_ta#.png^techage_appl_outp.png",
|
||||
"techage_filling_ta#.png^techage_frame_ta#.png^techage_appl_inp.png",
|
||||
{
|
||||
image = "techage_appl_pusher14.png^[transformR180]^techage_frame14_ta#.png",
|
||||
backface_culling = false,
|
||||
animation = {
|
||||
type = "vertical_frames",
|
||||
aspect_w = 32,
|
||||
aspect_h = 32,
|
||||
length = 2.0,
|
||||
},
|
||||
},
|
||||
{
|
||||
image = "techage_appl_pusher14.png^techage_frame14_ta#.png",
|
||||
backface_culling = false,
|
||||
animation = {
|
||||
type = "vertical_frames",
|
||||
aspect_w = 32,
|
||||
aspect_h = 32,
|
||||
length = 2.0,
|
||||
},
|
||||
},
|
||||
}
|
||||
tiles.def = {
|
||||
-- up, down, right, left, back, front
|
||||
"techage_filling_ta#.png^techage_frame_ta#_top.png^techage_appl_arrow.png",
|
||||
"techage_filling_ta#.png^techage_frame_ta#.png",
|
||||
"techage_filling_ta#.png^techage_frame_ta#.png^techage_appl_outp.png^techage_appl_defect.png",
|
||||
"techage_filling_ta#.png^techage_frame_ta#.png^techage_appl_inp.png^techage_appl_defect.png",
|
||||
"techage_appl_pusher.png^[transformR180]^techage_frame_ta#.png^techage_appl_defect.png",
|
||||
"techage_appl_pusher.png^techage_frame_ta#.png^techage_appl_defect.png",
|
||||
}
|
||||
|
||||
local tubing = {
|
||||
is_pusher = true, -- is a pulling/pushing node
|
||||
|
||||
on_recv_message = function(pos, topic, payload)
|
||||
local resp = TRD(pos).State:on_receive_message(pos, topic, payload)
|
||||
if resp then
|
||||
return resp
|
||||
else
|
||||
return "unsupported"
|
||||
end
|
||||
end,
|
||||
on_node_load = function(pos)
|
||||
TRD(pos).State:on_node_load(pos)
|
||||
end,
|
||||
on_node_repair = function(pos)
|
||||
return TRD(pos).State:on_node_repair(pos)
|
||||
end,
|
||||
}
|
||||
|
||||
local node_name_ta2, node_name_ta3, node_name_ta4 =
|
||||
techage.register_consumer("pusher", I("Pusher"), tiles, {
|
||||
cycle_time = CYCLE_TIME,
|
||||
standby_ticks = STANDBY_TICKS,
|
||||
has_item_meter = true,
|
||||
aging_factor = 10,
|
||||
})
|
||||
|
||||
minetest.register_node("techage:ta"..stage.."_pusher", {
|
||||
description = "TA"..stage..I(" Pusher"),
|
||||
tiles = {
|
||||
-- up, down, right, left, back, front
|
||||
"techage_filling_ta"..stage..".png^techage_frame_ta"..stage.."_top.png^techage_appl_arrow.png",
|
||||
"techage_filling_ta"..stage..".png^techage_frame_ta"..stage..".png",
|
||||
"techage_filling_ta"..stage..".png^techage_frame_ta"..stage..".png^techage_appl_outp.png",
|
||||
"techage_filling_ta"..stage..".png^techage_frame_ta"..stage..".png^techage_appl_inp.png",
|
||||
"techage_appl_pusher.png^[transformR180]^techage_frame_ta"..stage..".png",
|
||||
"techage_appl_pusher.png^techage_frame_ta"..stage..".png",
|
||||
},
|
||||
|
||||
techage = {
|
||||
State = State,
|
||||
num_items = num_items,
|
||||
},
|
||||
|
||||
tubing = tubing,
|
||||
after_place_node = function(pos, placer)
|
||||
local mem = tubelib2.init_mem(pos)
|
||||
local mem = tubelib2.get_mem(pos)
|
||||
local meta = M(pos)
|
||||
local node = minetest.get_node(pos)
|
||||
meta:set_int("pull_dir", techage.side_to_outdir("L", node.param2))
|
||||
meta:set_int("push_dir", techage.side_to_outdir("R", node.param2))
|
||||
local number = "-"
|
||||
if stage > 2 then
|
||||
number = techage.add_node(pos, "techage:ta"..stage.."_pusher")
|
||||
end
|
||||
TRD(pos).State:node_init(pos, mem, number)
|
||||
end,
|
||||
|
||||
on_rightclick = on_rightclick,
|
||||
after_dig_node = after_dig_node,
|
||||
on_timer = keep_running,
|
||||
node_timer = keep_running,
|
||||
on_rotate = screwdriver.disallow,
|
||||
|
||||
drop = "",
|
||||
paramtype2 = "facedir",
|
||||
|
||||
groups = {choppy=2, cracky=2, crumbly=2},
|
||||
is_ground_content = false,
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
num_items = {0,2,6,18},
|
||||
})
|
||||
|
||||
minetest.register_node("techage:ta"..stage.."_pusher_active", {
|
||||
description = "TA"..stage..I(" Pusher"),
|
||||
tiles = {
|
||||
-- up, down, right, left, back, front
|
||||
"techage_filling_ta"..stage..".png^techage_frame_ta"..stage.."_top.png^techage_appl_arrow.png",
|
||||
"techage_filling_ta"..stage..".png^techage_frame_ta"..stage..".png",
|
||||
"techage_filling_ta"..stage..".png^techage_frame_ta"..stage..".png^techage_appl_outp.png",
|
||||
"techage_filling_ta"..stage..".png^techage_frame_ta"..stage..".png^techage_appl_inp.png",
|
||||
{
|
||||
image = "techage_appl_pusher14.png^[transformR180]^techage_frame14_ta"..stage..".png",
|
||||
backface_culling = false,
|
||||
animation = {
|
||||
type = "vertical_frames",
|
||||
aspect_w = 32,
|
||||
aspect_h = 32,
|
||||
length = 2.0,
|
||||
},
|
||||
},
|
||||
{
|
||||
image = "techage_appl_pusher14.png^techage_frame14_ta"..stage..".png",
|
||||
backface_culling = false,
|
||||
animation = {
|
||||
type = "vertical_frames",
|
||||
aspect_w = 32,
|
||||
aspect_h = 32,
|
||||
length = 2.0,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
techage = {
|
||||
State = State,
|
||||
num_items = num_items,
|
||||
},
|
||||
|
||||
on_rightclick = on_rightclick,
|
||||
after_dig_node = after_dig_node,
|
||||
on_timer = keep_running,
|
||||
on_rotate = screwdriver.disallow,
|
||||
on_timer = keep_running,
|
||||
|
||||
paramtype2 = "facedir",
|
||||
diggable = false,
|
||||
groups = {crumbly=0, not_in_creative_inventory=1},
|
||||
is_ground_content = false,
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
})
|
||||
|
||||
minetest.register_node("techage:ta"..stage.."_pusher_defect", {
|
||||
description = "TA"..stage.." Pusher",
|
||||
tiles = {
|
||||
-- up, down, right, left, back, front
|
||||
"techage_filling_ta"..stage..".png^techage_frame_ta"..stage.."_top.png^techage_appl_arrow.png",
|
||||
"techage_filling_ta"..stage..".png^techage_frame_ta"..stage..".png",
|
||||
"techage_filling_ta"..stage..".png^techage_frame_ta"..stage..".png^techage_appl_outp.png^techage_appl_defect.png",
|
||||
"techage_filling_ta"..stage..".png^techage_frame_ta"..stage..".png^techage_appl_inp.png^techage_appl_defect.png",
|
||||
"techage_appl_pusher.png^[transformR180]^techage_frame_ta"..stage..".png^techage_appl_defect.png",
|
||||
"techage_appl_pusher.png^techage_frame_ta"..stage..".png^techage_appl_defect.png",
|
||||
},
|
||||
|
||||
techage = {
|
||||
State = State,
|
||||
},
|
||||
|
||||
after_place_node = function(pos, placer)
|
||||
local mem = tubelib2.get_init(pos)
|
||||
local number = "-"
|
||||
if stage > 2 then
|
||||
number = techage.add_node(pos, "techage:ta"..stage.."_pusher")
|
||||
end
|
||||
TRD(pos).State:node_init(pos, mem, number)
|
||||
TRD(pos).State:defect(pos, mem)
|
||||
end,
|
||||
|
||||
after_dig_node = function(pos)
|
||||
techage.remove_node(pos)
|
||||
end,
|
||||
|
||||
on_rotate = screwdriver.disallow,
|
||||
|
||||
paramtype2 = "facedir",
|
||||
groups = {choppy=2, cracky=2, crumbly=2, not_in_creative_inventory=1},
|
||||
is_ground_content = false,
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
})
|
||||
|
||||
if stage == 2 then
|
||||
techage.register_node("techage:ta"..stage.."_pusher",
|
||||
{"techage:ta"..stage.."_pusher_active", "techage:ta"..stage.."_pusher_defect"}, {
|
||||
is_pusher = true, -- is a pulling/pushing node
|
||||
|
||||
on_recv_message = function(pos, topic, payload)
|
||||
return "unsupported"
|
||||
end,
|
||||
on_node_load = function(pos)
|
||||
TRD(pos).State:on_node_load(pos)
|
||||
end,
|
||||
on_node_repair = function(pos)
|
||||
return TRD(pos).State:on_node_repair(pos)
|
||||
end,
|
||||
})
|
||||
else
|
||||
techage.register_node("techage:ta"..stage.."_pusher",
|
||||
{"techage:ta"..stage.."_pusher_active", "techage:ta"..stage.."_pusher_defect"}, {
|
||||
is_pusher = true, -- is a pulling/pushing node
|
||||
|
||||
on_recv_message = function(pos, topic, payload)
|
||||
local resp = TRD(pos).State:on_receive_message(pos, topic, payload)
|
||||
if resp then
|
||||
return resp
|
||||
else
|
||||
return "unsupported"
|
||||
end
|
||||
end,
|
||||
on_node_load = function(pos)
|
||||
TRD(pos).State:on_node_load(pos)
|
||||
end,
|
||||
on_node_repair = function(pos)
|
||||
return TRD(pos).State:on_node_repair(pos)
|
||||
end,
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
register_pusher(2, 2)
|
||||
register_pusher(3, 6)
|
||||
register_pusher(4, 18)
|
||||
|
||||
minetest.register_craft({
|
||||
output = "techage:ta2_pusher 2",
|
||||
output = node_name_ta2.." 2",
|
||||
recipe = {
|
||||
{"group:wood", "wool:dark_green", "group:wood"},
|
||||
{"tubelib:tubeS", "default:mese_crystal", "tubelib:tubeS"},
|
||||
|
|
|
@ -29,7 +29,7 @@ local TRDN = function(node) return (minetest.registered_nodes[node.name] or {}).
|
|||
local consumer = techage.consumer
|
||||
|
||||
local function valid_power_dir(pos, power_dir, in_dir)
|
||||
return power_dir == in_dir or power_dir == tubelib2.Turn180Deg[in_dir]
|
||||
return true
|
||||
end
|
||||
|
||||
local function start_node(pos, mem, state)
|
||||
|
@ -72,27 +72,24 @@ function techage.register_consumer(base_name, inv_name, tiles, tNode)
|
|||
local name_inv = "TA"..stage.." "..inv_name
|
||||
names[#names+1] = name_pas
|
||||
|
||||
local power_network = techage.Axle
|
||||
local on_recv_message = tNode.tubing.on_recv_message
|
||||
local power_png = 'techage_axle_clutch.png'
|
||||
|
||||
if stage > 2 then
|
||||
power_network = techage.ElectricCable
|
||||
on_recv_message = function(pos, topic, payload)
|
||||
return "unsupported"
|
||||
end
|
||||
power_png = 'techage_appl_hole_electric.png'
|
||||
end
|
||||
|
||||
-- No power needed?
|
||||
if not tNode.power_consumption then
|
||||
start_node = nil
|
||||
stop_node = nil
|
||||
turn_on_clbk = nil
|
||||
valid_power_dir = nil
|
||||
power_network = nil
|
||||
tNode.power_consumption = {0,0,0,0} -- needed later
|
||||
else
|
||||
local power_network
|
||||
local power_png = 'techage_axle_clutch.png'
|
||||
local power_used = tNode.power_consumption ~= nil
|
||||
-- power needed?
|
||||
if power_used then
|
||||
if stage > 2 then
|
||||
power_network = techage.ElectricCable
|
||||
power_png = 'techage_appl_hole_electric.png'
|
||||
else
|
||||
power_network = techage.Axle
|
||||
end
|
||||
power_network:add_secondary_node_names({name_pas, name_act})
|
||||
end
|
||||
|
||||
|
@ -106,18 +103,18 @@ function techage.register_consumer(base_name, inv_name, tiles, tNode)
|
|||
has_item_meter = tNode.has_item_meter,
|
||||
aging_factor = tNode.aging_factor,
|
||||
formspec_func = tNode.formspec,
|
||||
start_node = start_node,
|
||||
stop_node = stop_node,
|
||||
start_node = power_used and start_node or nil,
|
||||
stop_node = power_used and stop_node or nil,
|
||||
})
|
||||
local tTechage = {
|
||||
State = tState,
|
||||
num_items = tNode.num_items[stage],
|
||||
turn_on = turn_on_clbk,
|
||||
turn_on = power_used and turn_on_clbk or nil,
|
||||
read_power_consumption = consumer.read_power_consumption,
|
||||
power_network = power_network,
|
||||
power_network = power_used and power_network or nil,
|
||||
power_side = "F",
|
||||
valid_power_dir = valid_power_dir,
|
||||
power_consumption = tNode.power_consumption[stage],
|
||||
valid_power_dir = power_used and valid_power_dir or nil,
|
||||
power_consumption = power_used and tNode.power_consumption[stage] or {0,0,0,0},
|
||||
}
|
||||
|
||||
tNode.groups.not_in_creative_inventory = 0
|
||||
|
@ -126,6 +123,9 @@ function techage.register_consumer(base_name, inv_name, tiles, tNode)
|
|||
description = name_inv,
|
||||
tiles = prepare_tiles(tiles.pas, stage, power_png),
|
||||
techage = tTechage,
|
||||
drawtype = tNode.drawtype,
|
||||
node_box = tNode.node_box,
|
||||
selection_box = tNode.selection_box,
|
||||
|
||||
after_place_node = function(pos, placer, itemstack, pointed_thing)
|
||||
local mem
|
||||
|
@ -164,6 +164,7 @@ function techage.register_consumer(base_name, inv_name, tiles, tNode)
|
|||
on_rotate = screwdriver.disallow,
|
||||
on_timer = tNode.node_timer,
|
||||
on_receive_fields = tNode.on_receive_fields,
|
||||
on_rightclick = tNode.on_rightclick,
|
||||
allow_metadata_inventory_put = tNode.allow_metadata_inventory_put,
|
||||
allow_metadata_inventory_move = tNode.allow_metadata_inventory_move,
|
||||
allow_metadata_inventory_take = tNode.allow_metadata_inventory_take,
|
||||
|
@ -184,11 +185,15 @@ function techage.register_consumer(base_name, inv_name, tiles, tNode)
|
|||
description = name_inv,
|
||||
tiles = prepare_tiles(tiles.act, stage, power_png),
|
||||
techage = tTechage,
|
||||
drawtype = tNode.drawtype,
|
||||
node_box = tNode.node_box,
|
||||
selection_box = tNode.selection_box,
|
||||
|
||||
after_tube_update = consumer.after_tube_update,
|
||||
on_rotate = screwdriver.disallow,
|
||||
on_timer = tNode.node_timer,
|
||||
on_receive_fields = tNode.on_receive_fields,
|
||||
on_rightclick = tNode.on_rightclick,
|
||||
allow_metadata_inventory_put = tNode.allow_metadata_inventory_put,
|
||||
allow_metadata_inventory_move = tNode.allow_metadata_inventory_move,
|
||||
allow_metadata_inventory_take = tNode.allow_metadata_inventory_take,
|
||||
|
@ -207,6 +212,9 @@ function techage.register_consumer(base_name, inv_name, tiles, tNode)
|
|||
description = name_inv,
|
||||
tiles = prepare_tiles(tiles.def, stage, power_png),
|
||||
techage = tTechage,
|
||||
drawtype = tNode.drawtype,
|
||||
node_box = tNode.node_box,
|
||||
selection_box = tNode.selection_box,
|
||||
|
||||
after_place_node = function(pos, placer, itemstack, pointed_thing)
|
||||
local mem = consumer.after_place_node(pos, placer)
|
||||
|
@ -227,6 +235,7 @@ function techage.register_consumer(base_name, inv_name, tiles, tNode)
|
|||
after_tube_update = consumer.after_tube_update,
|
||||
on_rotate = screwdriver.disallow,
|
||||
on_receive_fields = tNode.on_receive_fields,
|
||||
on_rightclick = tNode.on_rightclick,
|
||||
allow_metadata_inventory_put = tNode.allow_metadata_inventory_put,
|
||||
allow_metadata_inventory_move = tNode.allow_metadata_inventory_move,
|
||||
allow_metadata_inventory_take = tNode.allow_metadata_inventory_take,
|
||||
|
|
|
@ -18,9 +18,11 @@ local P = minetest.string_to_pos
|
|||
local M = minetest.get_meta
|
||||
|
||||
-- Load support for intllib.
|
||||
local MP = minetest.get_modpath("tubelib2")
|
||||
local MP = minetest.get_modpath("techage")
|
||||
local I,_ = dofile(MP.."/intllib.lua")
|
||||
|
||||
-- used by other tools: dug_node[player_name] = pos
|
||||
techage.dug_node = {}
|
||||
|
||||
-- Overridden method of tubelib2!
|
||||
function techage.get_primary_node_param2(pos, dir)
|
||||
|
@ -102,11 +104,14 @@ minetest.register_node("techage:trowel", {
|
|||
})
|
||||
|
||||
minetest.register_on_dignode(function(pos, oldnode, digger)
|
||||
if not digger then return end
|
||||
-- If hidden nodes are arround, the removed one was probably
|
||||
-- a hidden node, too.
|
||||
if other_hidden_nodes(pos, "techage_hidden_nodename") then
|
||||
-- test both hidden networks
|
||||
techage.ElectricCable:after_dig_node(pos, oldnode, digger)
|
||||
techage.BiogasPipe:after_dig_node(pos, oldnode, digger)
|
||||
else
|
||||
techage.dug_node[digger:get_player_name()] = pos
|
||||
end
|
||||
end)
|
||||
|
|
|
@ -4,7 +4,7 @@ local P = minetest.string_to_pos
|
|||
local M = minetest.get_meta
|
||||
|
||||
-- Load support for intllib.
|
||||
local MP = minetest.get_modpath("tubelib2")
|
||||
local MP = minetest.get_modpath("techage")
|
||||
local I,_ = dofile(MP.."/intllib.lua")
|
||||
|
||||
local POWER_CONSUMPTION = 2
|
||||
|
|
|
@ -18,7 +18,7 @@ local P = minetest.string_to_pos
|
|||
local M = minetest.get_meta
|
||||
|
||||
-- Load support for intllib.
|
||||
local MP = minetest.get_modpath("tubelib2")
|
||||
local MP = minetest.get_modpath("techage")
|
||||
local I,_ = dofile(MP.."/intllib.lua")
|
||||
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ local P = minetest.string_to_pos
|
|||
local M = minetest.get_meta
|
||||
|
||||
-- Load support for intllib.
|
||||
local MP = minetest.get_modpath("tubelib2")
|
||||
local MP = minetest.get_modpath("techage")
|
||||
local I,_ = dofile(MP.."/intllib.lua")
|
||||
|
||||
local STANDBY_TICKS = 4
|
||||
|
|
|
@ -18,7 +18,7 @@ local P = minetest.string_to_pos
|
|||
local M = minetest.get_meta
|
||||
|
||||
-- Load support for intllib.
|
||||
local MP = minetest.get_modpath("tubelib2")
|
||||
local MP = minetest.get_modpath("techage")
|
||||
local I,_ = dofile(MP.."/intllib.lua")
|
||||
|
||||
|
||||
|
|
9
init.lua
|
@ -6,6 +6,7 @@ techage = {
|
|||
techage.max_num_forceload_blocks = tonumber(minetest.setting_get("techage_max_num_forceload_blocks")) or 12
|
||||
techage.basalt_stone_enabled = minetest.setting_get("techage_basalt_stone_enabled") == "true"
|
||||
techage.machine_aging_value = tonumber(minetest.setting_get("techage_machine_aging_value")) or 100
|
||||
techage.ore_rarity = tonumber(minetest.setting_get("techage_ore_rarity")) or 1
|
||||
|
||||
|
||||
local MP = minetest.get_modpath("techage")
|
||||
|
@ -21,6 +22,11 @@ dofile(MP.."/basis/tubes.lua") -- tubelib replacement
|
|||
dofile(MP.."/basis/command.lua") -- tubelib replacement
|
||||
dofile(MP.."/basis/consumer.lua") -- consumer base model
|
||||
|
||||
-- Iron Age
|
||||
dofile(MP.."/iron_age/gravelsieve.lua")
|
||||
dofile(MP.."/iron_age/hammer.lua")
|
||||
|
||||
|
||||
-- Steam Engine
|
||||
dofile(MP.."/steam_engine/drive_axle.lua")
|
||||
dofile(MP.."/steam_engine/steam_pipe.lua")
|
||||
|
@ -37,10 +43,13 @@ dofile(MP.."/electric/test.lua")
|
|||
dofile(MP.."/electric/generator.lua")
|
||||
dofile(MP.."/electric/consumer.lua")
|
||||
|
||||
-- Basic Machines
|
||||
dofile(MP.."/basic_machines/pusher.lua")
|
||||
dofile(MP.."/basic_machines/legacy_nodes.lua")
|
||||
dofile(MP.."/basic_machines/grinder.lua")
|
||||
dofile(MP.."/basic_machines/distributor.lua")
|
||||
dofile(MP.."/basic_machines/gravelsieve.lua")
|
||||
dofile(MP.."/basic_machines/chest.lua")
|
||||
|
||||
|
||||
--dofile(MP.."/fermenter/biogas_pipe.lua")
|
||||
|
|
|
@ -0,0 +1,45 @@
|
|||
|
||||
-- Fallback functions for when `intllib` is not installed.
|
||||
-- Code released under Unlicense <http://unlicense.org>.
|
||||
|
||||
-- Get the latest version of this file at:
|
||||
-- https://raw.githubusercontent.com/minetest-mods/intllib/master/lib/intllib.lua
|
||||
|
||||
local function format(str, ...)
|
||||
local args = { ... }
|
||||
local function repl(escape, open, num, close)
|
||||
if escape == "" then
|
||||
local replacement = tostring(args[tonumber(num)])
|
||||
if open == "" then
|
||||
replacement = replacement..close
|
||||
end
|
||||
return replacement
|
||||
else
|
||||
return "@"..open..num..close
|
||||
end
|
||||
end
|
||||
return (str:gsub("(@?)@(%(?)(%d+)(%)?)", repl))
|
||||
end
|
||||
|
||||
local gettext, ngettext
|
||||
if minetest.get_modpath("intllib") then
|
||||
if intllib.make_gettext_pair then
|
||||
-- New method using gettext.
|
||||
gettext, ngettext = intllib.make_gettext_pair()
|
||||
else
|
||||
-- Old method using text files.
|
||||
gettext = intllib.Getter()
|
||||
end
|
||||
end
|
||||
|
||||
-- Fill in missing functions.
|
||||
|
||||
gettext = gettext or function(msgid, ...)
|
||||
return format(msgid, ...)
|
||||
end
|
||||
|
||||
ngettext = ngettext or function(msgid, msgid_plural, n, ...)
|
||||
return format(n==1 and msgid or msgid_plural, ...)
|
||||
end
|
||||
|
||||
return gettext, ngettext
|
|
@ -0,0 +1,376 @@
|
|||
--[[
|
||||
|
||||
TechAge
|
||||
=======
|
||||
|
||||
Copyright (C) 2019 Joachim Stolberg
|
||||
|
||||
LGPLv2.1+
|
||||
See LICENSE.txt for more information
|
||||
|
||||
TA2/TA3/TA4 Gravel Sieve, sieving gravel to find ores
|
||||
|
||||
]]--
|
||||
|
||||
-- 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
|
||||
-- Techage Related Data
|
||||
local TRD = function(pos) return (minetest.registered_nodes[minetest.get_node(pos).name] or {}).techage end
|
||||
|
||||
-- Load support for intllib.
|
||||
local MP = minetest.get_modpath("techage")
|
||||
local I,_ = dofile(MP.."/intllib.lua")
|
||||
|
||||
-- Increase the probability over the natural occurrence
|
||||
local PROBABILITY_FACTOR = 3
|
||||
|
||||
-- Ore probability table (1/n)
|
||||
techage.ore_probability = {
|
||||
}
|
||||
|
||||
-- collect all registered ores and calculate the probability
|
||||
local function add_ores()
|
||||
for _,item in pairs(minetest.registered_ores) do
|
||||
if minetest.registered_nodes[item.ore] then
|
||||
local drop = minetest.registered_nodes[item.ore].drop
|
||||
if type(drop) == "string"
|
||||
and drop ~= item.ore
|
||||
and drop ~= ""
|
||||
and item.ore_type == "scatter"
|
||||
and item.wherein == "default:stone"
|
||||
and item.clust_scarcity ~= nil and item.clust_scarcity > 0
|
||||
and item.clust_num_ores ~= nil and item.clust_num_ores > 0
|
||||
and item.y_max ~= nil and item.y_min ~= nil then
|
||||
local probability = (techage.ore_rarity / PROBABILITY_FACTOR) * item.clust_scarcity /
|
||||
(item.clust_num_ores * ((item.y_max - item.y_min) / 65535))
|
||||
if techage.ore_probability[drop] == nil then
|
||||
techage.ore_probability[drop] = probability
|
||||
else
|
||||
-- harmonic sum
|
||||
techage.ore_probability[drop] = 1.0 / ((1.0 / techage.ore_probability[drop]) +
|
||||
(1.0 / probability))
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
local overall_probability = 0.0
|
||||
for name,probability in pairs(techage.ore_probability) do
|
||||
minetest.log("info", string.format("[techage] %-32s %u", name, probability))
|
||||
overall_probability = overall_probability + 1.0/probability
|
||||
end
|
||||
minetest.log("info", string.format("[techage] Overall probability %g", overall_probability))
|
||||
end
|
||||
|
||||
minetest.after(1, add_ores)
|
||||
|
||||
local sieve_formspec =
|
||||
"size[8,8]"..
|
||||
default.gui_bg..
|
||||
default.gui_bg_img..
|
||||
default.gui_slots..
|
||||
"list[context;src;1,1.5;1,1;]"..
|
||||
"image[3,1.5;1,1;techage_form_arrow.png]"..
|
||||
"list[context;dst;4,0;4,4;]"..
|
||||
"list[current_player;main;0,4.2;8,4;]"..
|
||||
"listring[context;dst]"..
|
||||
"listring[current_player;main]"..
|
||||
"listring[context;src]"..
|
||||
"listring[current_player;main]"
|
||||
|
||||
|
||||
local function allow_metadata_inventory_put(pos, listname, index, stack, player)
|
||||
if minetest.is_protected(pos, player:get_player_name()) then
|
||||
return 0
|
||||
end
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
if listname == "src" then
|
||||
return stack:get_count()
|
||||
elseif listname == "dst" then
|
||||
return 0
|
||||
end
|
||||
end
|
||||
|
||||
local function allow_metadata_inventory_move(pos, from_list, from_index, to_list, to_index, count, player)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
local stack = inv:get_stack(from_list, from_index)
|
||||
return allow_metadata_inventory_put(pos, to_list, to_index, stack, player)
|
||||
end
|
||||
|
||||
local function allow_metadata_inventory_take(pos, listname, index, stack, player)
|
||||
if minetest.is_protected(pos, player:get_player_name()) then
|
||||
return 0
|
||||
end
|
||||
return stack:get_count()
|
||||
end
|
||||
|
||||
-- handle the sieve animation
|
||||
local function swap_node(pos, meta, start)
|
||||
local node = minetest.get_node(pos)
|
||||
local idx = meta:get_int("idx")
|
||||
if start then
|
||||
if idx == 3 then
|
||||
idx = 0
|
||||
end
|
||||
else
|
||||
idx = (idx + 1) % 4
|
||||
end
|
||||
meta:set_int("idx", idx)
|
||||
node.name = meta:get_string("node_name")..idx
|
||||
minetest.swap_node(pos, node)
|
||||
return idx == 3
|
||||
end
|
||||
|
||||
-- place ores to dst according to the calculated probability
|
||||
local function random_ore(inv, src)
|
||||
local num
|
||||
for ore, probability in pairs(techage.ore_probability) do
|
||||
if math.random(probability) == 1 then
|
||||
local item = ItemStack(ore)
|
||||
if inv:room_for_item("dst", item) then
|
||||
inv:add_item("dst", item)
|
||||
return true -- ore placed
|
||||
end
|
||||
end
|
||||
end
|
||||
return false -- gravel has to be moved
|
||||
end
|
||||
|
||||
|
||||
local function add_gravel_to_dst(meta, inv)
|
||||
-- maintain a counter for gravel kind selection
|
||||
local gravel_cnt = meta:get_int("gravel_cnt") + 1
|
||||
meta:set_int("gravel_cnt", gravel_cnt)
|
||||
|
||||
if (gravel_cnt % 2) == 0 then -- gravel or sieved gravel?
|
||||
inv:add_item("dst", ItemStack("default:gravel")) -- add to dest
|
||||
else
|
||||
inv:add_item("dst", ItemStack("techage:sieved_gravel")) -- add to dest
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
-- move gravel and ores to dst
|
||||
local function move_src2dst(meta, pos, inv, src, dst)
|
||||
if inv:room_for_item("dst", dst) and inv:contains_item("src", src) then
|
||||
local res = swap_node(pos, meta, false)
|
||||
if res then -- time to move one item?
|
||||
if src:get_name() == "default:gravel" then -- will we find ore?
|
||||
if not random_ore(inv, src) then -- no ore found?
|
||||
add_gravel_to_dst(meta, inv)
|
||||
end
|
||||
else
|
||||
inv:add_item("dst", ItemStack("techage:sieved_gravel")) -- add to dest
|
||||
end
|
||||
inv:remove_item("src", src)
|
||||
end
|
||||
return true -- process finished
|
||||
end
|
||||
return false -- process still running
|
||||
end
|
||||
|
||||
-- timer callback, alternatively called by on_punch
|
||||
local function sieve_node_timer(pos, elapsed)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
local gravel = ItemStack("default:gravel")
|
||||
local gravel_sieved = ItemStack("techage:sieved_gravel")
|
||||
|
||||
if move_src2dst(meta, pos, inv, gravel) then
|
||||
return true
|
||||
elseif move_src2dst(meta, pos, inv, gravel_sieved) then
|
||||
return true
|
||||
else
|
||||
minetest.get_node_timer(pos):stop()
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
for idx = 0,4 do
|
||||
local nodebox_data = {
|
||||
{ -8/16, -8/16, -8/16, 8/16, 4/16, -6/16 },
|
||||
{ -8/16, -8/16, 6/16, 8/16, 4/16, 8/16 },
|
||||
{ -8/16, -8/16, -8/16, -6/16, 4/16, 8/16 },
|
||||
{ 6/16, -8/16, -8/16, 8/16, 4/16, 8/16 },
|
||||
{ -6/16, -2/16, -6/16, 6/16, 8/16, 6/16 },
|
||||
}
|
||||
nodebox_data[5][5] = (8 - 2*idx) / 16
|
||||
|
||||
local node_name
|
||||
local description
|
||||
local tiles_data
|
||||
local tube_info
|
||||
local not_in_creative_inventory
|
||||
node_name = "techage:sieve"
|
||||
description = "Gravel Sieve"
|
||||
tiles_data = {
|
||||
-- up, down, right, left, back, front
|
||||
"techage_handsieve_gravel.png",
|
||||
"techage_handsieve_gravel.png",
|
||||
"techage_handsieve_sieve.png",
|
||||
"techage_handsieve_sieve.png",
|
||||
"techage_handsieve_sieve.png",
|
||||
"techage_handsieve_sieve.png",
|
||||
}
|
||||
|
||||
if idx == 3 then
|
||||
tiles_data[1] = "techage_handsieve_top.png"
|
||||
not_in_creative_inventory = 0
|
||||
else
|
||||
not_in_creative_inventory = 1
|
||||
end
|
||||
|
||||
|
||||
minetest.register_node(node_name..idx, {
|
||||
description = description,
|
||||
tiles = tiles_data,
|
||||
drawtype = "nodebox",
|
||||
drop = node_name,
|
||||
|
||||
tube = tube_info, -- NEW
|
||||
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = nodebox_data,
|
||||
},
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = { -8/16, -8/16, -8/16, 8/16, 4/16, 8/16 },
|
||||
},
|
||||
|
||||
on_timer = sieve_node_timer,
|
||||
|
||||
on_construct = function(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
meta:set_int("idx", idx) -- for the 4 sieve phases
|
||||
meta:set_int("gravel_cnt", 0) -- counter to switch between gravel and sieved gravel
|
||||
meta:set_string("node_name", node_name)
|
||||
meta:set_string("formspec", sieve_formspec)
|
||||
local inv = meta:get_inventory()
|
||||
inv:set_size('src', 1)
|
||||
inv:set_size('dst', 16)
|
||||
end,
|
||||
|
||||
after_place_node = function(pos, placer)
|
||||
local meta = minetest.get_meta(pos)
|
||||
meta:set_string("infotext", I("TA1 Gravel Sieve"))
|
||||
end,
|
||||
|
||||
on_metadata_inventory_move = function(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
swap_node(pos, meta, true)
|
||||
end,
|
||||
|
||||
on_metadata_inventory_take = function(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
if inv:is_empty("src") then
|
||||
-- sieve should be empty
|
||||
meta:set_int("idx", 2)
|
||||
swap_node(pos, meta, false)
|
||||
meta:set_int("gravel_cnt", 0)
|
||||
end
|
||||
end,
|
||||
|
||||
on_metadata_inventory_put = function(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
swap_node(pos, meta, true)
|
||||
end,
|
||||
|
||||
on_punch = function(pos, node, puncher, pointed_thing)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
if inv:is_empty("dst") and inv:is_empty("src") then
|
||||
minetest.node_punch(pos, node, puncher, pointed_thing)
|
||||
else
|
||||
sieve_node_timer(pos, 0)
|
||||
end
|
||||
end,
|
||||
|
||||
on_dig = function(pos, node, puncher, pointed_thing)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
if inv:is_empty("dst") and inv:is_empty("src") then
|
||||
minetest.node_dig(pos, node, puncher, pointed_thing)
|
||||
end
|
||||
end,
|
||||
|
||||
allow_metadata_inventory_put = allow_metadata_inventory_put,
|
||||
allow_metadata_inventory_move = allow_metadata_inventory_move,
|
||||
allow_metadata_inventory_take = allow_metadata_inventory_take,
|
||||
|
||||
paramtype = "light",
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
paramtype2 = "facedir",
|
||||
sunlight_propagates = true,
|
||||
is_ground_content = false,
|
||||
groups = {choppy=2, cracky=1, not_in_creative_inventory=not_in_creative_inventory},
|
||||
drop = node_name.."3",
|
||||
})
|
||||
end
|
||||
|
||||
minetest.register_node("techage:sieved_gravel", {
|
||||
description = I("Sieved Gravel"),
|
||||
tiles = {"default_gravel.png"},
|
||||
groups = {crumbly=2, falling_node=1, not_in_creative_inventory=1},
|
||||
sounds = default.node_sound_gravel_defaults(),
|
||||
})
|
||||
|
||||
minetest.register_node("techage:compressed_gravel", {
|
||||
description = I("Compressed Gravel"),
|
||||
tiles = {"techage_compressed_gravel.png"},
|
||||
groups = {cracky=2, crumbly = 2, cracky = 2},
|
||||
sounds = default.node_sound_gravel_defaults(),
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "techage:sieve",
|
||||
recipe = {
|
||||
{"group:wood", "", "group:wood"},
|
||||
{"group:wood", "default:steel_ingot", "group:wood"},
|
||||
{"group:wood", "", "group:wood"},
|
||||
},
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "techage:auto_sieve",
|
||||
type = "shapeless",
|
||||
recipe = {
|
||||
"techage:sieve", "default:mese_crystal", "default:mese_crystal",
|
||||
},
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "techage:compressed_gravel",
|
||||
recipe = {
|
||||
{"techage:sieved_gravel", "techage:sieved_gravel"},
|
||||
{"techage:sieved_gravel", "techage:sieved_gravel"},
|
||||
},
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
type = "cooking",
|
||||
output = "default:cobble",
|
||||
recipe = "techage:compressed_gravel",
|
||||
cooktime = 10,
|
||||
})
|
||||
|
||||
minetest.register_alias("techage:sieve", "techage:sieve3")
|
||||
minetest.register_alias("techage:auto_sieve", "techage:auto_sieve3")
|
||||
|
||||
-- adaption to Circular Saw
|
||||
--if minetest.get_modpath("moreblocks") then
|
||||
|
||||
-- stairsplus:register_all("techage", "compressed_gravel", "techage:compressed_gravel", {
|
||||
-- description= I("Compressed Gravel"),
|
||||
-- groups={cracky=2, crumbly=2, choppy=2, not_in_creative_inventory=1},
|
||||
-- tiles = {"techage_compressed_gravel.png"},
|
||||
-- sounds = default.node_sound_stone_defaults(),
|
||||
-- })
|
||||
--end
|
||||
|
||||
|
|
@ -0,0 +1,141 @@
|
|||
--[[
|
||||
|
||||
TechAge
|
||||
=======
|
||||
|
||||
Copyright (C) 2019 Joachim Stolberg
|
||||
|
||||
LGPLv2.1+
|
||||
See LICENSE.txt for more information
|
||||
|
||||
Hammer to convert stone into gravel
|
||||
|
||||
]]--
|
||||
|
||||
-- Load support for intllib.
|
||||
local MP = minetest.get_modpath("techage")
|
||||
local I,_ = dofile(MP.."/intllib.lua")
|
||||
|
||||
local function handler(player_name, node, itemstack, digparams)
|
||||
local pos = techage.dug_node[player_name]
|
||||
if not pos then return end
|
||||
|
||||
if minetest.is_protected(pos, player_name) then
|
||||
minetest.record_protection_violation(pos, player_name)
|
||||
return
|
||||
end
|
||||
|
||||
if minetest.get_item_group(node.name, "stone") > 0 then
|
||||
node.name = "default:gravel"
|
||||
minetest.swap_node(pos, node)
|
||||
end
|
||||
end
|
||||
|
||||
minetest.register_tool("techage:hammer_bronze", {
|
||||
description = I("Bronze Hammer (converts stone into gravel)"),
|
||||
inventory_image = "techage_tool_hammer_bronze.png",
|
||||
tool_capabilities = {
|
||||
full_punch_interval = 1.0,
|
||||
max_drop_level=1,
|
||||
groupcaps={
|
||||
cracky = {times={[1]=5.00, [2]=2.0, [3]=1.0}, uses=30, maxlevel=2},
|
||||
},
|
||||
damage_groups = {fleshy=4},
|
||||
},
|
||||
sound = {breaks = "default_tool_breaks"},
|
||||
after_use = function(itemstack, user, node, digparams)
|
||||
minetest.after(0.05, handler, user:get_player_name(), node)
|
||||
itemstack:add_wear(digparams.wear)
|
||||
return itemstack
|
||||
end,
|
||||
})
|
||||
|
||||
minetest.register_tool("techage:hammer_steel", {
|
||||
description = I("Steel Hammer (converts stone into gravel)"),
|
||||
inventory_image = "techage_tool_hammer_steel.png",
|
||||
tool_capabilities = {
|
||||
full_punch_interval = 1.0,
|
||||
max_drop_level=1,
|
||||
groupcaps={
|
||||
cracky = {times={[1]=4.00, [2]=1.60, [3]=0.80}, uses=30, maxlevel=2},
|
||||
},
|
||||
damage_groups = {fleshy=4},
|
||||
},
|
||||
sound = {breaks = "default_tool_breaks"},
|
||||
after_use = function(itemstack, user, node, digparams)
|
||||
minetest.after(0.05, handler, user:get_player_name(), node)
|
||||
itemstack:add_wear(digparams.wear)
|
||||
return itemstack
|
||||
end,
|
||||
})
|
||||
|
||||
minetest.register_tool("techage:hammer_mese", {
|
||||
description = I("Mese Hammer (converts stone into gravel)"),
|
||||
inventory_image = "techage_tool_hammer_mese.png",
|
||||
tool_capabilities = {
|
||||
full_punch_interval = 0.9,
|
||||
max_drop_level=3,
|
||||
groupcaps={
|
||||
cracky = {times={[1]=2.4, [2]=1.2, [3]=0.60}, uses=40, maxlevel=3},
|
||||
},
|
||||
damage_groups = {fleshy=5},
|
||||
},
|
||||
sound = {breaks = "default_tool_breaks"},
|
||||
after_use = function(itemstack, user, node, digparams)
|
||||
minetest.after(0.05, handler, user:get_player_name(), node)
|
||||
itemstack:add_wear(digparams.wear)
|
||||
return itemstack
|
||||
end,
|
||||
})
|
||||
|
||||
minetest.register_tool("techage:hammer_diamond", {
|
||||
description = I("Diamond Hammer (converts stone into gravel)"),
|
||||
inventory_image = "techage_tool_hammer_diamond.png",
|
||||
tool_capabilities = {
|
||||
full_punch_interval = 0.9,
|
||||
max_drop_level=3,
|
||||
groupcaps={
|
||||
cracky = {times={[1]=2.0, [2]=1.0, [3]=0.50}, uses=40, maxlevel=3},
|
||||
},
|
||||
damage_groups = {fleshy=5},
|
||||
},
|
||||
sound = {breaks = "default_tool_breaks"},
|
||||
after_use = function(itemstack, user, node, digparams)
|
||||
minetest.after(0.05, handler, user:get_player_name(), node)
|
||||
itemstack:add_wear(digparams.wear)
|
||||
return itemstack
|
||||
end,
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "techage:hammer_bronze",
|
||||
recipe = {
|
||||
{"default:bronze_ingot", "group:stick", "default:bronze_ingot"},
|
||||
{"default:bronze_ingot", "group:stick", "default:bronze_ingot"},
|
||||
{"", "group:stick", ""},
|
||||
}
|
||||
})
|
||||
minetest.register_craft({
|
||||
output = "techage:hammer_steel",
|
||||
recipe = {
|
||||
{"default:steel_ingot", "group:stick", "default:steel_ingot"},
|
||||
{"default:steel_ingot", "group:stick", "default:steel_ingot"},
|
||||
{"", "group:stick", ""},
|
||||
}
|
||||
})
|
||||
minetest.register_craft({
|
||||
output = "techage:hammer_mese",
|
||||
recipe = {
|
||||
{"default:mese_crystal", "group:stick", "default:mese_crystal"},
|
||||
{"default:mese_crystal", "group:stick", "default:mese_crystal"},
|
||||
{"", "group:stick", ""},
|
||||
}
|
||||
})
|
||||
minetest.register_craft({
|
||||
output = "techage:hammer_diamond",
|
||||
recipe = {
|
||||
{"default:diamond", "group:stick", "default:diamond"},
|
||||
{"default:diamond", "group:stick", "default:diamond"},
|
||||
{"", "group:stick", ""},
|
||||
}
|
||||
})
|
4
mod.conf
|
@ -1 +1,3 @@
|
|||
name = techage
|
||||
name = techage
|
||||
depends = default, tubelib2, basic_materials
|
||||
description = Hello World!
|
|
@ -4,7 +4,7 @@ local P = minetest.string_to_pos
|
|||
local M = minetest.get_meta
|
||||
|
||||
-- Load support for intllib.
|
||||
local MP = minetest.get_modpath("tubelib2")
|
||||
local MP = minetest.get_modpath("techage")
|
||||
local I,_ = dofile(MP.."/intllib.lua")
|
||||
|
||||
local STANDBY_TICKS = 4
|
||||
|
|
|
@ -18,7 +18,7 @@ local P = minetest.string_to_pos
|
|||
local M = minetest.get_meta
|
||||
|
||||
-- Load support for intllib.
|
||||
local MP = minetest.get_modpath("tubelib2")
|
||||
local MP = minetest.get_modpath("techage")
|
||||
local I,_ = dofile(MP.."/intllib.lua")
|
||||
|
||||
local CYCLE_TIME = 4
|
||||
|
|
|
@ -18,7 +18,7 @@ local P = minetest.string_to_pos
|
|||
local M = minetest.get_meta
|
||||
|
||||
-- Load support for intllib.
|
||||
local MP = minetest.get_modpath("tubelib2")
|
||||
local MP = minetest.get_modpath("techage")
|
||||
local I,_ = dofile(MP.."/intllib.lua")
|
||||
|
||||
local POWER_CONSUMPTION = 8
|
||||
|
|
|
@ -18,7 +18,7 @@ local P = minetest.string_to_pos
|
|||
local M = minetest.get_meta
|
||||
|
||||
-- Load support for intllib.
|
||||
local MP = minetest.get_modpath("tubelib2")
|
||||
local MP = minetest.get_modpath("techage")
|
||||
local I,_ = dofile(MP.."/intllib.lua")
|
||||
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ local M = minetest.get_meta
|
|||
local TRD = function(pos) return (minetest.registered_nodes[minetest.get_node(pos).name] or {}).techage end
|
||||
|
||||
-- Load support for intllib.
|
||||
local MP = minetest.get_modpath("tubelib2")
|
||||
local MP = minetest.get_modpath("techage")
|
||||
local I,_ = dofile(MP.."/intllib.lua")
|
||||
|
||||
local CYCLE_TIME = 2
|
||||
|
|
|
@ -20,7 +20,7 @@ local M = minetest.get_meta
|
|||
local TRD = function(pos) return (minetest.registered_nodes[minetest.get_node(pos).name] or {}).techage end
|
||||
|
||||
-- Load support for intllib.
|
||||
local MP = minetest.get_modpath("tubelib2")
|
||||
local MP = minetest.get_modpath("techage")
|
||||
local I,_ = dofile(MP.."/intllib.lua")
|
||||
|
||||
local STANDBY_TICKS = 4
|
||||
|
|
|
@ -18,7 +18,7 @@ local P = minetest.string_to_pos
|
|||
local M = minetest.get_meta
|
||||
|
||||
-- Load support for intllib.
|
||||
local MP = minetest.get_modpath("tubelib2")
|
||||
local MP = minetest.get_modpath("techage")
|
||||
local I,_ = dofile(MP.."/intllib.lua")
|
||||
|
||||
local POWER_CONSUMPTION = 1
|
||||
|
|
|
@ -18,7 +18,7 @@ local P = minetest.string_to_pos
|
|||
local M = minetest.get_meta
|
||||
|
||||
-- Load support for intllib.
|
||||
local MP = minetest.get_modpath("tubelib2")
|
||||
local MP = minetest.get_modpath("techage")
|
||||
local I,_ = dofile(MP.."/intllib.lua")
|
||||
|
||||
|
||||
|
|
After Width: | Height: | Size: 264 B |
Before Width: | Height: | Size: 359 B After Width: | Height: | Size: 355 B |
After Width: | Height: | Size: 6.3 KiB |
After Width: | Height: | Size: 920 B |
After Width: | Height: | Size: 753 B |
Before Width: | Height: | Size: 402 B After Width: | Height: | Size: 399 B |
After Width: | Height: | Size: 2.2 KiB |
After Width: | Height: | Size: 1.5 KiB |
After Width: | Height: | Size: 934 B |
After Width: | Height: | Size: 1.4 KiB |
After Width: | Height: | Size: 1.4 KiB |
After Width: | Height: | Size: 1.4 KiB |
After Width: | Height: | Size: 1.4 KiB |