From 01b684397317a0d48786a7a2665a95c14bc9d909 Mon Sep 17 00:00:00 2001 From: tacigar Date: Wed, 14 Sep 2016 20:25:33 +0900 Subject: [PATCH] [FIX] inner global functions -> local function --- maidroid/api.lua | 14 +++++++------- maidroid_tool/core_writer.lua | 14 +++++++------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/maidroid/api.lua b/maidroid/api.lua index 9813bd5..77d0424 100644 --- a/maidroid/api.lua +++ b/maidroid/api.lua @@ -165,7 +165,7 @@ function maidroid.register_maidroid(product_name, def) end -- create_inventory creates a new inventory, and returns it. - function create_inventory(self) + local function create_inventory(self) self.inventory_name = self.product_name .. tostring(self.manufacturing_number) local inventory = minetest.create_detached_inventory(self.inventory_name, { on_put = function(inv, listname, index, stack, player) @@ -202,7 +202,7 @@ function maidroid.register_maidroid(product_name, def) end -- create_formspec_string returns a string that represents a formspec definition. - function create_formspec_string(self) + local function create_formspec_string(self) return "size[8,9]" .. "list[detached:"..self.inventory_name..";main;0,0;4,4;]" .. "label[5,0;core]" @@ -212,7 +212,7 @@ function maidroid.register_maidroid(product_name, def) end -- on_activate is a callback function that is called when the object is created or recreated. - function on_activate(self, staticdata) + local function on_activate(self, staticdata) -- parse the staticdata, and compose a inventory. if staticdata == "" then self.product_name = product_name @@ -256,7 +256,7 @@ function maidroid.register_maidroid(product_name, def) end -- get_staticdata is a callback function that is called when the object is destroyed. - function get_staticdata(self) + local function get_staticdata(self) local inventory = self:get_inventory() local data = { ["product_name"] = self.product_name, @@ -279,7 +279,7 @@ function maidroid.register_maidroid(product_name, def) end -- on_step is a callback function that is called every delta times. - function on_step(self, dtime) + local function on_step(self, dtime) if (not self.pause) and self.core_name ~= "" then local core = maidroid.registered_cores[self.core_name] core.on_step(self, dtime) @@ -287,7 +287,7 @@ function maidroid.register_maidroid(product_name, def) end -- on_rightclick is a callback function that is called when a player right-click them. - function on_rightclick(self, clicker) + local function on_rightclick(self, clicker) minetest.show_formspec( clicker:get_player_name(), self.inventory_name, @@ -296,7 +296,7 @@ function maidroid.register_maidroid(product_name, def) end -- on_punch is a callback function that is called when a player punch then. - function on_punch(self, puncher, time_from_last_punch, tool_capabilities, dir) + local function on_punch(self, puncher, time_from_last_punch, tool_capabilities, dir) if self.pause == true then self.pause = false if self.core_name ~= "" then diff --git a/maidroid_tool/core_writer.lua b/maidroid_tool/core_writer.lua index d36d35b..1901b1f 100644 --- a/maidroid_tool/core_writer.lua +++ b/maidroid_tool/core_writer.lua @@ -17,7 +17,7 @@ }, } - function can_dig(pos, player) + local function can_dig(pos, player) local meta = minetest.get_meta(pos) local inventory = meta:get_inventory() return ( @@ -27,7 +27,7 @@ ) end - function allow_metadata_inventory_put(pos, listname, index, stack, player) + local function allow_metadata_inventory_put(pos, listname, index, stack, player) local meta = minetest.get_meta(pos) local inventory = meta:get_inventory() local itemname = stack:get_name() @@ -42,7 +42,7 @@ return 0 end - function allow_metadata_inventory_move(pos, from_list, from_index, to_list, to_index, count, player) + local function allow_metadata_inventory_move(pos, from_list, from_index, to_list, to_index, count, player) local meta = minetest.get_meta(pos) local inventory = meta:get_inventory() local stack = inventory:get_stack(from_list, from_index) @@ -66,7 +66,7 @@ .. "list[current_player;main;0,5;8,1;]" .. "list[current_player;main;0,6.2;8,3;8]" - function on_construct(pos) + local function on_construct(pos) local meta = minetest.get_meta(pos) meta:set_string("formspec", formspec_string) @@ -76,11 +76,11 @@ inventory:set_size("dye", 1) end - function on_metadata_inventory_move(pos) + local function on_metadata_inventory_move(pos) end - function allow_metadata_inventory_take(pos, listname, index, stack, player) + local function allow_metadata_inventory_take(pos, listname, index, stack, player) return stack:get_count() -- maybe add more. end @@ -125,7 +125,7 @@ }, } - function allow_metadata_inventory_take(pos, listname, index, stack, player) + local function allow_metadata_inventory_take(pos, listname, index, stack, player) return stack:get_count() -- maybe add more. end