Small fixes and improvements

master
AndrejIT 2017-05-04 09:31:51 +03:00
parent dc4d466d82
commit 6b0e2be273
12 changed files with 34 additions and 27 deletions

0
LICENSE Normal file → Executable file
View File

0
README.md Normal file → Executable file
View File

61
craft_guide/api_craft_guide.lua Normal file → Executable file
View File

@ -27,7 +27,7 @@ craft_guide.set_stack=function(inv, listname, index, stack)
elseif stack=="group:stick" then
stack="default:stick"
elseif stack=="group:wool" then
stack="default:wool"
stack="wool:white"
elseif stack=="group:dye,basecolor_black" then
stack="default:cobble"
elseif stack=="group:mesecon_conductor_craftable" then
@ -70,14 +70,14 @@ end
-- get_craft_guide_formspec
craft_guide.get_craft_guide_formspec = function(meta, search, page, alternate)
if search == nil then
if search == nil then
search = meta:get_string("search")
end
if page == nil then
page = craft_guide.get_current_page(meta)
if page == nil then
page = craft_guide.get_current_page(meta)
end
if alternate == nil then
alternate = craft_guide.get_current_alternate(meta)
if alternate == nil then
alternate = craft_guide.get_current_alternate(meta)
end
local inv = meta:get_inventory()
local size = inv:get_size("main")
@ -161,13 +161,18 @@ craft_guide.on_receive_fields = function(pos, formname, fields, player)
local pages = math.floor((size-1) / (5*14) + 1)
local search
-- search
search = fields.craft_guide_search_box
meta:set_string("search", search)
if fields.craft_guide_search_button then
page = 1
end
if player and player:is_player() then
minetest.log('action', 'CraftGuide formspec by player '..player:get_player_name())
else
minetest.log('action', 'CraftGuide formspec without player')
end
-- change page
if fields.craft_guide_prev then
@ -226,12 +231,19 @@ craft_guide.update_recipe = function(meta, player, stack, alternate)
craft_guide.set_stack(inv, "fuel", 1, nil)
if stack==nil then return end
if type(stack)=="string" then
craft_guide.log("Request for item by string name :| - "..stack)
end
if stack:get_name()=="" then
craft_guide.log("Request for item with empty name :|")
return
end
craft_guide.set_stack(inv, "output", 1, stack:get_name())
alternate = tonumber(alternate) or 1
craft_guide.log(player:get_player_name().." requests recipe "..alternate.." for "..stack:get_name())
local crafts = craft_guide.crafts[stack:get_name()]
if crafts == nil then
minetest.chat_send_player(player:get_player_name(), "no recipe available for "..stack:get_name())
meta:set_string("formspec",craft_guide.get_craft_guide_formspec(meta))
@ -241,11 +253,11 @@ craft_guide.update_recipe = function(meta, player, stack, alternate)
alternate = 1
end
local craft = crafts[alternate]
-- show me the unknown items
craft_guide.log(dump(craft))
-- craft_guide.log(dump(craft))
--minetest.chat_send_player(player:get_player_name(), "recipe for "..stack:get_name()..": "..dump(craft))
local itemstack = ItemStack(craft.output)
craft_guide.set_stack(inv, "output", 1, itemstack)
@ -376,26 +388,22 @@ end
-- allow_metadata_inventory_move
craft_guide.allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
local meta = minetest.env:get_meta(pos)
local inv = meta:get_inventory()
if to_list == "bin" and from_list == "output" then
if from_list == "output" and to_list == "bin" then
craft_guide.update_recipe(meta, player, inv:get_stack(from_list, from_index))
craft_guide.set_stack(inv, from_list,from_index,nil)
elseif from_list == "output" or to_list == "output" then
craft_guide.update_recipe(meta, player, inv:get_stack(from_list, from_index))
end
if to_list == "bin" and from_list == "bookmark" then
craft_guide.set_stack(inv, from_list,from_index,nil)
end
if to_list == "bookmark" then
craft_guide.set_stack(inv, to_list, to_index, inv:get_stack(from_list, from_index):get_name())
if from_list == "output" then
craft_guide.set_stack(inv, from_list,from_index,nil)
end
end
if to_list == "output" or from_list == "output" then
craft_guide.update_recipe(meta, player, inv:get_stack(from_list, from_index))
end
if from_list == "bookmarks" and to_list == "bookmarks" then
elseif from_list == "bookmarks" and to_list == "bookmarks" then
return count
elseif from_list == "bookmark" and to_list == "bin" then
craft_guide.set_stack(inv, from_list,from_index,nil)
elseif to_list == "bookmark" then
if inv:get_size("from_list") > from_index then
craft_guide.set_stack(inv, to_list, to_index, inv:get_stack(from_list, from_index):get_name())
end
end
return 0
end
@ -411,4 +419,3 @@ end
craft_guide.allow_metadata_inventory_take = function(pos, listname, index, stack, player)
return 0
end

0
craft_guide/depends.txt Normal file → Executable file
View File

0
craft_guide/init.lua Normal file → Executable file
View File

0
craft_guide/register_craft.lua Normal file → Executable file
View File

0
craft_guide/register_node.lua Normal file → Executable file
View File

0
craft_guide/textures/craft_guide_pc_black.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 157 B

After

Width:  |  Height:  |  Size: 157 B

0
craft_guide/textures/craft_guide_pc_grey.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 157 B

After

Width:  |  Height:  |  Size: 157 B

0
craft_guide/textures/craft_guide_pc_screen.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 2.0 KiB

After

Width:  |  Height:  |  Size: 2.0 KiB

0
craft_guide/textures/craft_guide_sign.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 2.2 KiB

After

Width:  |  Height:  |  Size: 2.2 KiB

0
modpack.txt Normal file → Executable file
View File