cleanup obsolete files, consitent syntax and forms, new keypad texture

master
Juraj Vajda 2018-12-02 21:00:00 -05:00
parent bca954d393
commit 4b87c9e114
17 changed files with 325 additions and 252 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -46,7 +46,10 @@ local ball_spawner_update_form = function (pos)
local scale = meta:get_int("scale"); local scale = meta:get_int("scale");
local form = local form =
"size[4.25,4.75]" .. -- width, height "size[4.25,4.75]".. -- width, height
default.gui_bg..
default.gui_bg_img..
default.gui_slots..
"field[0.25,0.5;1,1;x0;target;"..x0.."] field[1.25,0.5;1,1;y0;;"..y0.."] field[2.25,0.5;1,1;z0;;"..z0.."]".. "field[0.25,0.5;1,1;x0;target;"..x0.."] field[1.25,0.5;1,1;y0;;"..y0.."] field[2.25,0.5;1,1;z0;;"..z0.."]"..
"field[3.25,0.5;1,1;speed;speed;"..speed.."]".. "field[3.25,0.5;1,1;speed;speed;"..speed.."]"..
--speed, jump, gravity,sneak --speed, jump, gravity,sneak

View File

@ -39,24 +39,24 @@ basic_machines.craft_recipe_order = { -- order in which nodes appear
"keypad","light","grinder","mover", "battery","generator","detector", "distributor", "clock_generator","recycler","autocrafter","ball_spawner", "power_block", "power_cell", "coal_lump", "keypad","light","grinder","mover", "battery","generator","detector", "distributor", "clock_generator","recycler","autocrafter","ball_spawner", "power_block", "power_cell", "coal_lump",
} }
local constructor_process = function(pos)
local constructor_process = function(pos)
local meta = minetest.get_meta(pos); local meta = minetest.get_meta(pos);
local craft = basic_machines.craft_recipes[meta:get_string("craft")]; local craft = basic_machines.craft_recipes[meta:get_string("craft")];
if not craft then return end if not craft then return end
local item = craft.item; local item = craft.item;
local craftlist = craft.craft; local craftlist = craft.craft;
local inv = meta:get_inventory(); local inv = meta:get_inventory();
for _,v in pairs(craftlist) do for _,v in pairs(craftlist) do
if not inv:contains_item("main", ItemStack(v)) then if not inv:contains_item("main", ItemStack(v)) then
meta:set_string("infotext", "#CRAFTING: you need " .. v .. " to craft " .. craft.item) meta:set_string("infotext", "#CRAFTING: you need " .. v .. " to craft " .. craft.item)
return return
end end
end end
for _,v in pairs(craftlist) do for _,v in pairs(craftlist) do
inv:remove_item("main", ItemStack(v)); inv:remove_item("main", ItemStack(v));
end end
@ -66,45 +66,48 @@ end
local constructor_update_meta = function(pos) local constructor_update_meta = function(pos)
local meta = minetest.get_meta(pos); local meta = minetest.get_meta(pos);
local list_name = "nodemeta:"..pos.x..','..pos.y..','..pos.z local list_name = "nodemeta:"..pos.x..','..pos.y..','..pos.z
local craft = meta:get_string("craft"); local craft = meta:get_string("craft");
local description = basic_machines.craft_recipes[craft]; local description = basic_machines.craft_recipes[craft];
local tex; local tex;
if description then if description then
tex = description.tex; tex = description.tex;
local i = 0; local i = 0;
local itex; local itex;
local inv = meta:get_inventory(); -- set up craft list local inv = meta:get_inventory(); -- set up craft list
for _,v in pairs(description.craft) do for _,v in pairs(description.craft) do
i=i+1; i=i+1;
inv:set_stack("recipe", i, ItemStack(v)) inv:set_stack("recipe", i, ItemStack(v))
end end
for j = i+1,6 do for j = i+1,6 do
inv:set_stack("recipe", j, ItemStack("")) inv:set_stack("recipe", j, ItemStack(""))
end end
description = description.description description = description.description
else else
description = "" description = ""
tex = "" tex = ""
end end
local textlist = " "; local textlist = " ";
local selected = meta:get_int("selected") or 1; local selected = meta:get_int("selected") or 1;
for _,v in ipairs(basic_machines.craft_recipe_order) do for _,v in ipairs(basic_machines.craft_recipe_order) do
textlist = textlist .. v .. ", "; textlist = textlist .. v .. ", ";
end end
local form = local form =
"size[8,10]".. "size[8,10]"..
default.gui_bg..
default.gui_bg_img..
default.gui_slots..
"textlist[0,0;3,1.5;craft;" .. textlist .. ";" .. selected .."]".. "textlist[0,0;3,1.5;craft;" .. textlist .. ";" .. selected .."]"..
"button[3.5,1;1.25,0.75;CRAFT;CRAFT]".. "button[3.5,1;1.25,0.75;CRAFT;CRAFT]"..
"image[3.65,0;1,1;".. tex .. ".png]".. "image[3.65,0;1,1;".. tex .. ".png]"..
@ -137,14 +140,14 @@ minetest.register_node("basic_machines:constructor", {
local inv = meta:get_inventory();inv:set_size("main", 24);--inv:set_size("dst",6); local inv = meta:get_inventory();inv:set_size("main", 24);--inv:set_size("dst",6);
inv:set_size("recipe",8); inv:set_size("recipe",8);
end, end,
on_rightclick = function(pos, node, player, itemstack, pointed_thing) on_rightclick = function(pos, node, player, itemstack, pointed_thing)
local meta = minetest.get_meta(pos); local meta = minetest.get_meta(pos);
local privs = minetest.get_player_privs(player:get_player_name()); local privs = minetest.get_player_privs(player:get_player_name());
if minetest.is_protected(pos, player:get_player_name()) and not privs.privs then return end -- only owner can interact with recycler if minetest.is_protected(pos, player:get_player_name()) and not privs.privs then return end -- only owner can interact with recycler
constructor_update_meta(pos); constructor_update_meta(pos);
end, end,
allow_metadata_inventory_put = function(pos, listname, index, stack, player) allow_metadata_inventory_put = function(pos, listname, index, stack, player)
if minetest.is_protected(pos, player:get_player_name()) then if minetest.is_protected(pos, player:get_player_name()) then
@ -158,7 +161,7 @@ minetest.register_node("basic_machines:constructor", {
if meta:get_string("owner") ~= player:get_player_name() and not privs.privs then return 0 end if meta:get_string("owner") ~= player:get_player_name() and not privs.privs then return 0 end
return stack:get_count(); return stack:get_count();
end, end,
allow_metadata_inventory_take = function(pos, listname, index, stack, player) allow_metadata_inventory_take = function(pos, listname, index, stack, player)
if listname == "recipe" then return 0 end if listname == "recipe" then return 0 end
@ -171,8 +174,8 @@ minetest.register_node("basic_machines:constructor", {
return stack:get_count(); return stack:get_count();
end, end,
on_metadata_inventory_put = function(pos, listname, index, stack, player) on_metadata_inventory_put = function(pos, listname, index, stack, player)
if listname == "recipe" then return 0 end if listname == "recipe" then return 0 end
local privs = minetest.get_player_privs(player:get_player_name()); local privs = minetest.get_player_privs(player:get_player_name());
@ -183,59 +186,59 @@ minetest.register_node("basic_machines:constructor", {
return stack:get_count(); return stack:get_count();
end, end,
allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player) allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
return 0; return 0;
end, end,
mesecons = {effector = { mesecons = {effector = {
action_on = function (pos, node,ttl) action_on = function (pos, node,ttl)
if type(ttl)~="number" then ttl = 1 end if type(ttl)~="number" then ttl = 1 end
if ttl<0 then return end -- machines_TTL prevents infinite recursion if ttl<0 then return end -- machines_TTL prevents infinite recursion
constructor_process(pos); constructor_process(pos);
end end
} }
}, },
on_receive_fields = function(pos, formname, fields, sender) on_receive_fields = function(pos, formname, fields, sender)
if minetest.is_protected(pos, sender:get_player_name()) then if minetest.is_protected(pos, sender:get_player_name()) then
minetest.record_protection_violation(pos, sender:get_player_name()) minetest.record_protection_violation(pos, sender:get_player_name())
return return
end end
local meta = minetest.get_meta(pos); local meta = minetest.get_meta(pos);
if fields.craft then if fields.craft then
if string.sub(fields.craft,1,3)=="CHG" then if string.sub(fields.craft,1,3)=="CHG" then
local sel = basic_machines.tonumber(string.sub(fields.craft,5)) or 1 local sel = basic_machines.tonumber(string.sub(fields.craft,5)) or 1
meta:set_int("selected",sel); meta:set_int("selected",sel);
local i = 0; local i = 0;
for _,v in ipairs(basic_machines.craft_recipe_order) do for _,v in ipairs(basic_machines.craft_recipe_order) do
i=i+1; i=i+1;
if i == sel then meta:set_string("craft",v); break; end if i == sel then meta:set_string("craft",v); break; end
end end
else else
return return
end end
end end
if fields.CRAFT then if fields.CRAFT then
constructor_process(pos); constructor_process(pos);
end end
constructor_update_meta(pos); constructor_update_meta(pos);
end, end,
can_dig = function(pos) can_dig = function(pos)
local meta = minetest.get_meta(pos); local meta = minetest.get_meta(pos);
local inv = meta:get_inventory(); local inv = meta:get_inventory();
if not (inv:is_empty("main")) then return false end -- main inv must be empty to be dug if not (inv:is_empty("main")) then return false end -- main inv must be empty to be dug
return true return true
end end
@ -248,6 +251,6 @@ minetest.register_craft({
{"default:steel_ingot","default:steel_ingot","default:steel_ingot"}, {"default:steel_ingot","default:steel_ingot","default:steel_ingot"},
{"default:steel_ingot","default:copperblock","default:steel_ingot"}, {"default:steel_ingot","default:copperblock","default:steel_ingot"},
{"default:steel_ingot","default:steel_ingot","default:steel_ingot"}, {"default:steel_ingot","default:steel_ingot","default:steel_ingot"},
} }
}) })

View File

@ -5,18 +5,18 @@
local enviro = {}; local enviro = {};
enviro.skyboxes = { enviro.skyboxes = {
["default"]={type = "regular", tex = {}}, ["default"]={type = "regular", tex = {}},
["space"]={type="skybox", tex={"sky_pos_y.png","sky_neg_y.png","sky_pos_z.png","sky_neg_z.png","sky_neg_x.png","sky_pos_x.png",}}, -- need textures installed! ["space"]={type="skybox", tex={"sky_pos_y.png","sky_neg_y.png","sky_pos_z.png","sky_neg_z.png","sky_neg_x.png","sky_pos_x.png",}}, -- need textures installed!
["caves"]={type = "cavebox", tex = {"black.png","black.png","black.png","black.png","black.png","black.png",}}, ["caves"]={type = "cavebox", tex = {"black.png","black.png","black.png","black.png","black.png","black.png",}},
}; };
local space_start = 1100; local space_start = 1100;
local ENABLE_SPACE_EFFECTS = false -- enable damage outside protected areas local ENABLE_SPACE_EFFECTS = false -- enable damage outside protected areas
local enviro_update_form = function (pos) local enviro_update_form = function (pos)
local meta = minetest.get_meta(pos); local meta = minetest.get_meta(pos);
local x0,y0,z0; local x0,y0,z0;
x0=meta:get_int("x0");y0=meta:get_int("y0");z0=meta:get_int("z0"); x0=meta:get_int("x0");y0=meta:get_int("y0");z0=meta:get_int("z0");
@ -34,9 +34,12 @@ local enviro_update_form = function (pos)
speed = meta:get_float("speed");jump = meta:get_float("jump"); speed = meta:get_float("speed");jump = meta:get_float("jump");
g = meta:get_float("g"); sneak = meta:get_int("sneak"); g = meta:get_float("g"); sneak = meta:get_int("sneak");
local list_name = "nodemeta:"..pos.x..','..pos.y..','..pos.z; local list_name = "nodemeta:"..pos.x..','..pos.y..','..pos.z;
local form = local form =
"size[8,8.5]".. -- width, height "size[8,8.5]".. -- width, height
default.gui_bg..
default.gui_bg_img..
default.gui_slots..
"field[0.25,0.5;1,1;x0;target;"..x0.."] field[1.25,0.5;1,1;y0;;"..y0.."] field[2.25,0.5;1,1;z0;;"..z0.."]".. "field[0.25,0.5;1,1;x0;target;"..x0.."] field[1.25,0.5;1,1;y0;;"..y0.."] field[2.25,0.5;1,1;z0;;"..z0.."]"..
"field[3.25,0.5;1,1;r;radius;"..r.."]".. "field[3.25,0.5;1,1;r;radius;"..r.."]"..
--speed, jump, gravity,sneak --speed, jump, gravity,sneak
@ -54,7 +57,7 @@ local enviro_update_form = function (pos)
"listring[current_player;main]" "listring[current_player;main]"
meta:set_string("formspec",form) meta:set_string("formspec",form)
end end
-- enviroment changer -- enviroment changer
minetest.register_node("basic_machines:enviro", { minetest.register_node("basic_machines:enviro", {
description = "Changes enviroment for players around target location", description = "Changes enviroment for players around target location",
@ -86,51 +89,51 @@ minetest.register_node("basic_machines:enviro", {
local inv = meta:get_inventory(); local inv = meta:get_inventory();
inv:set_size("fuel",1*1); inv:set_size("fuel",1*1);
enviro_update_form(pos); enviro_update_form(pos);
end, end,
mesecons = {effector = { mesecons = {effector = {
action_on = function (pos, node,ttl) action_on = function (pos, node,ttl)
local meta = minetest.get_meta(pos); local meta = minetest.get_meta(pos);
local machines = meta:get_int("machines"); local machines = meta:get_int("machines");
if not machines == 1 then meta:set_string("infotext","Error. You need machines privs.") return end if not machines == 1 then meta:set_string("infotext","Error. You need machines privs.") return end
local admin = meta:get_int("admin"); local admin = meta:get_int("admin");
local inv = meta:get_inventory(); local stack = ItemStack("default:diamond 1"); local inv = meta:get_inventory(); local stack = ItemStack("default:diamond 1");
if inv:contains_item("fuel", stack) then if inv:contains_item("fuel", stack) then
inv:remove_item("fuel", stack); inv:remove_item("fuel", stack);
else else
meta:set_string("infotext","Error. Insert diamond in fuel inventory") meta:set_string("infotext","Error. Insert diamond in fuel inventory")
return return
end end
local x0,y0,z0,r,skybox,speed,jump,g,sneak; local x0,y0,z0,r,skybox,speed,jump,g,sneak;
x0=meta:get_int("x0"); y0=meta:get_int("y0");z0=meta:get_int("z0"); -- target x0=meta:get_int("x0"); y0=meta:get_int("y0");z0=meta:get_int("z0"); -- target
r= meta:get_int("r",5); skybox=meta:get_string("skybox"); r= meta:get_int("r",5); skybox=meta:get_string("skybox");
speed=meta:get_float("speed");jump= meta:get_float("jump"); speed=meta:get_float("speed");jump= meta:get_float("jump");
g=meta:get_float("g");sneak=meta:get_int("sneak"); if sneak~=0 then sneak = true else sneak = false end g=meta:get_float("g");sneak=meta:get_int("sneak"); if sneak~=0 then sneak = true else sneak = false end
local players = minetest.get_connected_players(); local players = minetest.get_connected_players();
for _,player in pairs(players) do for _,player in pairs(players) do
local pos1 = player:getpos(); local pos1 = player:getpos();
local dist = math.sqrt((pos1.x-pos.x)^2 + (pos1.y-pos.y)^2 + (pos1.z-pos.z)^2 ); local dist = math.sqrt((pos1.x-pos.x)^2 + (pos1.y-pos.y)^2 + (pos1.z-pos.z)^2 );
if dist<=r then if dist<=r then
player:set_physics_override({speed=speed,jump=jump,gravity=g,sneak=sneak}) player:set_physics_override({speed=speed,jump=jump,gravity=g,sneak=sneak})
if admin == 1 then -- only admin can change skybox if admin == 1 then -- only admin can change skybox
local sky = enviro.skyboxes[skybox]; local sky = enviro.skyboxes[skybox];
player:set_sky(0,sky["type"],sky["tex"]); player:set_sky(0,sky["type"],sky["tex"]);
end end
end end
end end
-- attempt to set acceleration to balls, if any around -- attempt to set acceleration to balls, if any around
local objects = minetest.get_objects_inside_radius(pos, r) local objects = minetest.get_objects_inside_radius(pos, r)
for _,obj in pairs(objects) do for _,obj in pairs(objects) do
if obj:get_luaentity() then if obj:get_luaentity() then
local obj_name = obj:get_luaentity().name or "" local obj_name = obj:get_luaentity().name or ""
@ -138,26 +141,26 @@ minetest.register_node("basic_machines:enviro", {
obj:setacceleration({x=0,y=-g,z=0}); obj:setacceleration({x=0,y=-g,z=0});
end end
end end
end end
end end
} }
}, },
on_receive_fields = function(pos, formname, fields, sender) on_receive_fields = function(pos, formname, fields, sender)
if minetest.is_protected(pos, sender:get_player_name()) then if minetest.is_protected(pos, sender:get_player_name()) then
minetest.record_protection_violation(pos, sender:get_player_name()) minetest.record_protection_violation(pos, sender:get_player_name())
return return
end end
local name = sender:get_player_name(); local name = sender:get_player_name();
if fields.OK then if fields.OK then
local privs = minetest.get_player_privs(sender:get_player_name()); local privs = minetest.get_player_privs(sender:get_player_name());
local meta = minetest.get_meta(pos); local meta = minetest.get_meta(pos);
@ -167,40 +170,40 @@ minetest.register_node("basic_machines:enviro", {
if fields.y0 then y0 = tonumber(fields.y0) or 0 end if fields.y0 then y0 = tonumber(fields.y0) or 0 end
if fields.z0 then z0 = tonumber(fields.z0) or 0 end if fields.z0 then z0 = tonumber(fields.z0) or 0 end
if not privs.privs and (math.abs(x0)>10 or math.abs(y0)>10 or math.abs(z0) > 10) then return end if not privs.privs and (math.abs(x0)>10 or math.abs(y0)>10 or math.abs(z0) > 10) then return end
meta:set_int("x0",x0);meta:set_int("y0",y0);meta:set_int("z0",z0); meta:set_int("x0",x0);meta:set_int("y0",y0);meta:set_int("z0",z0);
if privs.privs then -- only admin can set sky if privs.privs then -- only admin can set sky
if fields.skybox then meta:set_string("skybox", fields.skybox) end if fields.skybox then meta:set_string("skybox", fields.skybox) end
end end
if fields.r then if fields.r then
local r = tonumber(fields.r) or 0; local r = tonumber(fields.r) or 0;
if r > 10 and not privs.privs then return end if r > 10 and not privs.privs then return end
meta:set_int("r", r) meta:set_int("r", r)
end end
if fields.g then if fields.g then
local g = tonumber(fields.g) or 1; local g = tonumber(fields.g) or 1;
if (g<0.1 or g>40) and not privs.privs then return end if (g<0.1 or g>40) and not privs.privs then return end
meta:set_float("g", g) meta:set_float("g", g)
end end
if fields.speed then if fields.speed then
local speed = tonumber(fields.speed) or 1; local speed = tonumber(fields.speed) or 1;
if (speed>1 or speed < 0) and not privs.privs then return end if (speed>1 or speed < 0) and not privs.privs then return end
meta:set_float("speed", speed) meta:set_float("speed", speed)
end end
if fields.jump then if fields.jump then
local jump = tonumber(fields.jump) or 1; local jump = tonumber(fields.jump) or 1;
if (jump<0 or jump>2) and not privs.privs then return end if (jump<0 or jump>2) and not privs.privs then return end
meta:set_float("jump", jump) meta:set_float("jump", jump)
end end
if fields.sneak then if fields.sneak then
meta:set_int("sneak", tonumber(fields.sneak) or 0) meta:set_int("sneak", tonumber(fields.sneak) or 0)
end end
enviro_update_form(pos); enviro_update_form(pos);
end end
end, end,
allow_metadata_inventory_take = function(pos, listname, index, stack, player) allow_metadata_inventory_take = function(pos, listname, index, stack, player)
if minetest.is_protected(pos, player:get_player_name()) then if minetest.is_protected(pos, player:get_player_name()) then
@ -213,7 +216,7 @@ minetest.register_node("basic_machines:enviro", {
if meta:get_string("owner")~=player:get_player_name() and not privs.privs then return 0 end if meta:get_string("owner")~=player:get_player_name() and not privs.privs then return 0 end
return stack:get_count(); return stack:get_count();
end, end,
allow_metadata_inventory_put = function(pos, listname, index, stack, player) allow_metadata_inventory_put = function(pos, listname, index, stack, player)
if minetest.is_protected(pos, player:get_player_name()) then if minetest.is_protected(pos, player:get_player_name()) then
@ -226,13 +229,13 @@ minetest.register_node("basic_machines:enviro", {
if meta:get_string("owner")~=player:get_player_name() and not privs.privs then return 0 end if meta:get_string("owner")~=player:get_player_name() and not privs.privs then return 0 end
return stack:get_count(); return stack:get_count();
end, end,
can_dig = function(pos, player) -- dont dig if fuel is inside, cause it will be destroyed can_dig = function(pos, player) -- dont dig if fuel is inside, cause it will be destroyed
local meta = minetest.get_meta(pos); local meta = minetest.get_meta(pos);
local inv = meta:get_inventory(); local inv = meta:get_inventory();
return inv:is_empty("fuel") return inv:is_empty("fuel")
end, end,
}) })
@ -275,7 +278,7 @@ minetest.register_on_joinplayer(enviro_adjust_physics)
-- SERVER GLOBAL SPACE CODE: uncomment to enable it -- SERVER GLOBAL SPACE CODE: uncomment to enable it
local round = math.floor; local round = math.floor;
local protector_position = function(pos) local protector_position = function(pos)
local r = 20; local r = 20;
local ry = 2*r; local ry = 2*r;
return {x=round(pos.x/r+0.5)*r,y=round(pos.y/ry+0.5)*ry,z=round(pos.z/r+0.5)*r}; return {x=round(pos.x/r+0.5)*r,y=round(pos.y/ry+0.5)*ry,z=round(pos.z/r+0.5)*r};
@ -297,13 +300,13 @@ minetest.register_globalstep(function(dtime)
enviro_space[name] = inspace; enviro_space[name] = inspace;
enviro_adjust_physics(player); enviro_adjust_physics(player);
end end
if ENABLE_SPACE_EFFECTS and inspace==1 then -- special space code if ENABLE_SPACE_EFFECTS and inspace==1 then -- special space code
if pos.y<1500 and pos.y>1120 then if pos.y<1500 and pos.y>1120 then
local hp = player:get_hp(); local hp = player:get_hp();
if hp>0 then if hp>0 then
minetest.chat_send_player(name,"WARNING: you entered DEADLY RADIATION ZONE"); minetest.chat_send_player(name,"WARNING: you entered DEADLY RADIATION ZONE");
local privs = minetest.get_player_privs(name) local privs = minetest.get_player_privs(name)
@ -311,13 +314,13 @@ minetest.register_globalstep(function(dtime)
end end
return return
else else
local ppos = protector_position(pos); local ppos = protector_position(pos);
local populated = (minetest.get_node(ppos).name=="basic_protect:protector"); local populated = (minetest.get_node(ppos).name=="basic_protect:protector");
if populated then if populated then
if minetest.get_meta(ppos):get_int("space") == 1 then populated = false end if minetest.get_meta(ppos):get_int("space") == 1 then populated = false end
end end
if not populated then -- do damage if player found not close to protectors if not populated then -- do damage if player found not close to protectors
local hp = player:get_hp(); local hp = player:get_hp();
local privs = minetest.get_player_privs(name); local privs = minetest.get_player_privs(name);
@ -327,7 +330,7 @@ minetest.register_globalstep(function(dtime)
end end
end end
end end
end end
end end
end end
@ -341,7 +344,7 @@ end)
-- description = "enables breathing in space", -- description = "enables breathing in space",
-- drawtype = "liquid", -- drawtype = "liquid",
-- tiles = {"default_water_source_animated.png"}, -- tiles = {"default_water_source_animated.png"},
-- drawtype = "glasslike", -- drawtype = "glasslike",
-- paramtype = "light", -- paramtype = "light",
-- alpha = 150, -- alpha = 150,
@ -352,7 +355,7 @@ end)
-- buildable_to = true, -- buildable_to = true,
-- drop = "", -- drop = "",
-- groups = {not_in_creative_inventory=1}, -- groups = {not_in_creative_inventory=1},
-- after_place_node = function(pos, placer, itemstack, pointed_thing) -- after_place_node = function(pos, placer, itemstack, pointed_thing)
-- local r = 3; -- local r = 3;
-- for i = -r,r do -- for i = -r,r do
-- for j = -r,r do -- for j = -r,r do
@ -365,10 +368,10 @@ end)
-- end -- end
-- end -- end
-- end -- end
-- }) -- })
-- minetest.register_abm({ -- minetest.register_abm({
-- nodenames = {"basic_machines:air"}, -- nodenames = {"basic_machines:air"},
-- neighbors = {"air"}, -- neighbors = {"air"},
-- interval = 10, -- interval = 10,
@ -378,23 +381,23 @@ end)
-- end -- end
-- }); -- });
minetest.register_on_punchplayer( -- bring gravity closer to normal with each punch minetest.register_on_punchplayer( -- bring gravity closer to normal with each punch
function(player, hitter, time_from_last_punch, tool_capabilities, dir, damage) function(player, hitter, time_from_last_punch, tool_capabilities, dir, damage)
if player:get_physics_override() == nil then return end if player:get_physics_override() == nil then return end
local pos = player:getpos(); if pos.y>= space_start then return end local pos = player:getpos(); if pos.y>= space_start then return end
local gravity = player:get_physics_override().gravity; local gravity = player:get_physics_override().gravity;
if gravity<1 then if gravity<1 then
gravity = 1; gravity = 1;
player:set_physics_override({gravity=gravity}) player:set_physics_override({gravity=gravity})
end end
end end
) )
-- RECIPE: extremely expensive -- RECIPE: extremely expensive

View File

@ -24,7 +24,7 @@ basic_machines.grinder_recipes = {
-- es gems dust cooking -- es gems dust cooking
local es_gems = function() local es_gems = function()
local es_gems = { local es_gems = {
{name = "emerald", cooktime = 1200},{name = "ruby", cooktime = 1500},{name = "purpellium", cooktime = 1800}, {name = "emerald", cooktime = 1200},{name = "ruby", cooktime = 1500},{name = "purpellium", cooktime = 1800},
{name = "aikerum", cooktime = 2000}} {name = "aikerum", cooktime = 2000}}
for _,v in pairs(es_gems) do for _,v in pairs(es_gems) do
@ -32,53 +32,53 @@ local es_gems = function()
type = "cooking", type = "cooking",
recipe = "es:"..v.name.."_dust", recipe = "es:"..v.name.."_dust",
output = "es:"..v.name .."_crystal", output = "es:"..v.name .."_crystal",
cooktime = v.cooktime cooktime = v.cooktime
}) })
end end
end end
minetest.after(0,es_gems); minetest.after(0,es_gems);
local grinder_process = function(pos) local grinder_process = function(pos)
local node = minetest.get_node({x=pos.x,y=pos.y-1,z=pos.z}).name; local node = minetest.get_node({x=pos.x,y=pos.y-1,z=pos.z}).name;
local meta = minetest.get_meta(pos);local inv = meta:get_inventory(); local meta = minetest.get_meta(pos);local inv = meta:get_inventory();
-- PROCESS: check out inserted items -- PROCESS: check out inserted items
local stack = inv:get_stack("src",1); local stack = inv:get_stack("src",1);
if stack:is_empty() then return end; -- nothing to do if stack:is_empty() then return end; -- nothing to do
local src_item = stack:to_string(); local src_item = stack:to_string();
local p=string.find(src_item," "); if p then src_item = string.sub(src_item,1,p-1) else p = 0 end -- take first word to determine what item was local p=string.find(src_item," "); if p then src_item = string.sub(src_item,1,p-1) else p = 0 end -- take first word to determine what item was
local def = basic_machines.grinder_recipes[src_item]; local def = basic_machines.grinder_recipes[src_item];
if not def then if not def then
meta:set_string("infotext", "please insert valid materials"); return meta:set_string("infotext", "please insert valid materials"); return
end-- unknown node end-- unknown node
if stack:get_count()< def[3] then if stack:get_count()< def[3] then
meta:set_string("infotext", "Recipe requires at least " .. def[3] .. " " .. src_item); meta:set_string("infotext", "Recipe requires at least " .. def[3] .. " " .. src_item);
return return
end end
-- FUEL CHECK -- FUEL CHECK
local fuel = meta:get_float("fuel"); local fuel = meta:get_float("fuel");
if fuel-def[1]<0 then -- we need new fuel, check chest below if fuel-def[1]<0 then -- we need new fuel, check chest below
local fuellist = inv:get_list("fuel") local fuellist = inv:get_list("fuel")
if not fuellist then return end if not fuellist then return end
local fueladd, afterfuel = minetest.get_craft_result({method = "fuel", width = 1, items = fuellist}) local fueladd, afterfuel = minetest.get_craft_result({method = "fuel", width = 1, items = fuellist})
local supply=0; local supply=0;
if fueladd.time == 0 then -- no fuel inserted, try look for outlet if fueladd.time == 0 then -- no fuel inserted, try look for outlet
-- No valid fuel in fuel list -- No valid fuel in fuel list
supply = basic_machines.check_power({x=pos.x,y=pos.y-1,z=pos.z} , def[1]) or 0; -- tweaked so 1 coal = 1 energy supply = basic_machines.check_power({x=pos.x,y=pos.y-1,z=pos.z} , def[1]) or 0; -- tweaked so 1 coal = 1 energy
if supply>0 then if supply>0 then
fueladd.time = supply -- same as 10 coal fueladd.time = supply -- same as 10 coal
else else
meta:set_string("infotext", "Please insert fuel"); meta:set_string("infotext", "Please insert fuel");
@ -90,51 +90,54 @@ local grinder_process = function(pos)
fueladd.time=fueladd.time*0.1/4 -- thats 1 for coal fueladd.time=fueladd.time*0.1/4 -- thats 1 for coal
--minetest.chat_send_all("FUEL ADD TIME " .. fueladd.time) --minetest.chat_send_all("FUEL ADD TIME " .. fueladd.time)
end end
end end
if fueladd.time>0 then if fueladd.time>0 then
fuel=fuel + fueladd.time fuel=fuel + fueladd.time
meta:set_float("fuel",fuel); meta:set_float("fuel",fuel);
meta:set_string("infotext", "added fuel furnace burn time " .. fueladd.time .. ", fuel status " .. fuel); meta:set_string("infotext", "added fuel furnace burn time " .. fueladd.time .. ", fuel status " .. fuel);
end end
if fuel-def[1]<0 then if fuel-def[1]<0 then
meta:set_string("infotext", "need at least " .. def[1]-fuel .. " fuel to complete operation "); return meta:set_string("infotext", "need at least " .. def[1]-fuel .. " fuel to complete operation "); return
end end
end end
-- process items -- process items
-- TO DO: check if there is room for item yyy -- TO DO: check if there is room for item yyy
local addstack = ItemStack(def[2]); local addstack = ItemStack(def[2]);
if inv:room_for_item("dst", addstack) then if inv:room_for_item("dst", addstack) then
inv:add_item("dst",addstack); inv:add_item("dst",addstack);
else return else return
end end
--take 1 item from src inventory for each activation --take 1 item from src inventory for each activation
stack=stack:take_item(1); inv:remove_item("src", stack) stack=stack:take_item(1); inv:remove_item("src", stack)
-- minetest.sound_play("grinder", {pos=pos,gain=0.5,max_hear_distance = 16,}) -- minetest.sound_play("grinder", {pos=pos,gain=0.5,max_hear_distance = 16,})
fuel = fuel-def[1]; -- burn fuel fuel = fuel-def[1]; -- burn fuel
meta:set_float("fuel",fuel); meta:set_float("fuel",fuel);
meta:set_string("infotext", "fuel " .. fuel); meta:set_string("infotext", "fuel " .. fuel);
end end
local grinder_update_meta = function(pos) local grinder_update_meta = function(pos)
local meta = minetest.get_meta(pos); local meta = minetest.get_meta(pos);
local list_name = "nodemeta:"..pos.x..','..pos.y..','..pos.z local list_name = "nodemeta:"..pos.x..','..pos.y..','..pos.z
local form = local form =
"size[8,8]".. -- width, height "size[8,8]".. -- width, height
--"size[6,10]".. -- width, height --"size[6,10]".. -- width, height
default.gui_bg..
default.gui_bg_img..
default.gui_slots..
"label[0,0;IN] label[1,0;OUT] label[0,2;FUEL] ".. "label[0,0;IN] label[1,0;OUT] label[0,2;FUEL] "..
"list["..list_name..";src;0.,0.5;1,1;]".. "list["..list_name..";src;0.,0.5;1,1;]"..
"list["..list_name..";dst;1.,0.5;3,3;]".. "list["..list_name..";dst;1.,0.5;3,3;]"..
"list["..list_name..";fuel;0.,2.5;1,1;]".. "list["..list_name..";fuel;0.,2.5;1,1;]"..
"list[current_player;main;0,4;8,4;]".. "list[current_player;main;0,4;8,4;]"..
"button[6.5,0.5;1,1;OK;OK]".. "button[6.5,0.5;1,1;OK;OK]"..
"button[6.5,1.5;1,1;help;help]".. "button[6.5,1.5;1,1;help;help]"..
@ -160,14 +163,14 @@ minetest.register_node("basic_machines:grinder", {
meta:set_float("fuel",0); meta:set_float("fuel",0);
local inv = meta:get_inventory();inv:set_size("src", 1);inv:set_size("dst",9);inv:set_size("fuel",1); local inv = meta:get_inventory();inv:set_size("src", 1);inv:set_size("dst",9);inv:set_size("fuel",1);
end, end,
on_rightclick = function(pos, node, player, itemstack, pointed_thing) on_rightclick = function(pos, node, player, itemstack, pointed_thing)
local meta = minetest.get_meta(pos); local meta = minetest.get_meta(pos);
local privs = minetest.get_player_privs(player:get_player_name()); local privs = minetest.get_player_privs(player:get_player_name());
if minetest.is_protected(pos, player:get_player_name()) and not privs.privs then return end -- only owner can interact with recycler if minetest.is_protected(pos, player:get_player_name()) and not privs.privs then return end -- only owner can interact with recycler
grinder_update_meta(pos); grinder_update_meta(pos);
end, end,
allow_metadata_inventory_put = function(pos, listname, index, stack, player) allow_metadata_inventory_put = function(pos, listname, index, stack, player)
if minetest.is_protected(pos, player:get_player_name()) then if minetest.is_protected(pos, player:get_player_name()) then
@ -180,7 +183,7 @@ minetest.register_node("basic_machines:grinder", {
if meta:get_string("owner")~=player:get_player_name() and not privs.privs then return 0 end if meta:get_string("owner")~=player:get_player_name() and not privs.privs then return 0 end
return stack:get_count(); return stack:get_count();
end, end,
allow_metadata_inventory_take = function(pos, listname, index, stack, player) allow_metadata_inventory_take = function(pos, listname, index, stack, player)
if minetest.is_protected(pos, player:get_player_name()) then if minetest.is_protected(pos, player:get_player_name()) then
@ -193,25 +196,25 @@ minetest.register_node("basic_machines:grinder", {
if meta:get_string("owner")~=player:get_player_name() and not privs.privs then return 0 end if meta:get_string("owner")~=player:get_player_name() and not privs.privs then return 0 end
return stack:get_count(); return stack:get_count();
end, end,
on_metadata_inventory_put = function(pos, listname, index, stack, player) on_metadata_inventory_put = function(pos, listname, index, stack, player)
if listname =="dst" then return end if listname =="dst" then return end
grinder_process(pos); grinder_process(pos);
end, end,
allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player) allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
return 0; return 0;
end, end,
mesecons = {effector = { mesecons = {effector = {
action_on = function (pos, node,ttl) action_on = function (pos, node,ttl)
if type(ttl)~="number" then ttl = 1 end if type(ttl)~="number" then ttl = 1 end
if ttl<0 then return end -- machines_TTL prevents infinite recursion if ttl<0 then return end -- machines_TTL prevents infinite recursion
grinder_process(pos); grinder_process(pos);
end end
} }
}, },
on_receive_fields = function(pos, formname, fields, sender) on_receive_fields = function(pos, formname, fields, sender)
if minetest.is_protected(pos, sender:get_player_name()) then if minetest.is_protected(pos, sender:get_player_name()) then
@ -221,30 +224,34 @@ minetest.register_node("basic_machines:grinder", {
if fields.quit then return end if fields.quit then return end
local meta = minetest.get_meta(pos); local meta = minetest.get_meta(pos);
if fields.help then if fields.help then
--recipe list: [in] ={fuel cost, out, quantity of material required for processing} --recipe list: [in] ={fuel cost, out, quantity of material required for processing}
--basic_machines.grinder_recipes --basic_machines.grinder_recipes
local text = "RECIPES\n\n"; local text = "RECIPES\n\n";
for key,v in pairs(basic_machines.grinder_recipes) do for key,v in pairs(basic_machines.grinder_recipes) do
text = text .. "INPUT ".. key .. " " .. v[3] .. " OUTPUT " .. v[2] .. "\n" text = text .. "INPUT ".. key .. " " .. v[3] .. " OUTPUT " .. v[2] .. "\n"
end end
local form = "size [6,7] textarea[0,0;6.5,8.5;grinderhelp;GRINDER RECIPES;".. text.."]" local form = "size[6,7]"..
default.gui_bg..
default.gui_bg_img..
default.gui_slots..
"textarea[0,0;6.5,8.5;grinderhelp;GRINDER RECIPES;".. text.."]"
minetest.show_formspec(sender:get_player_name(), "grinderhelp", form) minetest.show_formspec(sender:get_player_name(), "grinderhelp", form)
end end
grinder_update_meta(pos); grinder_update_meta(pos);
end, end,
can_dig = function(pos) can_dig = function(pos)
local meta = minetest.get_meta(pos); local meta = minetest.get_meta(pos);
local inv = meta:get_inventory(); local inv = meta:get_inventory();
if not (inv:is_empty("fuel")) or not (inv:is_empty("src")) or not (inv:is_empty("dst")) then return false end -- all inv must be empty to be dug if not (inv:is_empty("fuel")) or not (inv:is_empty("src")) or not (inv:is_empty("dst")) then return false end -- all inv must be empty to be dug
return true return true
end end
}) })
@ -256,7 +263,7 @@ minetest.register_craft({
{"default:diamond","default:mese","default:diamond"}, {"default:diamond","default:mese","default:diamond"},
{"default:mese","default:diamondblock","default:mese"}, {"default:mese","default:diamondblock","default:mese"},
{"default:diamond","default:mese","default:diamond"}, {"default:diamond","default:mese","default:diamond"},
} }
}) })
@ -265,13 +272,13 @@ minetest.register_craft({
local function register_dust(name,input_node_name,ingot,grindcost,cooktime,R,G,B) local function register_dust(name,input_node_name,ingot,grindcost,cooktime,R,G,B)
if not R then R = "FF" end if not R then R = "FF" end
if not G then G = "FF" end if not G then G = "FF" end
if not B then B = "FF" end if not B then B = "FF" end
local purity_table = {"33","66"}; local purity_table = {"33","66"};
for i = 1,#purity_table do for i = 1,#purity_table do
local purity = purity_table[i]; local purity = purity_table[i];
minetest.register_craftitem("basic_machines:"..name.."_dust_".. purity, { minetest.register_craftitem("basic_machines:"..name.."_dust_".. purity, {
@ -279,11 +286,11 @@ local function register_dust(name,input_node_name,ingot,grindcost,cooktime,R,G,B
inventory_image = "basic_machines_dust.png^[colorize:#"..R..G..B..":"..purity * 2, inventory_image = "basic_machines_dust.png^[colorize:#"..R..G..B..":"..purity * 2,
}) })
end end
basic_machines.grinder_recipes[input_node_name] = {grindcost,"basic_machines:"..name.."_dust_".. purity_table[1].." 2",1} -- register grinder recipe basic_machines.grinder_recipes[input_node_name] = {grindcost,"basic_machines:"..name.."_dust_".. purity_table[1].." 2",1} -- register grinder recipe
if ingot~="" then if ingot~="" then
for i = 1,#purity_table-1 do for i = 1,#purity_table-1 do
minetest.register_craft({ minetest.register_craft({
type = "cooking", type = "cooking",
@ -292,7 +299,7 @@ local function register_dust(name,input_node_name,ingot,grindcost,cooktime,R,G,B
cooktime = cooktime cooktime = cooktime
}) })
end end
minetest.register_craft({ minetest.register_craft({
type = "cooking", type = "cooking",
recipe = "basic_machines:"..name.."_dust_".. purity_table[#purity_table], recipe = "basic_machines:"..name.."_dust_".. purity_table[#purity_table],
@ -300,7 +307,7 @@ local function register_dust(name,input_node_name,ingot,grindcost,cooktime,R,G,B
output = ingot, output = ingot,
cooktime = cooktime cooktime = cooktime
}) })
end end
end end
@ -319,11 +326,11 @@ basic_machines.grinder_recipes["default:tin_ingot"] = {4,"basic_machines:tin_dus
-- are moreores (tin, silver, mithril) present? -- are moreores (tin, silver, mithril) present?
local table = minetest.registered_items["moreores:tin_lump"]; if table then local table = minetest.registered_items["moreores:tin_lump"]; if table then
-- register_dust("tin","moreores:tin_lump","moreores:tin_ingot",4,8,"FF","FF","FF") -- register_dust("tin","moreores:tin_lump","moreores:tin_ingot",4,8,"FF","FF","FF")
register_dust("silver","moreores:silver_lump","moreores:silver_ingot",5,15,"BB","BB","BB") register_dust("silver","moreores:silver_lump","moreores:silver_ingot",5,15,"BB","BB","BB")
register_dust("mithril","moreores:mithril_lump","moreores:mithril_ingot",16,750,"00","00","FF") register_dust("mithril","moreores:mithril_lump","moreores:mithril_ingot",16,750,"00","00","FF")
basic_machines.grinder_recipes["moreores:tin_ingot"] = {4,"basic_machines:tin_dust_33 2",1}; basic_machines.grinder_recipes["moreores:tin_ingot"] = {4,"basic_machines:tin_dust_33 2",1};
basic_machines.grinder_recipes["moreores:silver_ingot"] = {5,"basic_machines:silver_dust_33 2",1}; basic_machines.grinder_recipes["moreores:silver_ingot"] = {5,"basic_machines:silver_dust_33 2",1};
basic_machines.grinder_recipes["moreores:mithril_ingot"] = {16,"basic_machines:mithril_dust_33 2",1}; basic_machines.grinder_recipes["moreores:mithril_ingot"] = {16,"basic_machines:mithril_dust_33 2",1};

View File

@ -265,6 +265,9 @@ local get_mover_form = function(pos,player)
form = "size[8,8.25]" .. -- width, height form = "size[8,8.25]" .. -- width, height
--"size[6,10]" .. -- width, height --"size[6,10]" .. -- width, height
default.gui_bg..
default.gui_bg_img..
default.gui_slots..
"tabheader[0,0;tabs;MODE OF OPERATION,WHERE TO MOVE;".. seltab .. ";true;true]".. "tabheader[0,0;tabs;MODE OF OPERATION,WHERE TO MOVE;".. seltab .. ";true;true]"..
"label[0.,0;MODE selection]".."button[3,0.25;1,1;help;help]".. "label[0.,0;MODE selection]".."button[3,0.25;1,1;help;help]"..
"dropdown[0.,0.35;3,1;mode;normal,dig,drop,object,inventory,transport;".. mode .."]".. "dropdown[0.,0.35;3,1;mode;normal,dig,drop,object,inventory,transport;".. mode .."]"..
@ -294,6 +297,9 @@ local get_mover_form = function(pos,player)
form = "size[6,5.5]" .. -- width, height form = "size[6,5.5]" .. -- width, height
--"size[6,10]" .. -- width, height --"size[6,10]" .. -- width, height
default.gui_bg..
default.gui_bg_img..
default.gui_slots..
"tabheader[0,0;tabs;MODE OF OPERATION,WHERE TO MOVE;".. seltab .. ";true;true]".. "tabheader[0,0;tabs;MODE OF OPERATION,WHERE TO MOVE;".. seltab .. ";true;true]"..
"label[0.,0;" .. minetest.colorize("lawngreen","INPUT AREA - mover will dig here").."]".. "label[0.,0;" .. minetest.colorize("lawngreen","INPUT AREA - mover will dig here").."]"..
@ -1002,7 +1008,7 @@ minetest.register_node("basic_machines:mover", {
if prefer ~= node1.name and if prefer ~= node1.name and
not source_chest and not source_chest and
mode ~= "inventory" then mode ~= "inventory" then
return return
end end
-- take stuff from chest -- take stuff from chest
@ -1493,6 +1499,9 @@ local function check_keypad(pos,name,ttl) -- called only when manually activated
if meta:get_string("text") == "@" then -- keypad works as a keyboard if meta:get_string("text") == "@" then -- keypad works as a keyboard
local form = local form =
"size[3,1]" .. -- width, height "size[3,1]" .. -- width, height
default.gui_bg..
default.gui_bg_img..
default.gui_slots..
"field[0.25,0.25;3,1;pass;Enter text: ;".."".."] button_exit[0.,0.5;1,1;OK;OK]"; "field[0.25,0.25;3,1;pass;Enter text: ;".."".."] button_exit[0.,0.5;1,1;OK;OK]";
minetest.show_formspec(name, "basic_machines:check_keypad_"..minetest.pos_to_string(pos), form) minetest.show_formspec(name, "basic_machines:check_keypad_"..minetest.pos_to_string(pos), form)
return return
@ -1501,11 +1510,12 @@ local function check_keypad(pos,name,ttl) -- called only when manually activated
pass = "" pass = ""
local form = local form =
"size[3,1.25]" .. -- width, height "size[3,1.25]" .. -- width, height
"bgcolor[#FF8888BB; false]" .. default.gui_bg..
default.gui_bg_img..
default.gui_slots..
"field[0.25,0.25;3,1;pass;Enter Password: ;".."".."] button_exit[0.,0.75;1,1;OK;OK]"; "field[0.25,0.25;3,1;pass;Enter Password: ;".."".."] button_exit[0.,0.75;1,1;OK;OK]";
minetest.show_formspec(name, "basic_machines:check_keypad_"..minetest.pos_to_string(pos), form) minetest.show_formspec(name, "basic_machines:check_keypad_"..minetest.pos_to_string(pos), form)
return return
end end
minetest.register_node("basic_machines:keypad", { minetest.register_node("basic_machines:keypad", {
@ -1550,7 +1560,9 @@ minetest.register_node("basic_machines:keypad", {
pass = meta:get_string("pass"); pass = meta:get_string("pass");
local form = local form =
"size[4.25,3.75]" .. -- width, height "size[4.25,3.75]" .. -- width, height
"bgcolor[#888888BB; false]" .. default.gui_bg..
default.gui_bg_img..
default.gui_slots..
"field[2.25,0.25;2.25,1;pass;Password: ;"..pass.."]" .. "field[2.25,0.25;2.25,1;pass;Password: ;"..pass.."]" ..
"field[0.25,2.5;3.25,1;text;text;".. text .."]" .. "field[0.25,2.5;3.25,1;text;text;".. text .."]" ..
"field[0.25,0.25;1,1;mode;mode;"..mode.."]".. "field[1.25,0.25;1,1;iter;repeat;".. iter .."]".. "field[0.25,0.25;1,1;mode;mode;"..mode.."]".. "field[1.25,0.25;1,1;iter;repeat;".. iter .."]"..
@ -1638,6 +1650,9 @@ minetest.register_node("basic_machines:detector", {
local list_name = "nodemeta:"..pos.x..','..pos.y..','..pos.z local list_name = "nodemeta:"..pos.x..','..pos.y..','..pos.z
local form = local form =
"size[4,6.25]" .. -- width, height "size[4,6.25]" .. -- width, height
default.gui_bg..
default.gui_bg_img..
default.gui_slots..
"field[0.25,0.5;1,1;x0;source1;"..x0.."] field[1.25,0.5;1,1;y0;;"..y0.."] field[2.25,0.5;1,1;z0;;"..z0.."]".. "field[0.25,0.5;1,1;x0;source1;"..x0.."] field[1.25,0.5;1,1;y0;;"..y0.."] field[2.25,0.5;1,1;z0;;"..z0.."]"..
"dropdown[3,0.25;1,1;op; ,AND,OR;".. op .."]".. "dropdown[3,0.25;1,1;op; ,AND,OR;".. op .."]"..
"field[0.25,1.5;1,1;x1;source2;"..x1.."] field[1.25,1.5;1,1;y1;;"..y1.."] field[2.25,1.5;1,1;z1;;"..z1.."]".. "field[0.25,1.5;1,1;x1;source2;"..x1.."] field[1.25,1.5;1,1;y1;;"..y1.."] field[2.25,1.5;1,1;z1;;"..z1.."]"..
@ -1949,6 +1964,9 @@ local get_distributor_form = function(pos,player)
local list_name = "nodemeta:"..pos.x..','..pos.y..','..pos.z local list_name = "nodemeta:"..pos.x..','..pos.y..','..pos.z
local form = local form =
"size[7,"..(0.75+(n)*0.75).."]" .. -- width, height "size[7,"..(0.75+(n)*0.75).."]" .. -- width, height
default.gui_bg..
default.gui_bg_img..
default.gui_slots..
"label[0,-0.25;" .. minetest.colorize("lawngreen","target: x y z, MODE -2=only OFF, -1=NOT input/0/1=input, 2 = only ON") .. "]"; "label[0,-0.25;" .. minetest.colorize("lawngreen","target: x y z, MODE -2=only OFF, -1=NOT input/0/1=input, 2 = only ON") .. "]";
for i =1,n do for i =1,n do
form = form.."field[0.25,"..(0.5+(i-1)*0.75)..";1,1;x"..i..";;"..p[i].x.."] field[1.25,"..(0.5+(i-1)*0.75)..";1,1;y"..i..";;"..p[i].y.."] field[2.25,"..(0.5+(i-1)*0.75)..";1,1;z"..i..";;"..p[i].z.."] field [ 3.25,"..(0.5+(i-1)*0.75)..";1,1;active"..i..";;" .. active[i] .. "]" form = form.."field[0.25,"..(0.5+(i-1)*0.75)..";1,1;x"..i..";;"..p[i].x.."] field[1.25,"..(0.5+(i-1)*0.75)..";1,1;y"..i..";;"..p[i].y.."] field[2.25,"..(0.5+(i-1)*0.75)..";1,1;z"..i..";;"..p[i].z.."] field [ 3.25,"..(0.5+(i-1)*0.75)..";1,1;active"..i..";;" .. active[i] .. "]"
@ -1958,7 +1976,6 @@ local get_distributor_form = function(pos,player)
form=form.."button_exit[4.25,"..(0.25+(n)*0.75)..";1,1;ADD;ADD]".."button_exit[3.,"..(0.25+(n)*0.75)..";1,1;OK;OK]".."field[0.25,"..(0.5+(n)*0.75)..";1,1;delay;delay;"..delay .. "]"; form=form.."button_exit[4.25,"..(0.25+(n)*0.75)..";1,1;ADD;ADD]".."button_exit[3.,"..(0.25+(n)*0.75)..";1,1;OK;OK]".."field[0.25,"..(0.5+(n)*0.75)..";1,1;delay;delay;"..delay .. "]";
form = form.."button[6.25,"..(0.25+(n)*0.75)..";1,1;help;help]"; form = form.."button[6.25,"..(0.25+(n)*0.75)..";1,1;help;help]";
return form return form
end end
@ -2164,7 +2181,11 @@ minetest.register_node("basic_machines:light_on", {
local meta = minetest.get_meta(pos); local meta = minetest.get_meta(pos);
local list_name = "nodemeta:"..pos.x..','..pos.y..','..pos.z local list_name = "nodemeta:"..pos.x..','..pos.y..','..pos.z
local deactivate = meta:get_int("deactivate"); local deactivate = meta:get_int("deactivate");
local form = "size[2,2] field[0.25,0.5;2,1;deactivate;deactivate after ;"..deactivate.."]".."button_exit[0.,1;1,1;OK;OK]"; local form = "size[2,2]"..
default.gui_bg..
default.gui_bg_img..
default.gui_slots..
"field[0.25,0.5;2,1;deactivate;deactivate after ;"..deactivate.."]".."button_exit[0.,1;1,1;OK;OK]";
meta:set_string("formspec", form); meta:set_string("formspec", form);
end, end,
on_receive_fields = function(pos, formname, fields, player) on_receive_fields = function(pos, formname, fields, player)
@ -2179,7 +2200,11 @@ minetest.register_node("basic_machines:light_on", {
local deactivate = basic_machines.tonumber(fields.deactivate) or 0; local deactivate = basic_machines.tonumber(fields.deactivate) or 0;
if deactivate <0 or deactivate > 600 then deactivate = 0 end if deactivate <0 or deactivate > 600 then deactivate = 0 end
meta:set_int("deactivate",deactivate); meta:set_int("deactivate",deactivate);
local form = "size[2,2] field[0.25,0.5;2,1;deactivate;deactivate after ;"..deactivate.."]".."button_exit[0.,1;1,1;OK;OK]"; local form = "size[2,2]"..
default.gui_bg..
default.gui_bg_img..
default.gui_slots..
"field[0.25,0.5;2,1;deactivate;deactivate after ;"..deactivate.."]".."button_exit[0.,1;1,1;OK;OK]";
meta:set_string("formspec", form); meta:set_string("formspec", form);
end end
@ -2535,7 +2560,11 @@ minetest.register_on_player_receive_fields(function(player,formname,fields)
"\n\n FUEL CONSUMPTION depends on blocks to be moved and distance. For example, stone or tree is harder to move than dirt, harvesting wheat is very cheap and and moving lava is very hard.".. "\n\n FUEL CONSUMPTION depends on blocks to be moved and distance. For example, stone or tree is harder to move than dirt, harvesting wheat is very cheap and and moving lava is very hard."..
"\n\n UPGRADE mover by moving mese blocks in upgrade inventory. Each mese block increases mover range by 10, fuel consumption is divided by (number of mese blocks)+1 in upgrade. Max 10 blocks are used for upgrade. Dont forget to click OK to refresh after upgrade. ".. "\n\n UPGRADE mover by moving mese blocks in upgrade inventory. Each mese block increases mover range by 10, fuel consumption is divided by (number of mese blocks)+1 in upgrade. Max 10 blocks are used for upgrade. Dont forget to click OK to refresh after upgrade. "..
"\n\n Activate mover by keypad/detector signal or mese signal (if mesecons mod) ."; "\n\n Activate mover by keypad/detector signal or mese signal (if mesecons mod) .";
local form = "size [6,7] textarea[0,0;6.5,8.5;help;MOVER HELP;".. text.."]" local form = "size [6,7]"..
default.gui_bg..
default.gui_bg_img..
default.gui_slots..
"textarea[0,0;6.5,8.5;help;MOVER HELP;".. text.."]"
minetest.show_formspec(name, "basic_machines:help_mover", form) minetest.show_formspec(name, "basic_machines:help_mover", form)
return return
end end
@ -2700,7 +2729,11 @@ minetest.register_on_player_receive_fields(function(player,formname,fields)
"\ntext replacement : Suppose keypad A is set with text \"@some @. text @!\" and there are blocks on top of keypad A with infotext '1' and '2'. Suppose we target B with A and activate A. Then text of keypad B will be set to \"some 1. text 2!\"".. "\ntext replacement : Suppose keypad A is set with text \"@some @. text @!\" and there are blocks on top of keypad A with infotext '1' and '2'. Suppose we target B with A and activate A. Then text of keypad B will be set to \"some 1. text 2!\""..
"\nword extraction: Suppose similiar setup but now keypad A is set with text \"%1\". Then upon activation text of keypad B will be set to 1.st word of infotext"; "\nword extraction: Suppose similiar setup but now keypad A is set with text \"%1\". Then upon activation text of keypad B will be set to 1.st word of infotext";
local form = "size [6,7] textarea[0,0;6.5,8.5;help;KEYPAD HELP;".. text.."]" local form = "size[6,7]"..
default.gui_bg..
default.gui_bg_img..
default.gui_slots..
"textarea[0,0;6.5,8.5;help;KEYPAD HELP;".. text.."]"
minetest.show_formspec(name, "basic_machines:help_keypad", form) minetest.show_formspec(name, "basic_machines:help_keypad", form)
return return
end end
@ -2805,7 +2838,11 @@ minetest.register_on_player_receive_fields(function(player,formname,fields)
"If source position is chest it will look into it and check if there are items inside. If mode is inventory it will check for items in specified inventory of source node.".. "If source position is chest it will look into it and check if there are items inside. If mode is inventory it will check for items in specified inventory of source node."..
"\n\nADVANCED: you can select second source and then select AND/OR from the right top dropdown list to do logical operations. You can also filter output signal:\n -2=only OFF,-1=NOT/0/1=normal,2=only ON, 3 only if changed".. "\n\nADVANCED: you can select second source and then select AND/OR from the right top dropdown list to do logical operations. You can also filter output signal:\n -2=only OFF,-1=NOT/0/1=normal,2=only ON, 3 only if changed"..
" 4 = if target keypad set its text to detected object name" ; " 4 = if target keypad set its text to detected object name" ;
local form = "size [5.5,5.5] textarea[0,0;6,7;help;DETECTOR HELP;".. text.."]" local form = "size[5.5,5.5]"..
default.gui_bg..
default.gui_bg_img..
default.gui_slots..
"textarea[0,0;6,7;help;DETECTOR HELP;".. text.."]"
minetest.show_formspec(name, "basic_machines:help_detector", form) minetest.show_formspec(name, "basic_machines:help_detector", form)
end end
@ -2954,7 +2991,11 @@ minetest.register_on_player_receive_fields(function(player,formname,fields)
"delay option adds delay to activations, in seconds. With negative delay activation is randomized with probability -delay/1000.\n\n".. "delay option adds delay to activations, in seconds. With negative delay activation is randomized with probability -delay/1000.\n\n"..
"ADVANCED: you can use distributor as an event handler. First you must deactivate first target by putting 0 at\n".. "ADVANCED: you can use distributor as an event handler. First you must deactivate first target by putting 0 at\n"..
"last place in first line. Meanings of first 2 numbers are as follows: first number 0/1 controls if node/n".. "listens to failed interact attempts around it, second number -1/1 listens to chat and can mute it"; "last place in first line. Meanings of first 2 numbers are as follows: first number 0/1 controls if node/n".. "listens to failed interact attempts around it, second number -1/1 listens to chat and can mute it";
local form = "size [5.5,5.5] textarea[0,0;6,7;help;DISTRIBUTOR HELP;".. text.."]" local form = "size[5.5,5.5]"..
default.gui_bg..
default.gui_bg_img..
default.gui_slots..
"textarea[0,0;6,7;help;DISTRIBUTOR HELP;".. text.."]"
minetest.show_formspec(name, "basic_machines:help_distributor", form) minetest.show_formspec(name, "basic_machines:help_distributor", form)
end end

View File

@ -13,25 +13,25 @@ local no_recycle_list = {
} }
local recycler_process = function(pos) local recycler_process = function(pos)
local node = minetest.get_node({x=pos.x,y=pos.y-1,z=pos.z}).name; local node = minetest.get_node({x=pos.x,y=pos.y-1,z=pos.z}).name;
local meta = minetest.get_meta(pos);local inv = meta:get_inventory(); local meta = minetest.get_meta(pos);local inv = meta:get_inventory();
-- FUEL CHECK -- FUEL CHECK
local fuel = meta:get_float("fuel"); local fuel = meta:get_float("fuel");
if fuel-1<0 then -- we need new fuel, check chest below if fuel-1<0 then -- we need new fuel, check chest below
local fuellist = inv:get_list("fuel") local fuellist = inv:get_list("fuel")
if not fuellist then return end if not fuellist then return end
local fueladd, afterfuel = minetest.get_craft_result({method = "fuel", width = 1, items = fuellist}) local fueladd, afterfuel = minetest.get_craft_result({method = "fuel", width = 1, items = fuellist})
local supply=0; local supply=0;
if fueladd.time == 0 then -- no fuel inserted, try look for outlet if fueladd.time == 0 then -- no fuel inserted, try look for outlet
-- No valid fuel in fuel list -- No valid fuel in fuel list
supply = basic_machines.check_power({x=pos.x,y=pos.y-1,z=pos.z},1) or 0; supply = basic_machines.check_power({x=pos.x,y=pos.y-1,z=pos.z},1) or 0;
if supply>0 then if supply>0 then
fueladd.time = 40*supply -- same as 10 coal fueladd.time = 40*supply -- same as 10 coal
else else
meta:set_string("infotext", "Please insert fuel."); meta:set_string("infotext", "Please insert fuel.");
@ -42,8 +42,8 @@ local recycler_process = function(pos)
inv:set_stack("fuel", 1, afterfuel.items[1]) inv:set_stack("fuel", 1, afterfuel.items[1])
fueladd.time = fueladd.time*0.1; -- thats 4 for coal fueladd.time = fueladd.time*0.1; -- thats 4 for coal
end end
end end
if fueladd.time>0 then if fueladd.time>0 then
fuel=fuel + fueladd.time fuel=fuel + fueladd.time
meta:set_float("fuel",fuel); meta:set_float("fuel",fuel);
meta:set_string("infotext", "added fuel furnace burn time " .. fueladd.time .. ", fuel status " .. fuel); meta:set_string("infotext", "added fuel furnace burn time " .. fueladd.time .. ", fuel status " .. fuel);
@ -51,15 +51,15 @@ local recycler_process = function(pos)
if fuel-1<0 then return end if fuel-1<0 then return end
end end
-- RECYCLING: check out inserted items -- RECYCLING: check out inserted items
local stack = inv:get_stack("src",1); local stack = inv:get_stack("src",1);
if stack:is_empty() then return end; -- nothing to do if stack:is_empty() then return end; -- nothing to do
local src_item = stack:to_string(); local src_item = stack:to_string();
local p=string.find(src_item," "); if p then src_item = string.sub(src_item,1,p-1) end -- take first word to determine what item was local p=string.find(src_item," "); if p then src_item = string.sub(src_item,1,p-1) end -- take first word to determine what item was
-- look if we already handled this item -- look if we already handled this item
local known_recipe=true; local known_recipe=true;
if src_item~=meta:get_string("node") then-- did we already handle this? if yes read from cache if src_item~=meta:get_string("node") then-- did we already handle this? if yes read from cache
@ -68,56 +68,56 @@ local recycler_process = function(pos)
meta:set_int("reqcount",0); meta:set_int("reqcount",0);
known_recipe=false; known_recipe=false;
end end
local itemlist, reqcount; local itemlist, reqcount;
reqcount = 1; -- needed count of materials for recycle to work reqcount = 1; -- needed count of materials for recycle to work
if not known_recipe then if not known_recipe then
if no_recycle_list[src_item] then meta:set_string("node","") return end -- dont allow recycling of forbidden items if no_recycle_list[src_item] then meta:set_string("node","") return end -- dont allow recycling of forbidden items
local recipe = minetest.get_all_craft_recipes( src_item ); local recipe = minetest.get_all_craft_recipes( src_item );
local recipe_id = basic_machines.tonumber(meta:get_int("recipe")) or 1; local recipe_id = basic_machines.tonumber(meta:get_int("recipe")) or 1;
if not recipe then if not recipe then
return return
else else
itemlist = recipe[recipe_id]; itemlist = recipe[recipe_id];
if not itemlist then meta:set_string("node","") return end; if not itemlist then meta:set_string("node","") return end;
itemlist=itemlist.items; itemlist=itemlist.items;
end end
local output = recipe[recipe_id].output or ""; local output = recipe[recipe_id].output or "";
if string.find(output," ") then if string.find(output," ") then
local par = string.find(output," "); local par = string.find(output," ");
--if (basic_machines.tonumber(string.sub(output, par)) or 0)>1 then itemlist = {} end --if (basic_machines.tonumber(string.sub(output, par)) or 0)>1 then itemlist = {} end
if par then if par then
reqcount = basic_machines.tonumber(string.sub(output, par)) or 1; reqcount = basic_machines.tonumber(string.sub(output, par)) or 1;
end end
end end
meta:set_string("itemlist",minetest.serialize(itemlist)); -- read cached itemlist meta:set_string("itemlist",minetest.serialize(itemlist)); -- read cached itemlist
meta:set_int("reqcount",reqcount); meta:set_int("reqcount",reqcount);
else else
itemlist=minetest.deserialize(meta:get_string("itemlist")) or {}; itemlist=minetest.deserialize(meta:get_string("itemlist")) or {};
reqcount = meta:get_int("reqcount") or 1; reqcount = meta:get_int("reqcount") or 1;
end end
if stack:get_count()<reqcount then if stack:get_count()<reqcount then
meta:set_string("infotext", "at least " .. reqcount .. " of " .. src_item .. " is needed "); meta:set_string("infotext", "at least " .. reqcount .. " of " .. src_item .. " is needed ");
return return
end end
--empty dst inventory before proceeding --empty dst inventory before proceeding
-- local size = inv:get_size("dst"); -- local size = inv:get_size("dst");
-- for i=1,size do -- for i=1,size do
-- inv:set_stack("dst", i, ItemStack("")); -- inv:set_stack("dst", i, ItemStack(""));
-- end -- end
--take 1 item from src inventory for each activation --take 1 item from src inventory for each activation
stack=stack:take_item(reqcount); inv:remove_item("src", stack) stack=stack:take_item(reqcount); inv:remove_item("src", stack)
for _, v in pairs(itemlist) do for _, v in pairs(itemlist) do
if math.random(1, 4)<=3 then -- probability 3/4 = 75% if math.random(1, 4)<=3 then -- probability 3/4 = 75%
if not string.find(v,"group") then -- dont add if item described with group if not string.find(v,"group") then -- dont add if item described with group
@ -129,12 +129,12 @@ local recycler_process = function(pos)
end end
end end
end end
minetest.sound_play("recycler", {pos=pos,gain=0.5,max_hear_distance = 16,}) minetest.sound_play("recycler", {pos=pos,gain=0.5,max_hear_distance = 16,})
fuel = fuel-1; -- burn fuel on succesful operation fuel = fuel-1; -- burn fuel on succesful operation
meta:set_float("fuel",fuel); meta:set_string("infotext", "fuel status " .. fuel .. ", recycling " .. meta:get_string("node")); meta:set_float("fuel",fuel); meta:set_string("infotext", "fuel status " .. fuel .. ", recycling " .. meta:get_string("node"));
end end
@ -142,10 +142,13 @@ end
local recycler_update_meta = function(pos) local recycler_update_meta = function(pos)
local meta = minetest.get_meta(pos) local meta = minetest.get_meta(pos)
local list_name = "nodemeta:"..pos.x..','..pos.y..','..pos.z local list_name = "nodemeta:"..pos.x..','..pos.y..','..pos.z
local form = local form =
"size[8,8]".. -- width, heightinv:get_stack "size[8,8]".. -- width, heightinv:get_stack
--"size[6,10]".. -- width, height --"size[6,10]".. -- width, height
default.gui_bg..
default.gui_bg_img..
default.gui_slots..
"label[0,0;IN] label[1,0;OUT] label[0,2;FUEL] ".. "label[0,0;IN] label[1,0;OUT] label[0,2;FUEL] "..
"list["..list_name..";src;0.,0.5;1,1;]".. "list["..list_name..";src;0.,0.5;1,1;]"..
"list["..list_name..";dst;1.,0.5;3,3;]".. "list["..list_name..";dst;1.,0.5;3,3;]"..
@ -158,7 +161,7 @@ local recycler_update_meta = function(pos)
"listring["..list_name..";src]".. "listring["..list_name..";src]"..
"listring[current_player;main]".. "listring[current_player;main]"..
"listring["..list_name..";fuel]".. "listring["..list_name..";fuel]"..
"listring[current_player;main]" "listring[current_player;main]"
--"field[0.25,4.5;2,1;mode;mode;"..mode.."]" --"field[0.25,4.5;2,1;mode;mode;"..mode.."]"
meta:set_string("formspec", form) meta:set_string("formspec", form)
end end
@ -176,14 +179,14 @@ minetest.register_node("basic_machines:recycler", {
meta:set_float("fuel",0); meta:set_float("fuel",0);
local inv = meta:get_inventory();inv:set_size("src", 1);inv:set_size("dst",9);inv:set_size("fuel",1); local inv = meta:get_inventory();inv:set_size("src", 1);inv:set_size("dst",9);inv:set_size("fuel",1);
end, end,
on_rightclick = function(pos, node, player, itemstack, pointed_thing) on_rightclick = function(pos, node, player, itemstack, pointed_thing)
local meta = minetest.get_meta(pos); local meta = minetest.get_meta(pos);
local privs = minetest.get_player_privs(player:get_player_name()); local privs = minetest.get_player_privs(player:get_player_name());
if minetest.is_protected(pos, player:get_player_name()) and not privs.privs then return end -- only owner can interact with recycler if minetest.is_protected(pos, player:get_player_name()) and not privs.privs then return end -- only owner can interact with recycler
recycler_update_meta(pos); recycler_update_meta(pos);
end, end,
allow_metadata_inventory_put = function(pos, listname, index, stack, player) allow_metadata_inventory_put = function(pos, listname, index, stack, player)
if minetest.is_protected(pos, player:get_player_name()) then if minetest.is_protected(pos, player:get_player_name()) then
@ -196,7 +199,7 @@ minetest.register_node("basic_machines:recycler", {
if meta:get_string("owner")~=player:get_player_name() and not privs.privs then return 0 end if meta:get_string("owner")~=player:get_player_name() and not privs.privs then return 0 end
return stack:get_count(); return stack:get_count();
end, end,
allow_metadata_inventory_take = function(pos, listname, index, stack, player) allow_metadata_inventory_take = function(pos, listname, index, stack, player)
if minetest.is_protected(pos, player:get_player_name()) then if minetest.is_protected(pos, player:get_player_name()) then
@ -209,25 +212,25 @@ minetest.register_node("basic_machines:recycler", {
if meta:get_string("owner")~=player:get_player_name() and not privs.privs then return 0 end if meta:get_string("owner")~=player:get_player_name() and not privs.privs then return 0 end
return stack:get_count(); return stack:get_count();
end, end,
on_metadata_inventory_put = function(pos, listname, index, stack, player) on_metadata_inventory_put = function(pos, listname, index, stack, player)
if listname =="dst" then return end if listname =="dst" then return end
recycler_process(pos); recycler_process(pos);
end, end,
allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player) allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
return 0; return 0;
end, end,
mesecons = {effector = { mesecons = {effector = {
action_on = function (pos, node,ttl) action_on = function (pos, node,ttl)
if type(ttl)~="number" then ttl = 1 end if type(ttl)~="number" then ttl = 1 end
if ttl<0 then return end -- machines_TTL prevents infinite recursion if ttl<0 then return end -- machines_TTL prevents infinite recursion
recycler_process(pos); recycler_process(pos);
end end
} }
}, },
on_receive_fields = function(pos, formname, fields, sender) on_receive_fields = function(pos, formname, fields, sender)
if minetest.is_protected(pos, sender:get_player_name()) then if minetest.is_protected(pos, sender:get_player_name()) then
@ -246,16 +249,16 @@ minetest.register_node("basic_machines:recycler", {
meta:set_string("node",""); -- this will force to reread recipe on next use meta:set_string("node",""); -- this will force to reread recipe on next use
recycler_update_meta(pos); recycler_update_meta(pos);
end, end,
can_dig = function(pos) can_dig = function(pos)
local meta = minetest.get_meta(pos); local meta = minetest.get_meta(pos);
local inv = meta:get_inventory(); local inv = meta:get_inventory();
if not (inv:is_empty("fuel")) or not (inv:is_empty("src")) or not (inv:is_empty("dst")) then return false end -- all inv must be empty to be dug if not (inv:is_empty("fuel")) or not (inv:is_empty("src")) or not (inv:is_empty("dst")) then return false end -- all inv must be empty to be dug
return true return true
end end
}) })
@ -267,6 +270,6 @@ minetest.register_craft({
{"default:mese_crystal","default:mese_crystal","default:mese_crystal"}, {"default:mese_crystal","default:mese_crystal","default:mese_crystal"},
{"default:mese_crystal","default:diamondblock","default:mese_crystal"}, {"default:mese_crystal","default:diamondblock","default:mese_crystal"},
{"default:mese_crystal","default:mese_crystal","default:mese_crystal"}, {"default:mese_crystal","default:mese_crystal","default:mese_crystal"},
} }
}) })

View File

@ -12,7 +12,9 @@ local battery_update_meta = function(pos)
local form = local form =
"size[8,6.5]".. -- width, height "size[8,6.5]".. -- width, height
"bgcolor[#333333;false]".. default.gui_bg..
default.gui_bg_img..
default.gui_slots..
"label[0,0;FUEL] ".."label[6,0;UPGRADE] ".. "label[0,0;FUEL] ".."label[6,0;UPGRADE] "..
"box[1.45,0.48;2.15,1.01;#222222]".. "box[1.45,0.48;2.15,1.01;#222222]"..
"list["..list_name..";fuel;0.,0.5;1,1;]".. "list["..list_name..";fuel;0.,0.5;1,1;]"..
@ -271,7 +273,11 @@ minetest.register_node("basic_machines:battery_0", {
"UPGRADE with diamondblocks for more available power output or with ".. "UPGRADE with diamondblocks for more available power output or with "..
"meseblocks for more power storage capacity" "meseblocks for more power storage capacity"
local form = "size [6,7] textarea[0,0;6.5,8.5;help;BATTERY HELP;".. text.."]" local form = "size[6,7]"..
default.gui_bg..
default.gui_bg_img..
default.gui_slots..
"textarea[0,0;6.5,8.5;help;BATTERY HELP;".. text.."]"
minetest.show_formspec(name, "basic_machines:help_battery", form) minetest.show_formspec(name, "basic_machines:help_battery", form)
end end
end, end,
@ -347,6 +353,9 @@ local generator_update_meta = function(pos)
local form = local form =
"size[8,6.5]" .. -- width, height "size[8,6.5]" .. -- width, height
default.gui_bg..
default.gui_bg_img..
default.gui_slots..
"label[0,0;POWER CRYSTALS] ".."label[6,0;UPGRADE] ".. "label[0,0;POWER CRYSTALS] ".."label[6,0;UPGRADE] "..
"label[1,1;UPGRADE LEVEL ".. meta:get_int("upgrade").." (generator)]".. "label[1,1;UPGRADE LEVEL ".. meta:get_int("upgrade").." (generator)]"..
"list["..list_name..";fuel;0.,0.5;1,1;]".. "list["..list_name..";fuel;0.,0.5;1,1;]"..
@ -410,7 +419,11 @@ minetest.register_node("basic_machines:generator", {
if fields.quit then return end if fields.quit then return end
if fields.help then if fields.help then
local text = "Generator slowly produces power crystals. Those can be used to recharge batteries and come in 3 flavors:\n\n low level (0-4), medium level (5-19) and high level (20+). Upgrading the generator (upgrade with generators) will increase the rate at which the crystals are produced.\n\nYou can automate the process of battery recharging by using mover in inventory mode, taking from inventory \"fuel\""; local text = "Generator slowly produces power crystals. Those can be used to recharge batteries and come in 3 flavors:\n\n low level (0-4), medium level (5-19) and high level (20+). Upgrading the generator (upgrade with generators) will increase the rate at which the crystals are produced.\n\nYou can automate the process of battery recharging by using mover in inventory mode, taking from inventory \"fuel\"";
local form = "size [6,7] textarea[0,0;6.5,8.5;help;GENERATOR HELP;".. text.."]" local form = "size[6,7]"..
default.gui_bg..
default.gui_bg_img..
default.gui_slots..
"textarea[0,0;6.5,8.5;help;GENERATOR HELP;".. text.."]"
minetest.show_formspec(sender:get_player_name(), "basic_machines:help_mover", form) minetest.show_formspec(sender:get_player_name(), "basic_machines:help_mover", form)
return return
end end

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 239 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 258 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 486 B

After

Width:  |  Height:  |  Size: 350 B