[FIX] inner global functions -> local function

This commit is contained in:
tacigar 2016-09-14 20:25:33 +09:00
parent 9a2376461c
commit 01b6843973
2 changed files with 14 additions and 14 deletions

View File

@ -165,7 +165,7 @@ function maidroid.register_maidroid(product_name, def)
end end
-- create_inventory creates a new inventory, and returns it. -- 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) self.inventory_name = self.product_name .. tostring(self.manufacturing_number)
local inventory = minetest.create_detached_inventory(self.inventory_name, { local inventory = minetest.create_detached_inventory(self.inventory_name, {
on_put = function(inv, listname, index, stack, player) on_put = function(inv, listname, index, stack, player)
@ -202,7 +202,7 @@ function maidroid.register_maidroid(product_name, def)
end end
-- create_formspec_string returns a string that represents a formspec definition. -- 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]" return "size[8,9]"
.. "list[detached:"..self.inventory_name..";main;0,0;4,4;]" .. "list[detached:"..self.inventory_name..";main;0,0;4,4;]"
.. "label[5,0;core]" .. "label[5,0;core]"
@ -212,7 +212,7 @@ function maidroid.register_maidroid(product_name, def)
end end
-- on_activate is a callback function that is called when the object is created or recreated. -- 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. -- parse the staticdata, and compose a inventory.
if staticdata == "" then if staticdata == "" then
self.product_name = product_name self.product_name = product_name
@ -256,7 +256,7 @@ function maidroid.register_maidroid(product_name, def)
end end
-- get_staticdata is a callback function that is called when the object is destroyed. -- 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 inventory = self:get_inventory()
local data = { local data = {
["product_name"] = self.product_name, ["product_name"] = self.product_name,
@ -279,7 +279,7 @@ function maidroid.register_maidroid(product_name, def)
end end
-- on_step is a callback function that is called every delta times. -- 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 if (not self.pause) and self.core_name ~= "" then
local core = maidroid.registered_cores[self.core_name] local core = maidroid.registered_cores[self.core_name]
core.on_step(self, dtime) core.on_step(self, dtime)
@ -287,7 +287,7 @@ function maidroid.register_maidroid(product_name, def)
end end
-- on_rightclick is a callback function that is called when a player right-click them. -- 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( minetest.show_formspec(
clicker:get_player_name(), clicker:get_player_name(),
self.inventory_name, self.inventory_name,
@ -296,7 +296,7 @@ function maidroid.register_maidroid(product_name, def)
end end
-- on_punch is a callback function that is called when a player punch then. -- 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 if self.pause == true then
self.pause = false self.pause = false
if self.core_name ~= "" then if self.core_name ~= "" then

View File

@ -17,7 +17,7 @@
}, },
} }
function can_dig(pos, player) local function can_dig(pos, player)
local meta = minetest.get_meta(pos) local meta = minetest.get_meta(pos)
local inventory = meta:get_inventory() local inventory = meta:get_inventory()
return ( return (
@ -27,7 +27,7 @@
) )
end 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 meta = minetest.get_meta(pos)
local inventory = meta:get_inventory() local inventory = meta:get_inventory()
local itemname = stack:get_name() local itemname = stack:get_name()
@ -42,7 +42,7 @@
return 0 return 0
end 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 meta = minetest.get_meta(pos)
local inventory = meta:get_inventory() local inventory = meta:get_inventory()
local stack = inventory:get_stack(from_list, from_index) 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,5;8,1;]"
.. "list[current_player;main;0,6.2;8,3;8]" .. "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) local meta = minetest.get_meta(pos)
meta:set_string("formspec", formspec_string) meta:set_string("formspec", formspec_string)
@ -76,11 +76,11 @@
inventory:set_size("dye", 1) inventory:set_size("dye", 1)
end end
function on_metadata_inventory_move(pos) local function on_metadata_inventory_move(pos)
end 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. return stack:get_count() -- maybe add more.
end 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. return stack:get_count() -- maybe add more.
end end