mirror of
https://github.com/minetest-mods/mesecons.git
synced 2025-03-28 06:50:29 +01:00
Replace several get_meta calls with a variable.
This commit is contained in:
parent
12aac53339
commit
72b022778b
@ -85,13 +85,15 @@ function mesecon.register_movestone(name, def, is_sticky)
|
|||||||
|
|
||||||
-- ### Step 2: Move the movestone ###
|
-- ### Step 2: Move the movestone ###
|
||||||
local node = minetest.get_node(pos)
|
local node = minetest.get_node(pos)
|
||||||
local owner = minetest.get_meta(pos):get_string("owner")
|
local meta = minetest.get_meta(pos)
|
||||||
|
local owner = meta:get_string("owner")
|
||||||
minetest.set_node(frontpos, node)
|
minetest.set_node(frontpos, node)
|
||||||
|
local frontmeta = minetest.get_meta(frontpos)
|
||||||
minetest.remove_node(pos)
|
minetest.remove_node(pos)
|
||||||
mesecon.on_dignode(pos, node)
|
mesecon.on_dignode(pos, node)
|
||||||
mesecon.on_placenode(frontpos, node)
|
mesecon.on_placenode(frontpos, node)
|
||||||
minetest.get_meta(frontpos):set_string("owner", owner)
|
frontmeta:set_string("owner", owner)
|
||||||
minetest.get_meta(frontpos):set_string("infotext", "Movestone (owned by "..owner..")")
|
frontmeta:set_string("infotext", "Movestone (owned by "..owner..")")
|
||||||
minetest.after(timer_interval, movestone_move, frontpos)
|
minetest.after(timer_interval, movestone_move, frontpos)
|
||||||
|
|
||||||
-- ### Step 3: If sticky, pull stack behind ###
|
-- ### Step 3: If sticky, pull stack behind ###
|
||||||
@ -128,8 +130,9 @@ mesecon.register_movestone("mesecons_movestones:movestone", {
|
|||||||
description="Movestone",
|
description="Movestone",
|
||||||
sounds = default.node_sound_stone_defaults(),
|
sounds = default.node_sound_stone_defaults(),
|
||||||
after_place_node = function(pos, player)
|
after_place_node = function(pos, player)
|
||||||
minetest.get_meta(pos):set_string("owner", player:get_player_name())
|
local meta = minetest.get_meta(pos)
|
||||||
minetest.get_meta(pos):set_string("infotext", "Movestone (owned by "..player:get_player_name()..")")
|
meta:set_string("owner", player:get_player_name())
|
||||||
|
meta:set_string("infotext", "Movestone (owned by "..player:get_player_name()..")")
|
||||||
end,
|
end,
|
||||||
}, false)
|
}, false)
|
||||||
|
|
||||||
@ -150,8 +153,9 @@ mesecon.register_movestone("mesecons_movestones:sticky_movestone", {
|
|||||||
description="Sticky Movestone",
|
description="Sticky Movestone",
|
||||||
sounds = default.node_sound_stone_defaults(),
|
sounds = default.node_sound_stone_defaults(),
|
||||||
after_place_node = function(pos, player)
|
after_place_node = function(pos, player)
|
||||||
minetest.get_meta(pos):set_string("owner", player:get_player_name())
|
local meta = minetest.get_meta(pos)
|
||||||
minetest.get_meta(pos):set_string("infotext", "Movestone (owned by "..player:get_player_name()..")")
|
meta:set_string("owner", player:get_player_name())
|
||||||
|
meta:set_string("infotext", "Movestone (owned by "..player:get_player_name()..")")
|
||||||
end,
|
end,
|
||||||
}, true)
|
}, true)
|
||||||
|
|
||||||
|
@ -152,8 +152,9 @@ end
|
|||||||
-- maximum: maximum nodes to be pushed
|
-- maximum: maximum nodes to be pushed
|
||||||
-- all_pull_sticky: All nodes are sticky in the direction that they are pulled from
|
-- all_pull_sticky: All nodes are sticky in the direction that they are pulled from
|
||||||
function mesecon.mvps_push_or_pull(from, ispulling, pos, stackdir, movedir, maximum, all_pull_sticky)
|
function mesecon.mvps_push_or_pull(from, ispulling, pos, stackdir, movedir, maximum, all_pull_sticky)
|
||||||
|
local frommeta = minetest.get_meta(from)
|
||||||
local has_meta = minetest.get_meta(from):to_table()
|
local has_meta = minetest.get_meta(from):to_table()
|
||||||
local owner = minetest.get_meta(from):get_string("owner")
|
local owner = frommeta:get_string("owner")
|
||||||
local tnodes = mesecon.mvps_get_stack(pos, movedir, maximum, all_pull_sticky)
|
local tnodes = mesecon.mvps_get_stack(pos, movedir, maximum, all_pull_sticky)
|
||||||
if not tnodes then return end
|
if not tnodes then return end
|
||||||
-- determine if one of the nodes blocks the push / pull
|
-- determine if one of the nodes blocks the push / pull
|
||||||
|
@ -112,8 +112,10 @@ local piston_orientate = function(pos, placer)
|
|||||||
-- not placed by player
|
-- not placed by player
|
||||||
if not placer then return end
|
if not placer then return end
|
||||||
|
|
||||||
minetest.get_meta(pos):set_string("owner", placer:get_player_name())
|
local meta = minetest.get_meta(pos)
|
||||||
minetest.get_meta(pos):set_string("infotext", "Piston (owned by "..placer:get_player_name()..")")
|
|
||||||
|
meta:set_string("owner", placer:get_player_name())
|
||||||
|
meta:set_string("infotext", "Piston (owned by "..placer:get_player_name()..")")
|
||||||
|
|
||||||
-- placer pitch in degrees
|
-- placer pitch in degrees
|
||||||
local pitch = placer:get_look_pitch() * (180 / math.pi)
|
local pitch = placer:get_look_pitch() * (180 / math.pi)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user