Compare commits

...

9 Commits

Author SHA1 Message Date
Juraj Vajda c7f0feb86d Merge https://repo.or.cz/minetest_easyvend into develop 2018-10-13 19:19:42 -04:00
Juraj Vajda 000d66769b Merge branch 'master' into develop 2018-10-13 19:18:37 -04:00
Wuzzy 9aca0379b7 Update select_item handling 2018-05-17 15:18:19 +02:00
Wuzzy fa14d27191 Rewrite msgs for tools 2018-05-15 02:57:51 +02:00
Wuzzy 1997fcde9a Fix typos 2018-05-15 01:37:53 +02:00
Juraj Vajda 592ea7996f replace deprecated functions 2017-12-10 18:04:33 -05:00
Juraj Vajda efe49d481c merge easyvend repository 2017-12-10 17:57:36 -05:00
Juraj Vajda db5512ba18 resolving conflicts and merge wuzzy branch 2016-12-25 10:33:14 -05:00
Juraj Vajda d32b48b241 fix crashing when no awards mod installed 2016-12-04 11:05:44 +01:00
4 changed files with 31 additions and 29 deletions

4
API.md
View File

@ -5,7 +5,7 @@ depositing machines.
## How it works
* Add `easyvend` as optional dependency
* Check for existance of `easyvend` mod in code
* Check for existence of `easyvend` mod in code
* Call `easyvend.register_chest` for all containers you want to be compatible
## `easyvend.register_chest = function(node_name, inv_list, meta_owner)`
@ -33,5 +33,5 @@ if minetest.get_modpath("easyvend") then
end
```
The `if` check is a common trick to check for the existance of the `easyvend`
The `if` check is a common trick to check for the existence of the `easyvend`
and allows you to make the dependency optional.

View File

@ -26,7 +26,7 @@ Vending machines TAKE currency (gold ingots by default) and GIVE items
of the owner's choice.
Depositing machines GIVE currency and TAKE items of the owner's choice.
To operatre your own machine, place a locked chest above or below and fill
To operate your own machine, place a locked chest above or below and fill
it with items to exchange. If the green status LED (the upper one) lights
up, the machine is operational. You can stack these locked chests for
extended storage.

View File

@ -24,32 +24,34 @@ end
if minetest.get_modpath("select_item") then
-- When player selects item via "select item" dialog, switch the
-- machine's selected item and update the formspec.
select_item.register_on_select_item(function(playername, itemstring)
local player = minetest.get_player_by_name(playername)
if not player then
return
end
local pos = active_item_selection[playername]
if pos then
local node = minetest.get_node(pos)
if not easyvend.is_machine(node.name) then
select_item.register_on_select_item(function(playername, dialogname, itemstring)
if dialogname == "easyvend:trade_item" then
local player = minetest.get_player_by_name(playername)
if not player then
return
end
local meta = minetest.get_meta(pos)
local owner = meta:get_string("owner")
if playername == owner then
local inv = meta:get_inventory()
local stack = ItemStack(itemstring)
if stack == nil then
inv:set_stack( "item", 1, nil )
else
inv:set_stack( "item", 1, stack)
meta:set_string("itemname", itemstring)
easyvend.set_formspec(pos, player)
local pos = active_item_selection[playername]
if pos then
local node = minetest.get_node(pos)
if not easyvend.is_machine(node.name) then
return
end
local meta = minetest.get_meta(pos)
local owner = meta:get_string("owner")
if playername == owner then
local inv = meta:get_inventory()
local stack = ItemStack(itemstring)
if stack == nil then
inv:set_stack( "item", 1, nil )
else
inv:set_stack( "item", 1, stack)
meta:set_string("itemname", itemstring)
easyvend.set_formspec(pos, player)
end
end
end
active_item_selection[playername] = nil
end
active_item_selection[playername] = nil
end)
end
@ -229,9 +231,9 @@ easyvend.set_formspec = function(pos, player)
end
else
if buysell == "sell" then
weartext = "Warning: Might sell worn tools."
weartext = "Note: Might sell worn tools."
else
weartext = "Worn tools are bought, too."
weartext = "Accepts worn tools."
end
end
if weartext ~= nil then
@ -1001,7 +1003,7 @@ easyvend.on_receive_fields = function(pos, formname, fields, sender)
if minetest.get_modpath("select_item") then
if sendername == owner then
active_item_selection[sendername] = pos
select_item.show_dialog(sendername, select_item.filters.creative)
select_item.show_dialog(sendername, "easyvend:trade_item", select_item.filters.creative)
else
meta:set_string("message", "Only the owner may change the configuration.")
easyvend.sound_error(sendername)
@ -1281,7 +1283,7 @@ minetest.register_abm({
-- Transform the world and items to use the easyvend nodes/items
-- For safety reasons, only do this when player requested so
if minetest.setting_getbool("easyvend_convert_vendor") == true then
if minetest.settings:get_bool("easyvend_convert_vendor") == true then
-- Replace vendor nodes
minetest.register_lbm({
name = "easyvend:replace_vendor",

View File

@ -25,7 +25,7 @@ easyvend.VERSION.PATCH = 3
easyvend.VERSION.STRING = easyvend.VERSION.MAJOR .. "." .. easyvend.VERSION.MINOR .. "." .. easyvend.VERSION.PATCH
-- Set item which is used as payment for vending and depositing machines
easyvend.currency = minetest.setting_get("easyvend_currency")
easyvend.currency = minetest.settings:get("easyvend_currency")
if easyvend.currency == nil or minetest.registered_items[easyvend.currency] == nil then
-- Default currency
easyvend.currency = "default:gold_ingot"