/clockgen command: requires just privs now
ball: damages entities now, so you can kill mobs for example( except basic_robots) keypad: PROBLEM: if player doesnt move it takes another punch at same block for this function to run again, and it works normally if player moved at least one block from his previous position. it is caused by minetest bad handling of punches.
This commit is contained in:
parent
9a66471390
commit
0bdc55c32c
15
ball.lua
15
ball.lua
@ -182,9 +182,18 @@ minetest.register_entity("basic_machines:ball",{
|
||||
end
|
||||
obj:set_hp(newhp)
|
||||
else -- non player
|
||||
local lua_entity = obj:get_luaentity();
|
||||
if lua_entity and lua_entity.itemstring then
|
||||
local entname = lua_entity.itemstring;
|
||||
if entname == "robot" then
|
||||
self.object:remove()
|
||||
return;
|
||||
end
|
||||
end
|
||||
local hp = obj:get_hp()
|
||||
local newhp = hp-self.hurt;
|
||||
obj:set_hp(newhp)
|
||||
minetest.chat_send_player(self.owner,"#ball: target hp " .. newhp)
|
||||
if newhp<=0 then obj:remove() else obj:set_hp(newhp) end
|
||||
end
|
||||
|
||||
|
||||
@ -536,7 +545,7 @@ minetest.register_node("basic_machines:ball_spawner", {
|
||||
end
|
||||
|
||||
if fields.hp then
|
||||
meta:set_float("hp", math.abs(tonumber(fields.hp)) or 0)
|
||||
meta:set_float("hp", math.abs(tonumber(fields.hp) or 0))
|
||||
end
|
||||
|
||||
if fields.texture then
|
||||
@ -544,7 +553,7 @@ minetest.register_node("basic_machines:ball_spawner", {
|
||||
end
|
||||
|
||||
if fields.scale then
|
||||
local scale = math.abs(tonumber(fields.scale)) or 100;
|
||||
local scale = math.abs(tonumber(fields.scale) or 100);
|
||||
if scale>1000 and not privs.privs then scale = 1000 end
|
||||
meta:set_int("scale", scale)
|
||||
end
|
||||
|
@ -36,7 +36,6 @@ local es_gems = function()
|
||||
end
|
||||
minetest.after(0,es_gems);
|
||||
|
||||
|
||||
|
||||
local grinder_process = function(pos)
|
||||
|
||||
@ -205,7 +204,7 @@ minetest.register_node("basic_machines:grinder", {
|
||||
if fields.help then
|
||||
--recipe list: [in] ={fuel cost, out, quantity of material required for processing}
|
||||
--basic_machines.grinder_recipes
|
||||
text = "RECIPES\n\n";
|
||||
local text = "RECIPES\n\n";
|
||||
for key,v in pairs(basic_machines.grinder_recipes) do
|
||||
text = text .. "INPUT ".. key .. " " .. v[3] .. " OUTPUT " .. v[2] .. "\n"
|
||||
end
|
||||
|
22
mover.lua
22
mover.lua
@ -951,6 +951,7 @@ local function check_keypad(pos,name,ttl) -- called only when manually activated
|
||||
"size[3,1]" .. -- width, height
|
||||
"button_exit[0.,0.5;1,1;OK;OK] field[0.25,0.25;3,1;pass;Enter Password: ;".."".."]";
|
||||
minetest.show_formspec(name, "basic_machines:check_keypad_"..minetest.pos_to_string(pos), form)
|
||||
return
|
||||
|
||||
end
|
||||
|
||||
@ -1292,20 +1293,20 @@ minetest.register_node("basic_machines:detector", {
|
||||
})
|
||||
|
||||
|
||||
minetest.register_chatcommand("clockgen", { -- test: toggle machine running with clockgens
|
||||
minetest.register_chatcommand("clockgen", { -- test: toggle machine running with clockgens, useful for debugging
|
||||
-- i.e. seeing how machines running affect server performance
|
||||
description = "",
|
||||
privs = {
|
||||
interact = true
|
||||
},
|
||||
func = function(name, param)
|
||||
local privs = minetest.get_player_privs(name);
|
||||
if not privs.privs and name~="rnd" then return end
|
||||
if not privs.privs then return end
|
||||
local player = minetest.get_player_by_name(name);
|
||||
if basic_machines.clockgen == 0 then basic_machines.clockgen = 1 else basic_machines.clockgen = 0 end
|
||||
minetest.chat_send_player(name, "#clockgen set to " .. basic_machines.clockgen);
|
||||
end
|
||||
});
|
||||
|
||||
})
|
||||
|
||||
|
||||
-- CLOCK GENERATOR : periodically activates machine on top of it
|
||||
@ -1375,9 +1376,6 @@ local get_distributor_form = function(pos,player)
|
||||
active[i]=meta:get_int("active"..i);
|
||||
end
|
||||
|
||||
-- machines.pos1[player:get_player_name()] = {x=pos.x+x1,y=pos.y+y1,z=pos.z+z1};machines.mark_pos1(player:get_player_name()) -- mark pos1
|
||||
-- machines.pos2[player:get_player_name()] = {x=pos.x+x2,y=pos.y+y2,z=pos.z+z2};machines.mark_pos2(player:get_player_name()) -- mark pos2
|
||||
|
||||
local list_name = "nodemeta:"..pos.x..','..pos.y..','..pos.z
|
||||
local form =
|
||||
"size[7,"..(0.75+(n)*0.75).."]" .. -- width, height
|
||||
@ -1621,6 +1619,9 @@ punchset.known_nodes = {["basic_machines:mover"]=true,["basic_machines:keypad"]=
|
||||
-- SETUP BY PUNCHING
|
||||
minetest.register_on_punchnode(function(pos, node, puncher, pointed_thing)
|
||||
|
||||
-- STRANGE PROBLEM: if player doesnt move it takes another punch at same block for this function to run again, and it works normally if player moved at least one block from his previous position
|
||||
-- it only happens with keypad - maybe caused by formspec displayed..
|
||||
|
||||
local name = puncher:get_player_name(); if name==nil then return end
|
||||
if punchset[name]== nil then -- set up punchstate
|
||||
punchset[name] = {}
|
||||
@ -1639,10 +1640,6 @@ minetest.register_on_punchnode(function(pos, node, puncher, pointed_thing)
|
||||
if node.name~="basic_machines:keypad" then -- keypad is supposed to be punch interactive!
|
||||
if minetest.is_protected(pos, name) then return end
|
||||
end
|
||||
-- local meta = minetest.get_meta(pos);
|
||||
-- if not (meta:get_int("public") == 1) then
|
||||
-- if meta:get_string("owner")~= name then return end
|
||||
-- end
|
||||
end
|
||||
|
||||
if node.name == "basic_machines:mover" then -- mover init code
|
||||
@ -1780,9 +1777,12 @@ minetest.register_on_punchnode(function(pos, node, puncher, pointed_thing)
|
||||
|
||||
-- KEYPAD
|
||||
if node.name == "basic_machines:keypad" then -- keypad init/usage code
|
||||
|
||||
local meta = minetest.get_meta(pos);
|
||||
if not (meta:get_int("x0")==0 and meta:get_int("y0")==0 and meta:get_int("z0")==0) then -- already configured
|
||||
check_keypad(pos,name)-- not setup, just standard operation
|
||||
punchset[name].state = 0;
|
||||
return;
|
||||
else
|
||||
if minetest.is_protected(pos, name) then return minetest.chat_send_player(name, "KEYPAD: You must be able to build to set up keypad.") end
|
||||
--if meta:get_string("owner")~= name then minetest.chat_send_player(name, "KEYPAD: Only owner can set up keypad.") return end
|
||||
|
Loading…
x
Reference in New Issue
Block a user