Update 3d_armor, replace mcl_inventory with craftingpack
31
mods/craftingpack/README.txt
Normal file
|
@ -0,0 +1,31 @@
|
|||
Minetest mod "Crafting"
|
||||
=======================
|
||||
version: 2.0.1
|
||||
|
||||
License of source code and Textures: WTFPL
|
||||
------------------------------------
|
||||
Copyright (c) 2013-2014 BlockMen
|
||||
|
||||
This program is free software. It comes without any warranty, to
|
||||
the extent permitted by applicable law. You can redistribute it
|
||||
and/or modify it under the terms of the Do What The Fuck You Want
|
||||
To Public License, Version 2, as published by Sam Hocevar. See
|
||||
http://sam.zoy.org/wtfpl/COPYING for more details.
|
||||
|
||||
|
||||
--USING the mod--
|
||||
=================
|
||||
This mod changes the players inventory (survival and creative) with more slots (9*4 instead of 8*4)
|
||||
Like known from Minecraft you have a 2x2 crafting grid at inventory now. Furthermore a categorized creative
|
||||
inventory and a support for stu's 3d armor mod (To use the armor and a preview of player).
|
||||
|
||||
Left items in the crafting slots are dropped infront of you.
|
||||
|
||||
Workbench
|
||||
=========
|
||||
With following recipe you craft a workbench (aka crafting table):
|
||||
|
||||
wood wood
|
||||
wood wood
|
||||
|
||||
The workbench has a 3x3 crafting grid, that allows to use all recipes.
|
34
mods/craftingpack/crafting/README.txt
Normal file
|
@ -0,0 +1,34 @@
|
|||
Minetest mod "Crafting"
|
||||
=======================
|
||||
Version: 2.0.1
|
||||
|
||||
License of source code and Textures: WTFPL
|
||||
------------------------------------
|
||||
copyright (c) 2013-2014 by BlockMen
|
||||
|
||||
This program is free software. It comes without any warranty, to
|
||||
the extent permitted by applicable law. You can redistribute it
|
||||
and/or modify it under the terms of the Do What The Fuck You Want
|
||||
To Public License, Version 2, as published by Sam Hocevar. See
|
||||
http://sam.zoy.org/wtfpl/COPYING for more details.
|
||||
|
||||
|
||||
--USING the mod--
|
||||
=================
|
||||
|
||||
This mod changes the players inventory (survival and creative) with more slots (9*4 instead of 8*4)
|
||||
Like known from Minecraft you have a 2x2 crafting grid at inventory now. Furthermore a categorized creative
|
||||
inventory and a support for stu's 3d armor mod (To use the armor and a preview of player).
|
||||
|
||||
Left items in the crafting slots are dropped infront of you.
|
||||
|
||||
|
||||
Workbench
|
||||
_________
|
||||
|
||||
With following recipe you craft a workbench (aka crafting table):
|
||||
|
||||
wood wood
|
||||
wood wood
|
||||
|
||||
The workbench has a 3x3 crafting grid, that allows to use all recipes.
|
BIN
mods/craftingpack/crafting/crafting_inventory.png
Normal file
After Width: | Height: | Size: 4.5 KiB |
BIN
mods/craftingpack/crafting/crafting_inventory_armor.png
Normal file
After Width: | Height: | Size: 1.3 KiB |
343
mods/craftingpack/crafting/creative.lua
Normal file
|
@ -0,0 +1,343 @@
|
|||
crafting = {}
|
||||
crafting.creative_inventory_size = 0
|
||||
|
||||
function init()
|
||||
local inv = minetest.create_detached_inventory("creative", {
|
||||
allow_move = function(inv, from_list, from_index, to_list, to_index, count, player)
|
||||
if minetest.setting_getbool("creative_mode") then
|
||||
return count
|
||||
else
|
||||
return 0
|
||||
end
|
||||
end,
|
||||
allow_put = function(inv, listname, index, stack, player)
|
||||
return 0
|
||||
end,
|
||||
allow_take = function(inv, listname, index, stack, player)
|
||||
if minetest.setting_getbool("creative_mode") then
|
||||
return -1
|
||||
else
|
||||
return 0
|
||||
end
|
||||
end,
|
||||
on_move = function(inv, from_list, from_index, to_list, to_index, count, player)
|
||||
end,
|
||||
on_put = function(inv, listname, index, stack, player)
|
||||
end,
|
||||
on_take = function(inv, listname, index, stack, player)
|
||||
print(player:get_player_name().." takes item from creative inventory; listname="..dump(listname)..", index="..dump(index)..", stack="..dump(stack))
|
||||
if stack then
|
||||
print("stack:get_name()="..dump(stack:get_name())..", stack:get_count()="..dump(stack:get_count()))
|
||||
end
|
||||
end,
|
||||
})
|
||||
set_inv("all")
|
||||
end
|
||||
|
||||
function set_inv(filter, player)
|
||||
local inv = minetest.get_inventory({type="detached", name="creative"})
|
||||
inv:set_size("main", 0)
|
||||
local creative_list = {}
|
||||
for name,def in pairs(minetest.registered_items) do
|
||||
if (not def.groups.not_in_creative_inventory or def.groups.not_in_creative_inventory == 0) and def.description and def.description ~= "" then
|
||||
if filter ~= "" then
|
||||
if filter == "#blocks" then
|
||||
if def.walkable == true then
|
||||
table.insert(creative_list, name)
|
||||
end
|
||||
elseif filter == "#deco" then
|
||||
if def.walkable == false or def.drawtype == "plantlike" or def.drawtype == "allfaces_optional" then--def.groups. == true then
|
||||
table.insert(creative_list, name)
|
||||
end
|
||||
elseif filter == "#mese" then
|
||||
if string.find(string.lower(def.name), "mese") or string.find(string.lower(def.description), "mese") then
|
||||
table.insert(creative_list, name)
|
||||
end
|
||||
elseif filter == "#rail" then
|
||||
if string.find(string.lower(def.name), "rail") or string.find(string.lower(def.description), "rail") or string.find(string.lower(def.name), "cart") or string.find(string.lower(def.description), "cart") or string.find(string.lower(def.description), "boat") then
|
||||
table.insert(creative_list, name)
|
||||
end
|
||||
elseif filter == "#misc" then
|
||||
if def.drawtype == nil and def.tool_capabilities == nil and not string.find(string.lower(def.description), "ingot") and not string.find(string.lower(def.description), "lump") and not string.find(string.lower(def.description), "dye") and not string.find(string.lower(def.name), "diamond") and not string.find(string.lower(def.name), "mese") and not string.find(string.lower(def.name), "obsidian") and not string.find(string.lower(def.description), "clay") then
|
||||
table.insert(creative_list, name)
|
||||
end
|
||||
elseif filter == "#food" then
|
||||
if def.groups.food ~= nil or string.find(string.lower(def.description), "apple") or string.find(string.lower(def.description), "bread") then
|
||||
table.insert(creative_list, name)
|
||||
end
|
||||
elseif filter == "#tools" then
|
||||
if def.tool_capabilities ~= nil and not string.find(string.lower(def.description), "sword") then
|
||||
table.insert(creative_list, name)
|
||||
end
|
||||
elseif filter == "#combat" then
|
||||
if def.tool_capabilities ~= nil and (string.find(string.lower(def.description), "sword") or string.find(string.lower(def.name), "armor") or string.find(string.lower(def.description), "bow") or string.find(string.lower(def.description), "arrow")) or string.find(string.lower(def.name), "armor") then
|
||||
table.insert(creative_list, name)
|
||||
end
|
||||
elseif filter == "#matr" then
|
||||
if def.drawtype == nil and def.tool_capabilities == nil and (string.find(string.lower(def.description), "ingot") or string.find(string.lower(def.description), "lump") or string.find(string.lower(def.description), "dye") or string.find(string.lower(def.name), "diamond") or string.find(string.lower(def.name), "mese") or string.find(string.lower(def.name), "obsidian") or string.find(string.lower(def.description), "clay") or string.find(string.lower(def.description), "stick") or string.find(string.lower(def.description), "flint") or string.find(string.lower(def.description), "seed")) then
|
||||
table.insert(creative_list, name)
|
||||
end
|
||||
elseif filter == "all" then
|
||||
table.insert(creative_list, name)
|
||||
else --for all other
|
||||
if string.find(string.lower(def.name), filter) or string.find(string.lower(def.description), filter) then
|
||||
table.insert(creative_list, name)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
table.sort(creative_list)
|
||||
inv:set_size("main", #creative_list)
|
||||
for _,itemstring in ipairs(creative_list) do
|
||||
inv:add_item("main", ItemStack(itemstring))
|
||||
end
|
||||
crafting.creative_inventory_size = #creative_list
|
||||
--print("creative inventory size: "..dump(crafting.creative_inventory_size))
|
||||
end
|
||||
|
||||
-- Create the trash field
|
||||
local trash = minetest.create_detached_inventory("creative_trash", {
|
||||
allow_put = function(inv, listname, index, stack, player)
|
||||
if minetest.setting_getbool("creative_mode") then
|
||||
return stack:get_count()
|
||||
else
|
||||
return 0
|
||||
end
|
||||
end,
|
||||
on_put = function(inv, listname, index, stack, player)
|
||||
inv:set_stack(listname, index, "")
|
||||
end,
|
||||
})
|
||||
trash:set_size("main", 1)
|
||||
|
||||
|
||||
-- Create detached creative inventory after loading all mods
|
||||
minetest.after(0, init)
|
||||
|
||||
local offset = {}
|
||||
local hoch = {}
|
||||
local bg = {}
|
||||
offset["blocks"] = "-0.29,-0.25"
|
||||
offset["deco"] = "0.98,-0.25"
|
||||
offset["mese"] = "2.23,-0.25"
|
||||
offset["rail"] = "3.495,-0.25"
|
||||
offset["misc"] = "4.75,-0.25"
|
||||
offset["nix"] = "8.99,-0.25"
|
||||
offset["food"] = "-0.29,8.12"
|
||||
offset["tools"] = "0.98,8.12"
|
||||
offset["combat"] = "2.23,8.12"
|
||||
offset["brew"] = "3.495,8.12"
|
||||
offset["matr"] = offset["brew"]--"4.74,8.12"
|
||||
offset["inv"] = "8.99,8.12"
|
||||
|
||||
hoch["blocks"] = ""
|
||||
hoch["deco"] = ""
|
||||
hoch["mese"] = ""
|
||||
hoch["rail"] = ""
|
||||
hoch["misc"] = ""
|
||||
hoch["nix"] = ""
|
||||
hoch["food"] = "^[transformfy"
|
||||
hoch["tools"] = "^[transformfy"
|
||||
hoch["combat"] = "^[transformfy"
|
||||
hoch["brew"] = "^[transformfy"
|
||||
hoch["matr"] = "^[transformfy"
|
||||
hoch["inv"] = "^[transformfy"
|
||||
|
||||
local dark_bg = "crafting_creative_bg_dark.png"
|
||||
|
||||
local function reset_menu_item_bg()
|
||||
bg["blocks"] = dark_bg
|
||||
bg["deco"] = dark_bg
|
||||
bg["mese"] = dark_bg
|
||||
bg["rail"] = dark_bg
|
||||
bg["misc"] = dark_bg
|
||||
bg["nix"] = dark_bg
|
||||
bg["food"] = dark_bg
|
||||
bg["tools"] = dark_bg
|
||||
bg["combat"] = dark_bg
|
||||
bg["brew"] = dark_bg
|
||||
bg["matr"] = dark_bg
|
||||
bg["inv"] = dark_bg
|
||||
end
|
||||
|
||||
|
||||
crafting.set_creative_formspec = function(player, start_i, pagenum, show, page)
|
||||
reset_menu_item_bg()
|
||||
pagenum = math.floor(pagenum) or 1
|
||||
local pagemax = math.floor((crafting.creative_inventory_size-1) / (9*5) + 1)
|
||||
local slider_height = 4/pagemax
|
||||
local slider_pos = slider_height*(pagenum-1)+2.25
|
||||
local name = "nix"
|
||||
local formspec = ""
|
||||
local main_list = "list[detached:creative;main;0,1.75;9,5;"..tostring(start_i).."]"
|
||||
if page ~= nil then name = page end
|
||||
bg[name] = "crafting_creative_bg.png"
|
||||
if name == "inv" then
|
||||
main_list = "image[-0.2,1.7;11.35,2.33;crafting_creative_bg.png]"..
|
||||
"list[current_player;main;0,3.75;9,3;9]"
|
||||
end
|
||||
formspec = "size[10,9.3]"..
|
||||
"background[-0.19,-0.25;10.5,9.87;crafting_inventory_creative.png]"..
|
||||
"bgcolor[#080808BB;true]"..
|
||||
"listcolors[#9990;#FFF7;#FFF0;#160816;#D4D2FF]"..
|
||||
"label[-5,-5;"..name.."]"..
|
||||
"image[" .. offset[name] .. ";1.5,1.44;crafting_creative_active.png"..hoch[name].."]"..
|
||||
"image_button[-0.1,0;1,1;"..bg["blocks"].."^crafting_creative_build.png;build;]".. --build blocks
|
||||
"image_button[1.15,0;1,1;"..bg["deco"].."^crafting_creative_deko.png;deco;]".. --decoration blocks
|
||||
"image_button[2.415,0;1,1;"..bg["mese"].."^crafting_creative_mese.png;mese;]".. --redstone
|
||||
"image_button[3.693,0;1,1;"..bg["rail"].."^crafting_creative_rail.png;rail;]".. --transportation
|
||||
"image_button[4.93,0;1,1;"..bg["misc"].."^crafting_creative_misc.png;misc;]".. --miscellaneous
|
||||
"image_button[9.19,0;1,1;"..bg["nix"].."^crafting_creative_all.png;default;]".. --search
|
||||
"image[0,1;5,0.75;fnt_"..name..".png]"..
|
||||
"list[current_player;main;0,7;9,1;]"..
|
||||
main_list..
|
||||
"image_button[9.03,1.74;0.85,0.6;crafting_creative_up.png;creative_prev;]"..
|
||||
"image[9.04," .. tostring(slider_pos) .. ";0.75,"..tostring(slider_height) .. ";crafting_slider.png]"..
|
||||
"image_button[9.03,6.15;0.85,0.6;crafting_creative_down.png;creative_next;]"..
|
||||
"image_button[-0.1,8.28;1,1;"..bg["food"].."^crafting_food.png;food;]".. --foodstuff
|
||||
"image_button[1.15,8.28;1,1;"..bg["tools"].."^crafting_creative_tool.png;tools;]".. --tools
|
||||
"image_button[2.415,8.28;1,1;"..bg["combat"].."^crafting_creative_sword.png;combat;]".. --combat
|
||||
"image_button[3.693,8.28;1,1;"..bg["matr"].."^crafting_creative_matr.png;matr;]".. --brewing
|
||||
--"image_button[4.93,8.28;1,1;"..bg["brew"].."^crafting_creative_matr.png;matr;]".. --materials^
|
||||
"image_button[9.19,8.28;1,1;"..bg["inv"].."^crafting_creative_inv.png;inv;]".. --inventory
|
||||
"list[detached:creative_trash;main;9,7;1,1;]"..
|
||||
"image[9,7;1,1;crafting_creative_trash.png]"
|
||||
|
||||
if name == "nix" then formspec = formspec .. "field[5.3,1.3;4,0.75;suche;;]" end
|
||||
if pagenum ~= nil then formspec = formspec .. "p"..tostring(pagenum) end
|
||||
|
||||
player:set_inventory_formspec(formspec)
|
||||
end
|
||||
|
||||
minetest.register_on_player_receive_fields(function(player, formname, fields)
|
||||
local page = nil
|
||||
if not minetest.setting_getbool("creative_mode") then
|
||||
return
|
||||
end
|
||||
|
||||
if fields.bgcolor then
|
||||
minetest.chat_send_all("jupp")
|
||||
end
|
||||
if fields.suche ~= nil and fields.suche ~= "" then
|
||||
set_inv(string.lower(fields.suche))
|
||||
minetest.after(0.5, function()
|
||||
minetest.show_formspec(player:get_player_name(), "detached:creative", player:get_inventory_formspec())
|
||||
end)
|
||||
end
|
||||
|
||||
if fields.build then
|
||||
set_inv("#blocks",player)
|
||||
page = "blocks"
|
||||
end
|
||||
if fields.deco then
|
||||
set_inv("#deco",player)
|
||||
page = "deco"
|
||||
end
|
||||
if fields.mese then
|
||||
set_inv("#mese",player)
|
||||
page = "mese"
|
||||
end
|
||||
if fields.rail then
|
||||
set_inv("#rail",player)
|
||||
page = "rail"
|
||||
end
|
||||
if fields.misc then
|
||||
set_inv("#misc",player)
|
||||
page = "misc"
|
||||
end
|
||||
if fields.default then
|
||||
set_inv("all")
|
||||
page = nil
|
||||
end
|
||||
if fields.food then
|
||||
set_inv("#food")
|
||||
page = "food"
|
||||
end
|
||||
if fields.tools then
|
||||
set_inv("#tools")
|
||||
page = "tools"
|
||||
end
|
||||
if fields.combat then
|
||||
set_inv("#combat")
|
||||
page = "combat"
|
||||
end
|
||||
if fields.matr then
|
||||
set_inv("#matr")
|
||||
page = "matr"
|
||||
end
|
||||
if fields.inv then
|
||||
page = "inv"
|
||||
end
|
||||
-- Figure out current page from formspec
|
||||
local current_page = 0
|
||||
local formspec = player:get_inventory_formspec()
|
||||
|
||||
local size = string.len(formspec)
|
||||
local marker = string.sub(formspec,size-2)
|
||||
marker = string.sub(marker,1)
|
||||
if marker ~= nil and marker == "p" then
|
||||
local page = string.sub(formspec,size-1)
|
||||
--minetest.chat_send_all(page)
|
||||
start_i = page
|
||||
end
|
||||
start_i = tonumber(start_i) or 0
|
||||
if fields.creative_prev then
|
||||
start_i = start_i - 9*5
|
||||
page = tmp_page
|
||||
end
|
||||
if fields.creative_next then
|
||||
start_i = start_i + 9*5
|
||||
page = tmp_page
|
||||
end
|
||||
if start_i < 0 then
|
||||
start_i = start_i + 9*5
|
||||
end
|
||||
if start_i >= crafting.creative_inventory_size then
|
||||
start_i = start_i - 9*5
|
||||
end
|
||||
if start_i < 0 or start_i >= crafting.creative_inventory_size then
|
||||
start_i = 0
|
||||
end
|
||||
crafting.set_creative_formspec(player, start_i, start_i / (9*5) + 1, false, page)
|
||||
end)
|
||||
|
||||
|
||||
if minetest.setting_getbool("creative_mode") then
|
||||
minetest.register_item(":", {
|
||||
type = "none",
|
||||
wield_image = "wieldhand.png",
|
||||
wield_scale = {x=1,y=1,z=2.5},
|
||||
tool_capabilities = {
|
||||
full_punch_interval = 0.5,
|
||||
max_drop_level = 3,
|
||||
groupcaps = {
|
||||
crumbly = {times={[1]=0.5, [2]=0.5, [3]=0.5}, uses=0, maxlevel=3},
|
||||
cracky = {times={[1]=0.5, [2]=0.5, [3]=0.5}, uses=0, maxlevel=3},
|
||||
snappy = {times={[1]=0.5, [2]=0.5, [3]=0.5}, uses=0, maxlevel=3},
|
||||
choppy = {times={[1]=0.5, [2]=0.5, [3]=0.5}, uses=0, maxlevel=3},
|
||||
oddly_breakable_by_hand = {times={[1]=0.5, [2]=0.5, [3]=0.5}, uses=0, maxlevel=3},
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_on_placenode(function(pos, newnode, placer, oldnode, itemstack)
|
||||
return true
|
||||
end)
|
||||
|
||||
function minetest.handle_node_drops(pos, drops, digger)
|
||||
if not digger or not digger:is_player() then
|
||||
return
|
||||
end
|
||||
local inv = digger:get_inventory()
|
||||
if inv then
|
||||
for _,item in ipairs(drops) do
|
||||
item = ItemStack(item):get_name()
|
||||
if not inv:contains_item("main", item) then
|
||||
inv:add_item("main", item)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
1
mods/craftingpack/crafting/depends.txt
Normal file
|
@ -0,0 +1 @@
|
|||
default
|
79
mods/craftingpack/crafting/formspecs.lua
Normal file
|
@ -0,0 +1,79 @@
|
|||
default.furnace_inactive_formspec =
|
||||
"size[9,8.75]"..
|
||||
"background[-0.19,-0.25;9.41,9.49;crafting_formspec_bg.png^crafting_inventory_furnace.png]"..
|
||||
"bgcolor[#080808BB;true]"..
|
||||
"listcolors[#9990;#FFF7;#FFF0;#160816;#D4D2FF]"..
|
||||
"list[current_player;main;0,4.5;9,3;9]"..
|
||||
"list[current_player;main;0,7.74;9,1;]"..
|
||||
"list[current_name;src;2.75,0.5;1,1;]"..
|
||||
"list[current_name;fuel;2.75,2.5;1,1;]"..
|
||||
"list[current_name;dst;5.75,1.5;1,1;]"..
|
||||
"image[2.75,1.5;1,1;crafting_furnace_fire_bg.png"
|
||||
|
||||
function default.get_furnace_active_formspec(pos, percent)
|
||||
local formspec =
|
||||
"size[9,8.75]"..
|
||||
"background[-0.19,-0.25;9.41,9.49;crafting_formspec_bg.png^crafting_inventory_furnace.png]"..
|
||||
"bgcolor[#080808BB;true]"..
|
||||
"listcolors[#9990;#FFF7;#FFF0;#160816;#D4D2FF]"..
|
||||
"list[current_player;main;0,4.5;9,3;9]"..
|
||||
"list[current_player;main;0,7.74;9,1;]"..
|
||||
"list[current_name;src;2.75,0.5;1,1;]"..
|
||||
"list[current_name;fuel;2.75,2.5;1,1;]"..
|
||||
"list[current_name;dst;5.75,1.5;1,1;]"..
|
||||
"image[2.75,1.5;1,1;crafting_furnace_fire_bg.png^[lowpart:"..
|
||||
(100-percent)..":default_furnace_fire_fg.png]"
|
||||
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
inv:set_size("dst",1)
|
||||
|
||||
return formspec
|
||||
end
|
||||
|
||||
default.chest_formspec =
|
||||
"size[9,9.75]"..
|
||||
"background[-0.19,-0.25;9.41,10.48;crafting_inventory_chest.png]"..
|
||||
"bgcolor[#080808BB;true]"..
|
||||
"listcolors[#9990;#FFF7;#FFF0;#160816;#D4D2FF]"..
|
||||
"list[current_name;main;0,0.5;9,4;]"..
|
||||
"list[current_player;main;0,5.5;9,3;9]"..
|
||||
"list[current_player;main;0,8.74;9,1;]"
|
||||
|
||||
local chest_inv_size = 4*9
|
||||
local chest_inv_vers = 2
|
||||
|
||||
function default.get_locked_chest_formspec(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv_v = meta:get_int("chest_inv_ver")
|
||||
if inv_v and inv_v < chest_inv_vers then
|
||||
local inv = meta:get_inventory()
|
||||
inv:set_size("main",chest_inv_size)
|
||||
meta:set_int("chest_inv_ver",chest_inv_vers)
|
||||
end
|
||||
local spos = pos.x .. "," .. pos.y .. "," ..pos.z
|
||||
local formspec =
|
||||
"size[9,9.75]"..
|
||||
"background[-0.19,-0.25;9.41,10.48;crafting_inventory_chest.png]"..
|
||||
"bgcolor[#080808BB;true]"..
|
||||
"listcolors[#9990;#FFF7;#FFF0;#160816;#D4D2FF]"..
|
||||
"list[nodemeta:".. spos .. ";main;0,0.5;9,4;]"..
|
||||
"list[current_player;main;0,5.5;9,3;9]"..
|
||||
"list[current_player;main;0,8.74;9,1;]"
|
||||
return formspec
|
||||
end
|
||||
|
||||
minetest.register_abm({
|
||||
nodenames = {"default:chest"},
|
||||
interval = 1,
|
||||
chance = 1,
|
||||
action = function(pos, node)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv_v = meta:get_int("chest_inv_ver")
|
||||
if inv_v and inv_v < chest_inv_vers then
|
||||
local inv = meta:get_inventory()
|
||||
inv:set_size("main",chest_inv_size)
|
||||
meta:set_int("chest_inv_ver",chest_inv_vers)
|
||||
end
|
||||
end
|
||||
})
|
196
mods/craftingpack/crafting/init.lua
Normal file
|
@ -0,0 +1,196 @@
|
|||
dofile(minetest.get_modpath("crafting").."/formspecs.lua")
|
||||
|
||||
local show_armor = false
|
||||
if minetest.get_modpath("3d_armor") ~= nil then show_armor = true end
|
||||
|
||||
local function item_drop(itemstack, dropper, pos)
|
||||
if dropper:is_player() then
|
||||
local v = dropper:get_look_dir()
|
||||
local p = {x=pos.x, y=pos.y+1.2, z=pos.z}
|
||||
p.x = p.x+(math.random(1,3)*0.2)
|
||||
p.z = p.z+(math.random(1,3)*0.2)
|
||||
local obj = minetest.env:add_item(p, itemstack)
|
||||
if obj then
|
||||
v.x = v.x*4
|
||||
v.y = v.y*4 + 2
|
||||
v.z = v.z*4
|
||||
obj:setvelocity(v)
|
||||
end
|
||||
else
|
||||
minetest.add_item(pos, itemstack)
|
||||
end
|
||||
return itemstack
|
||||
end
|
||||
|
||||
local function drop_fields(player, name)
|
||||
local inv = player:get_inventory()
|
||||
for i,stack in ipairs(inv:get_list(name)) do
|
||||
item_drop(stack, player, player:getpos())
|
||||
stack:clear()
|
||||
inv:set_stack(name, i, stack)
|
||||
end
|
||||
end
|
||||
|
||||
local player_armor = {}
|
||||
|
||||
local function update_armor(player)
|
||||
local out = ""
|
||||
if not player then return end
|
||||
local name = player:get_player_name()
|
||||
if not armor or not armor.textures then return end
|
||||
local armor_str = armor.textures[name].armor
|
||||
if string.find(armor_str, "leggings") then
|
||||
out = out .. "^crafting_armor_legs.png"
|
||||
end
|
||||
if string.find(armor_str, "boots") then
|
||||
out = out .. "^crafting_armor_boots.png"
|
||||
end
|
||||
if string.find(armor_str, "helmet") then
|
||||
out = out .. "^crafting_armor_helmet.png"
|
||||
end
|
||||
if string.find(armor_str, "chestplate") then
|
||||
out = out .. "^crafting_armor_chest.png"
|
||||
end
|
||||
player_armor[name] = out
|
||||
end
|
||||
|
||||
local function set_inventory(player)
|
||||
if minetest.setting_getbool("creative_mode") then
|
||||
minetest.after(0.5,function()
|
||||
crafting.set_creative_formspec(player, 0, 1)
|
||||
return
|
||||
end)
|
||||
end
|
||||
player:get_inventory():set_width("craft", 3)
|
||||
player:get_inventory():set_size("craft", 9)
|
||||
player:get_inventory():set_size("main", 9*4)
|
||||
|
||||
local player_name = player:get_player_name()
|
||||
local img = "crafting_inventory_player.png"
|
||||
local armor_img = ""
|
||||
if show_armor then
|
||||
armor_img = "^crafting_inventory_armor.png"
|
||||
if player_armor[player_name] ~= nil then
|
||||
img = img .. player_armor[player_name]
|
||||
end
|
||||
end
|
||||
local img_element = "image[1,0;3,4;"..img.."]"
|
||||
if show_armor and armor.textures[player_name] and armor.textures[player_name].preview then
|
||||
img = armor.textures[player_name].preview
|
||||
local s1 = img:find("character_preview")
|
||||
if s1 ~= nil then
|
||||
s1 = img:sub(s1+21)
|
||||
img = "crafting_player2d.png"..s1
|
||||
end
|
||||
img_element = "image[1.5,0;2,4;"..img.."]"
|
||||
end
|
||||
|
||||
local form = "size[9,8.75]"..
|
||||
"background[-0.19,-0.25;9.41,9.49;crafting_formspec_bg.png^crafting_inventory.png"..armor_img.."]"..
|
||||
"bgcolor[#080808BB;true]"..
|
||||
"listcolors[#9990;#FFF7;#FFF0;#160816;#D4D2FF]"..
|
||||
img_element
|
||||
--armor
|
||||
if show_armor then
|
||||
if armor.def[player_name] and armor.def[player_name].level then
|
||||
form = form ..
|
||||
"list[detached:"..player_name.."_armor;armor;0,0;1,1;1]"..
|
||||
"list[detached:"..player_name.."_armor;armor;0,1;1,1;2]"..
|
||||
"list[detached:"..player_name.."_armor;armor;0,2;1,1;3]"..
|
||||
"list[detached:"..player_name.."_armor;armor;0,3;1,1;4]"
|
||||
else
|
||||
form = form ..
|
||||
"list[detached:"..player_name.."_armor;armor_head;0,0;1,1;]"..
|
||||
"list[detached:"..player_name.."_armor;armor_torso;0,1;1,1;]"..
|
||||
"list[detached:"..player_name.."_armor;armor_legs;0,2;1,1;]"..
|
||||
"list[detached:"..player_name.."_armor;armor_feet;0,3;1,1;]"
|
||||
end
|
||||
end
|
||||
form = form ..
|
||||
"list[current_player;main;0,4.5;9,3;9]"..
|
||||
"list[current_player;main;0,7.74;9,1;]"..
|
||||
"list[current_player;craft;4,1;2,1;1]"..
|
||||
"list[current_player;craft;4,2;2,1;4]"..
|
||||
"list[current_player;craftpreview;7,1.5;1,1;]"..
|
||||
"inv"
|
||||
|
||||
player:set_inventory_formspec(form)
|
||||
end
|
||||
|
||||
local function set_workbench(player)
|
||||
player:get_inventory():set_width("craft", 3)
|
||||
player:get_inventory():set_size("craft", 9)
|
||||
player:get_inventory():set_size("main", 9*4)
|
||||
|
||||
local form = "size[9,8.75]"..
|
||||
"background[-0.19,-0.25;9.41,9.49;crafting_formspec_bg.png^crafting_inventory_workbench.png]"..
|
||||
"bgcolor[#080808BB;true]"..
|
||||
"listcolors[#9990;#FFF7;#FFF0;#160816;#D4D2FF]"..
|
||||
"list[current_player;main;0,4.5;9,3;9]"..
|
||||
"list[current_player;main;0,7.74;9,1;]"..
|
||||
"list[current_player;craft;1.75,0.5;3,3;]"..
|
||||
"list[current_player;craftpreview;5.75,1.5;1,1;]"..
|
||||
"wob"
|
||||
|
||||
--player:set_inventory_formspec(form)
|
||||
minetest.show_formspec(player:get_player_name(), "main", form)
|
||||
end
|
||||
|
||||
--drop craf items and reset inventory on closing
|
||||
minetest.register_on_player_receive_fields(function(player, formname, fields)
|
||||
if fields.quit then
|
||||
local formspec = player:get_inventory_formspec()
|
||||
local size = string.len(formspec)
|
||||
local marker = string.sub(formspec,size-2)
|
||||
if marker == "inv" or marker == "wob" then
|
||||
set_inventory(player)
|
||||
drop_fields(player,"craft")
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
minetest.register_on_joinplayer(function(player)
|
||||
if minetest.setting_getbool("creative_mode") then
|
||||
dofile(minetest.get_modpath("crafting").."/creative.lua")
|
||||
end
|
||||
--init inventory
|
||||
set_inventory(player)
|
||||
--set hotbar size
|
||||
if player.hud_set_hotbar_itemcount then
|
||||
minetest.after(0.5, player.hud_set_hotbar_itemcount, player, 9)
|
||||
end
|
||||
--add hotbar images
|
||||
minetest.after(0.5,function()
|
||||
player:hud_set_hotbar_image("crafting_hotbar.png")
|
||||
player:hud_set_hotbar_selected_image("crafting_hotbar_selected.png")
|
||||
|
||||
if show_armor then
|
||||
local armor_orginal = armor.set_player_armor
|
||||
armor.set_player_armor = function(self, player)
|
||||
armor_orginal(self, player)
|
||||
update_armor(player)
|
||||
set_inventory(player)
|
||||
end
|
||||
end
|
||||
end)
|
||||
end)
|
||||
|
||||
minetest.register_node("crafting:workbench", {
|
||||
description = "Workbench",
|
||||
tiles = {"crafting_workbench_top.png", "default_wood.png", "crafting_workbench_side.png",
|
||||
"crafting_workbench_side.png", "crafting_workbench_front.png", "crafting_workbench_front.png"},
|
||||
paramtype2 = "facedir",
|
||||
paramtype = "light",
|
||||
groups = {choppy=2,oddly_breakable_by_hand=2,flammable=2},
|
||||
on_rightclick = function(pos, node, clicker, itemstack)
|
||||
set_workbench(clicker)
|
||||
end
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "crafting:workbench",
|
||||
recipe = {
|
||||
{"group:wood", "group:wood"},
|
||||
{"group:wood", "group:wood"}
|
||||
}
|
||||
})
|
BIN
mods/craftingpack/crafting/textures/crafting_armor_boots.png
Normal file
After Width: | Height: | Size: 2.8 KiB |
BIN
mods/craftingpack/crafting/textures/crafting_armor_chest.png
Normal file
After Width: | Height: | Size: 2.7 KiB |
BIN
mods/craftingpack/crafting/textures/crafting_armor_helmet.png
Normal file
After Width: | Height: | Size: 2.6 KiB |
BIN
mods/craftingpack/crafting/textures/crafting_armor_legs.png
Normal file
After Width: | Height: | Size: 2.8 KiB |
BIN
mods/craftingpack/crafting/textures/crafting_creative_active.png
Normal file
After Width: | Height: | Size: 397 B |
BIN
mods/craftingpack/crafting/textures/crafting_creative_all.png
Normal file
After Width: | Height: | Size: 806 B |
BIN
mods/craftingpack/crafting/textures/crafting_creative_bg.png
Normal file
After Width: | Height: | Size: 340 B |
After Width: | Height: | Size: 228 B |
BIN
mods/craftingpack/crafting/textures/crafting_creative_build.png
Normal file
After Width: | Height: | Size: 7.8 KiB |
BIN
mods/craftingpack/crafting/textures/crafting_creative_deko.png
Normal file
After Width: | Height: | Size: 2.1 KiB |
BIN
mods/craftingpack/crafting/textures/crafting_creative_down.png
Normal file
After Width: | Height: | Size: 870 B |
BIN
mods/craftingpack/crafting/textures/crafting_creative_inv.png
Normal file
After Width: | Height: | Size: 8.1 KiB |
BIN
mods/craftingpack/crafting/textures/crafting_creative_matr.png
Normal file
After Width: | Height: | Size: 1.1 KiB |
BIN
mods/craftingpack/crafting/textures/crafting_creative_mese.png
Normal file
After Width: | Height: | Size: 6.6 KiB |
BIN
mods/craftingpack/crafting/textures/crafting_creative_misc.png
Normal file
After Width: | Height: | Size: 370 B |
BIN
mods/craftingpack/crafting/textures/crafting_creative_rail.png
Normal file
After Width: | Height: | Size: 3.4 KiB |
BIN
mods/craftingpack/crafting/textures/crafting_creative_sword.png
Normal file
After Width: | Height: | Size: 406 B |
BIN
mods/craftingpack/crafting/textures/crafting_creative_tool.png
Normal file
After Width: | Height: | Size: 382 B |
BIN
mods/craftingpack/crafting/textures/crafting_creative_trash.png
Normal file
After Width: | Height: | Size: 400 B |
BIN
mods/craftingpack/crafting/textures/crafting_creative_up.png
Normal file
After Width: | Height: | Size: 1.1 KiB |
BIN
mods/craftingpack/crafting/textures/crafting_food.png
Normal file
After Width: | Height: | Size: 408 B |
BIN
mods/craftingpack/crafting/textures/crafting_formspec_bg.png
Normal file
After Width: | Height: | Size: 25 KiB |
BIN
mods/craftingpack/crafting/textures/crafting_formspec_bg2.png
Normal file
After Width: | Height: | Size: 8.5 KiB |
BIN
mods/craftingpack/crafting/textures/crafting_furnace_fire_bg.png
Normal file
After Width: | Height: | Size: 233 B |
After Width: | Height: | Size: 372 B |
BIN
mods/craftingpack/crafting/textures/crafting_hotbar.png
Normal file
After Width: | Height: | Size: 483 B |
BIN
mods/craftingpack/crafting/textures/crafting_hotbar_selected.png
Normal file
After Width: | Height: | Size: 462 B |
BIN
mods/craftingpack/crafting/textures/crafting_inventory.png
Normal file
After Width: | Height: | Size: 1.5 KiB |
BIN
mods/craftingpack/crafting/textures/crafting_inventory_armor.png
Normal file
After Width: | Height: | Size: 1 KiB |
BIN
mods/craftingpack/crafting/textures/crafting_inventory_chest.png
Normal file
After Width: | Height: | Size: 13 KiB |
After Width: | Height: | Size: 20 KiB |
After Width: | Height: | Size: 22 KiB |
After Width: | Height: | Size: 22 KiB |
After Width: | Height: | Size: 15 KiB |
After Width: | Height: | Size: 24 KiB |
BIN
mods/craftingpack/crafting/textures/crafting_player2d.png
Normal file
After Width: | Height: | Size: 5.2 KiB |
BIN
mods/craftingpack/crafting/textures/crafting_slider.png
Normal file
After Width: | Height: | Size: 134 B |
BIN
mods/craftingpack/crafting/textures/crafting_workbench_front.png
Normal file
After Width: | Height: | Size: 801 B |
BIN
mods/craftingpack/crafting/textures/crafting_workbench_side.png
Normal file
After Width: | Height: | Size: 768 B |
BIN
mods/craftingpack/crafting/textures/crafting_workbench_top.png
Normal file
After Width: | Height: | Size: 1,012 B |
BIN
mods/craftingpack/crafting/textures/fnt_blocks.png
Normal file
After Width: | Height: | Size: 844 B |
BIN
mods/craftingpack/crafting/textures/fnt_combat.png
Normal file
After Width: | Height: | Size: 524 B |
BIN
mods/craftingpack/crafting/textures/fnt_deco.png
Normal file
After Width: | Height: | Size: 947 B |
BIN
mods/craftingpack/crafting/textures/fnt_food.png
Normal file
After Width: | Height: | Size: 658 B |
BIN
mods/craftingpack/crafting/textures/fnt_inv.png
Normal file
After Width: | Height: | Size: 895 B |
BIN
mods/craftingpack/crafting/textures/fnt_matr.png
Normal file
After Width: | Height: | Size: 576 B |
BIN
mods/craftingpack/crafting/textures/fnt_mese.png
Normal file
After Width: | Height: | Size: 459 B |
BIN
mods/craftingpack/crafting/textures/fnt_misc.png
Normal file
After Width: | Height: | Size: 744 B |
BIN
mods/craftingpack/crafting/textures/fnt_nix.png
Normal file
After Width: | Height: | Size: 751 B |
BIN
mods/craftingpack/crafting/textures/fnt_rail.png
Normal file
After Width: | Height: | Size: 859 B |
BIN
mods/craftingpack/crafting/textures/fnt_tools.png
Normal file
After Width: | Height: | Size: 487 B |
1
mods/craftingpack/creative/depends.txt
Normal file
|
@ -0,0 +1 @@
|
|||
default
|
9
mods/craftingpack/creative/init.lua
Normal file
|
@ -0,0 +1,9 @@
|
|||
creative = {}
|
||||
|
||||
creative.set_creative_formspec = function()
|
||||
|
||||
end
|
||||
|
||||
minetest.register_on_player_receive_fields(function(player, formname, fields)
|
||||
|
||||
end)
|
2
mods/craftingpack/inventory_plus/depends.txt
Normal file
|
@ -0,0 +1,2 @@
|
|||
default
|
||||
crafting
|
7
mods/craftingpack/inventory_plus/init.lua
Normal file
|
@ -0,0 +1,7 @@
|
|||
inventory_plus = {}
|
||||
|
||||
function inventory_plus.set_inventory_formspec(player, formspec)
|
||||
end
|
||||
|
||||
function inventory_plus.register_button(player,str1, str2)
|
||||
end
|