codestyle: replace inline functions
This commit is contained in:
parent
f8fc111b4a
commit
e3bb7fe4be
|
@ -546,7 +546,7 @@ for _,n in pairs(profession_names) do
|
||||||
table.insert(jobsites,professions[n].jobsite)
|
table.insert(jobsites,professions[n].jobsite)
|
||||||
end
|
end
|
||||||
|
|
||||||
local stand_still = function(self)
|
local function stand_still(self)
|
||||||
self.walk_chance = 0
|
self.walk_chance = 0
|
||||||
self.jump = false
|
self.jump = false
|
||||||
end
|
end
|
||||||
|
@ -636,7 +636,7 @@ local function get_a_job(self)
|
||||||
if self.state ~= "gowp" then look_for_job(self) end
|
if self.state ~= "gowp" then look_for_job(self) end
|
||||||
end
|
end
|
||||||
|
|
||||||
local update_max_tradenum = function(self)
|
local function update_max_tradenum(self)
|
||||||
if not self._trades then
|
if not self._trades then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
@ -651,7 +651,7 @@ local update_max_tradenum = function(self)
|
||||||
self._max_tradenum = #trades
|
self._max_tradenum = #trades
|
||||||
end
|
end
|
||||||
|
|
||||||
local init_trades = function(self, inv)
|
local function init_trades(self, inv)
|
||||||
local profession = professions[self._profession]
|
local profession = professions[self._profession]
|
||||||
local trade_tiers = profession.trades
|
local trade_tiers = profession.trades
|
||||||
if trade_tiers == nil then
|
if trade_tiers == nil then
|
||||||
|
@ -702,7 +702,7 @@ local init_trades = function(self, inv)
|
||||||
minetest.deserialize(self._trades)
|
minetest.deserialize(self._trades)
|
||||||
end
|
end
|
||||||
|
|
||||||
local set_trade = function(trader, player, inv, concrete_tradenum)
|
local function set_trade(trader, player, inv, concrete_tradenum)
|
||||||
local trades = minetest.deserialize(trader._trades)
|
local trades = minetest.deserialize(trader._trades)
|
||||||
if not trades then
|
if not trades then
|
||||||
init_trades(trader)
|
init_trades(trader)
|
||||||
|
@ -801,7 +801,7 @@ local function show_trade_formspec(playername, trader, tradenum)
|
||||||
minetest.show_formspec(playername, tradeinv_name, formspec)
|
minetest.show_formspec(playername, tradeinv_name, formspec)
|
||||||
end
|
end
|
||||||
|
|
||||||
local update_offer = function(inv, player, sound)
|
local function update_offer(inv, player, sound)
|
||||||
local name = player:get_player_name()
|
local name = player:get_player_name()
|
||||||
local trader = player_trading_with[name]
|
local trader = player_trading_with[name]
|
||||||
local tradenum = player_tradenum[name]
|
local tradenum = player_tradenum[name]
|
||||||
|
@ -825,12 +825,12 @@ local update_offer = function(inv, player, sound)
|
||||||
-- compass.
|
-- compass.
|
||||||
-- TODO: Remove these check functions when compass and clock are implemented
|
-- TODO: Remove these check functions when compass and clock are implemented
|
||||||
-- as single items.
|
-- as single items.
|
||||||
local check_special = function(special_item, group, wanted1, wanted2, input1, input2)
|
local function check_special(special_item, group, wanted1, wanted2, input1, input2)
|
||||||
if minetest.registered_aliases[special_item] then
|
if minetest.registered_aliases[special_item] then
|
||||||
special_item = minetest.registered_aliases[special_item]
|
special_item = minetest.registered_aliases[special_item]
|
||||||
end
|
end
|
||||||
if wanted1:get_name() == special_item then
|
if wanted1:get_name() == special_item then
|
||||||
local check_input = function(input, wanted, group)
|
local function check_input(input, wanted, group)
|
||||||
return minetest.get_item_group(input:get_name(), group) ~= 0 and input:get_count() >= wanted:get_count()
|
return minetest.get_item_group(input:get_name(), group) ~= 0 and input:get_count() >= wanted:get_count()
|
||||||
end
|
end
|
||||||
if check_input(input1, wanted1, group) then
|
if check_input(input1, wanted1, group) then
|
||||||
|
@ -845,7 +845,7 @@ local update_offer = function(inv, player, sound)
|
||||||
end
|
end
|
||||||
-- Apply above function to all items which we consider special.
|
-- Apply above function to all items which we consider special.
|
||||||
-- This function succeeds if ANY item check succeeds.
|
-- This function succeeds if ANY item check succeeds.
|
||||||
local check_specials = function(wanted1, wanted2, input1, input2)
|
local function check_specials(wanted1, wanted2, input1, input2)
|
||||||
return check_special(COMPASS, "compass", wanted1, wanted2, input1, input2)
|
return check_special(COMPASS, "compass", wanted1, wanted2, input1, input2)
|
||||||
end
|
end
|
||||||
-- END OF SPECIAL HANDLING OF COMPASS
|
-- END OF SPECIAL HANDLING OF COMPASS
|
||||||
|
@ -899,7 +899,7 @@ local function return_item(itemstack, dropper, pos, inv_p)
|
||||||
return itemstack
|
return itemstack
|
||||||
end
|
end
|
||||||
|
|
||||||
local return_fields = function(player)
|
local function return_fields(player)
|
||||||
local name = player:get_player_name()
|
local name = player:get_player_name()
|
||||||
local inv_t = minetest.get_inventory({type="detached", name = "mobs_mc:trade_"..name})
|
local inv_t = minetest.get_inventory({type="detached", name = "mobs_mc:trade_"..name})
|
||||||
local inv_p = player:get_inventory()
|
local inv_p = player:get_inventory()
|
||||||
|
@ -965,7 +965,7 @@ minetest.register_on_leaveplayer(function(player)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
-- Return true if player is trading with villager, and the villager entity exists
|
-- Return true if player is trading with villager, and the villager entity exists
|
||||||
local trader_exists = function(playername)
|
local function trader_exists(playername)
|
||||||
local trader = player_trading_with[playername]
|
local trader = player_trading_with[playername]
|
||||||
return trader ~= nil and trader.object:get_luaentity() ~= nil
|
return trader ~= nil and trader.object:get_luaentity() ~= nil
|
||||||
end
|
end
|
||||||
|
@ -992,7 +992,7 @@ local trade_inventory = {
|
||||||
wanted1:set_count(wanted1:get_count()*2)
|
wanted1:set_count(wanted1:get_count()*2)
|
||||||
wanted2:set_count(wanted2:get_count()*2)
|
wanted2:set_count(wanted2:get_count()*2)
|
||||||
-- BEGIN OF SPECIAL HANDLING FOR COMPASS
|
-- BEGIN OF SPECIAL HANDLING FOR COMPASS
|
||||||
local special_checks = function(wanted1, input1, input2)
|
local function special_checks(wanted1, input1, input2)
|
||||||
if wanted1:get_name() == COMPASS then
|
if wanted1:get_name() == COMPASS then
|
||||||
local compasses = 0
|
local compasses = 0
|
||||||
if (minetest.get_item_group(input1:get_name(), "compass") ~= 0) then
|
if (minetest.get_item_group(input1:get_name(), "compass") ~= 0) then
|
||||||
|
|
Loading…
Reference in New Issue
Block a user