Get rid of metas on sitting function and more robust rightclick callback
This commit is contained in:
parent
0beedaf539
commit
d2ec545395
21
nodes.lua
21
nodes.lua
@ -1,23 +1,19 @@
|
|||||||
screwdriver = screwdriver or {}
|
screwdriver = screwdriver or {}
|
||||||
|
|
||||||
local function sit(pos, node, clicker)
|
local function sit(pos, node, clicker)
|
||||||
local meta = minetest.get_meta(pos)
|
|
||||||
local player = clicker:get_player_name()
|
local player = clicker:get_player_name()
|
||||||
|
if default.player_attached[player] == true then
|
||||||
if meta:get_string("is_sit") == "yes" then
|
|
||||||
meta:set_string("is_sit", "")
|
|
||||||
pos.y = pos.y - 0.5
|
pos.y = pos.y - 0.5
|
||||||
clicker:setpos(pos)
|
clicker:setpos(pos)
|
||||||
clicker:set_eye_offset({x=0, y=0, z=0}, {x=0, y=0, z=0})
|
clicker:set_eye_offset({x=0, y=0, z=0}, {x=0, y=0, z=0})
|
||||||
clicker:set_physics_override(1, 1, 1)
|
clicker:set_physics_override(1, 1, 1)
|
||||||
default.player_attached[player] = false
|
default.player_attached[player] = false
|
||||||
default.player_set_animation(clicker, "stand", 30)
|
default.player_set_animation(clicker, "stand", 30)
|
||||||
elseif meta:get_string("is_sit") == "" and
|
elseif default.player_attached[player] ~= true and
|
||||||
clicker:get_player_velocity().x == 0 and
|
clicker:get_player_velocity().x == 0 and
|
||||||
clicker:get_player_velocity().y == 0 and
|
clicker:get_player_velocity().y == 0 and
|
||||||
clicker:get_player_velocity().z == 0 then
|
clicker:get_player_velocity().z == 0 then
|
||||||
|
|
||||||
meta:set_string("is_sit", "yes")
|
|
||||||
clicker:set_eye_offset({x=0, y=-7, z=2}, {x=0, y=0, z=0})
|
clicker:set_eye_offset({x=0, y=-7, z=2}, {x=0, y=0, z=0})
|
||||||
clicker:set_physics_override(0, 0, 0)
|
clicker:set_physics_override(0, 0, 0)
|
||||||
clicker:setpos(pos)
|
clicker:setpos(pos)
|
||||||
@ -69,8 +65,7 @@ xdecor.register("barrel", {
|
|||||||
infotext = "Barrel",
|
infotext = "Barrel",
|
||||||
tiles = {"xdecor_barrel_top.png", "xdecor_barrel_sides.png"},
|
tiles = {"xdecor_barrel_top.png", "xdecor_barrel_sides.png"},
|
||||||
groups = {choppy=3, flammable=3},
|
groups = {choppy=3, flammable=3},
|
||||||
sounds = default.node_sound_wood_defaults(),
|
sounds = default.node_sound_wood_defaults()
|
||||||
on_rotate = screwdriver.rotate_simple
|
|
||||||
})
|
})
|
||||||
|
|
||||||
xdecor.register("cabinet", {
|
xdecor.register("cabinet", {
|
||||||
@ -193,14 +188,13 @@ xdecor.register("chair", {
|
|||||||
on_rightclick = function(pos, node, clicker)
|
on_rightclick = function(pos, node, clicker)
|
||||||
local objs = minetest.get_objects_inside_radius(pos, 0.5)
|
local objs = minetest.get_objects_inside_radius(pos, 0.5)
|
||||||
for _, p in pairs(objs) do
|
for _, p in pairs(objs) do
|
||||||
if p:get_player_name() ~= nil or node.param2 > 3 or not
|
if p:get_player_name() ~= clicker:get_player_name() or
|
||||||
clicker or not clicker:is_player() then return end
|
node.param2 > 3 then return end
|
||||||
end
|
end
|
||||||
pos.y = pos.y + 0
|
pos.y = pos.y + 0
|
||||||
sit(pos, node, clicker)
|
sit(pos, node, clicker)
|
||||||
end,
|
end,
|
||||||
can_dig = function(pos, player)
|
can_dig = function(pos, player)
|
||||||
local meta = minetest.get_meta(pos)
|
|
||||||
local pname = player:get_player_name()
|
local pname = player:get_player_name()
|
||||||
local objs = minetest.get_objects_inside_radius(pos, 0.5)
|
local objs = minetest.get_objects_inside_radius(pos, 0.5)
|
||||||
|
|
||||||
@ -281,14 +275,13 @@ xdecor.register("cushion", {
|
|||||||
on_rightclick = function(pos, node, clicker)
|
on_rightclick = function(pos, node, clicker)
|
||||||
local objs = minetest.get_objects_inside_radius(pos, 0.5)
|
local objs = minetest.get_objects_inside_radius(pos, 0.5)
|
||||||
for _, p in pairs(objs) do
|
for _, p in pairs(objs) do
|
||||||
if p:get_player_name() ~= nil or node.param2 > 3 or not
|
if p:get_player_name() ~= clicker:get_player_name() or
|
||||||
clicker or not clicker:is_player() then return end
|
node.param2 > 3 then return end
|
||||||
end
|
end
|
||||||
pos.y = pos.y + 0
|
pos.y = pos.y + 0
|
||||||
sit(pos, node, clicker)
|
sit(pos, node, clicker)
|
||||||
end,
|
end,
|
||||||
can_dig = function(pos, player)
|
can_dig = function(pos, player)
|
||||||
local meta = minetest.get_meta(pos)
|
|
||||||
local pname = player:get_player_name()
|
local pname = player:get_player_name()
|
||||||
local objs = minetest.get_objects_inside_radius(pos, 0.5)
|
local objs = minetest.get_objects_inside_radius(pos, 0.5)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user