From 72b022778b75b4d3f197a791f70112221f29cf7c Mon Sep 17 00:00:00 2001 From: Beha Date: Fri, 24 Feb 2017 10:13:43 -0500 Subject: [PATCH] Replace several get_meta calls with a variable. --- mesecons_movestones/init.lua | 18 +++++++++++------- mesecons_mvps/init.lua | 3 ++- mesecons_pistons/init.lua | 6 ++++-- 3 files changed, 17 insertions(+), 10 deletions(-) diff --git a/mesecons_movestones/init.lua b/mesecons_movestones/init.lua index 76ca317..6bd1c37 100644 --- a/mesecons_movestones/init.lua +++ b/mesecons_movestones/init.lua @@ -85,13 +85,15 @@ function mesecon.register_movestone(name, def, is_sticky) -- ### Step 2: Move the movestone ### 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) + local frontmeta = minetest.get_meta(frontpos) minetest.remove_node(pos) mesecon.on_dignode(pos, node) mesecon.on_placenode(frontpos, node) - minetest.get_meta(frontpos):set_string("owner", owner) - minetest.get_meta(frontpos):set_string("infotext", "Movestone (owned by "..owner..")") + frontmeta:set_string("owner", owner) + frontmeta:set_string("infotext", "Movestone (owned by "..owner..")") minetest.after(timer_interval, movestone_move, frontpos) -- ### Step 3: If sticky, pull stack behind ### @@ -128,8 +130,9 @@ mesecon.register_movestone("mesecons_movestones:movestone", { description="Movestone", sounds = default.node_sound_stone_defaults(), after_place_node = function(pos, player) - minetest.get_meta(pos):set_string("owner", player:get_player_name()) - minetest.get_meta(pos):set_string("infotext", "Movestone (owned by "..player:get_player_name()..")") + local meta = minetest.get_meta(pos) + meta:set_string("owner", player:get_player_name()) + meta:set_string("infotext", "Movestone (owned by "..player:get_player_name()..")") end, }, false) @@ -150,8 +153,9 @@ mesecon.register_movestone("mesecons_movestones:sticky_movestone", { description="Sticky Movestone", sounds = default.node_sound_stone_defaults(), after_place_node = function(pos, player) - minetest.get_meta(pos):set_string("owner", player:get_player_name()) - minetest.get_meta(pos):set_string("infotext", "Movestone (owned by "..player:get_player_name()..")") + local meta = minetest.get_meta(pos) + meta:set_string("owner", player:get_player_name()) + meta:set_string("infotext", "Movestone (owned by "..player:get_player_name()..")") end, }, true) diff --git a/mesecons_mvps/init.lua b/mesecons_mvps/init.lua index b7008ed..d8e8579 100644 --- a/mesecons_mvps/init.lua +++ b/mesecons_mvps/init.lua @@ -152,8 +152,9 @@ end -- maximum: maximum nodes to be pushed -- 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) + local frommeta = minetest.get_meta(from) 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) if not tnodes then return end -- determine if one of the nodes blocks the push / pull diff --git a/mesecons_pistons/init.lua b/mesecons_pistons/init.lua index f1565d7..f2259cb 100644 --- a/mesecons_pistons/init.lua +++ b/mesecons_pistons/init.lua @@ -112,8 +112,10 @@ local piston_orientate = function(pos, placer) -- not placed by player if not placer then return end - minetest.get_meta(pos):set_string("owner", placer:get_player_name()) - minetest.get_meta(pos):set_string("infotext", "Piston (owned by "..placer:get_player_name()..")") + local meta = minetest.get_meta(pos) + + meta:set_string("owner", placer:get_player_name()) + meta:set_string("infotext", "Piston (owned by "..placer:get_player_name()..")") -- placer pitch in degrees local pitch = placer:get_look_pitch() * (180 / math.pi)