mirror of
https://github.com/tacigar/maidroid.git
synced 2025-01-10 00:00:18 +01:00
[FIX] inner global functions -> local function
This commit is contained in:
parent
9a2376461c
commit
01b6843973
@ -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
|
||||
|
@ -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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user