Use sfinv, wip
@ -24,6 +24,26 @@ end
|
||||
|
||||
local time = 0
|
||||
|
||||
sfinv.override_page("sfinv:crafting", {
|
||||
title = "Crafting",
|
||||
get = function(self, player, context)
|
||||
local player_name = player:get_player_name();
|
||||
local form = [[
|
||||
listcolors[#9990;#FFF7;#FFF0;#160816;#D4D2FF]
|
||||
list[current_player;craft;4,1;2,1;1]
|
||||
list[current_player;craft;4,2;2,1;4]
|
||||
list[current_player;craftpreview;7.05,1.54;1,1;]
|
||||
list[detached:split;main;7.99,3.15;1,1;]
|
||||
image[1.5,0;2,4;default_player2d.png]
|
||||
]] ..
|
||||
"list[detached:"..player_name.."_armor;armor;0,0;1,1;]"..
|
||||
"list[detached:"..player_name.."_armor;armor;0,1;1,1;1]"..
|
||||
"list[detached:"..player_name.."_armor;armor;0,2;1,1;2]"..
|
||||
"list[detached:"..player_name.."_armor;armor;0,3;1,1;3]"
|
||||
return sfinv.make_formspec(player, context, form , true)
|
||||
end,
|
||||
})
|
||||
|
||||
armor = {
|
||||
player_hp = {},
|
||||
elements = {"head", "torso", "legs", "feet"},
|
||||
|
@ -1 +1,2 @@
|
||||
default
|
||||
default
|
||||
sfinv
|
||||
|
@ -1,34 +0,0 @@
|
||||
MultiCraft 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.
|
@ -1,358 +0,0 @@
|
||||
crafting = {}
|
||||
crafting.creative_inventory_size = 0
|
||||
crafting.start_is = {}
|
||||
crafting.pages = {}
|
||||
|
||||
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 minetest.registered_items[def.name]
|
||||
and minetest.registered_items[def.name].groups
|
||||
and minetest.registered_items[def.name].groups.building
|
||||
then
|
||||
table.insert(creative_list, name)
|
||||
end
|
||||
elseif filter == "#deco" then
|
||||
if minetest.registered_items[def.name]
|
||||
and minetest.registered_items[def.name].groups
|
||||
and minetest.registered_items[def.name].groups.decorative
|
||||
then
|
||||
table.insert(creative_list, name)
|
||||
end
|
||||
elseif filter == "#mese" then
|
||||
if minetest.registered_items[def.name]
|
||||
and minetest.registered_items[def.name].groups
|
||||
and minetest.registered_items[def.name].groups.mese
|
||||
then
|
||||
table.insert(creative_list, name)
|
||||
end
|
||||
elseif filter == "#rail" then
|
||||
if minetest.registered_items[def.name]
|
||||
and minetest.registered_items[def.name].groups
|
||||
and minetest.registered_items[def.name].groups.rail
|
||||
then
|
||||
table.insert(creative_list, name)
|
||||
end
|
||||
elseif filter == "#misc" then
|
||||
if minetest.registered_items[def.name]
|
||||
and minetest.registered_items[def.name].groups
|
||||
and minetest.registered_items[def.name].groups.misc
|
||||
then
|
||||
table.insert(creative_list, name)
|
||||
end
|
||||
elseif filter == "#food" then
|
||||
if minetest.registered_items[def.name]
|
||||
and minetest.registered_items[def.name].groups
|
||||
and minetest.registered_items[def.name].groups.foodstuffs
|
||||
then
|
||||
table.insert(creative_list, name)
|
||||
end
|
||||
elseif filter == "#tools" then
|
||||
if minetest.registered_items[def.name]
|
||||
and minetest.registered_items[def.name].groups
|
||||
and minetest.registered_items[def.name].groups.tools
|
||||
then
|
||||
table.insert(creative_list, name)
|
||||
end
|
||||
elseif filter == "#combat" then
|
||||
if minetest.registered_items[def.name]
|
||||
and minetest.registered_items[def.name].groups
|
||||
and minetest.registered_items[def.name].groups.combat
|
||||
then
|
||||
table.insert(creative_list, name)
|
||||
end
|
||||
elseif filter == "#matr" then
|
||||
if minetest.registered_items[def.name]
|
||||
and minetest.registered_items[def.name].groups
|
||||
and minetest.registered_items[def.name].groups.materials
|
||||
then
|
||||
table.insert(creative_list, name)
|
||||
end
|
||||
elseif filter == "#brew" then
|
||||
if minetest.registered_items[def.name]
|
||||
and minetest.registered_items[def.name].groups
|
||||
and minetest.registered_items[def.name].groups.brewing
|
||||
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"] = "4.78,8.12"
|
||||
offset["matr"] = "3.495,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, scroll)
|
||||
reset_menu_item_bg()
|
||||
pagenum = math.floor(pagenum) or 1
|
||||
local pagemax = math.floor((crafting.creative_inventory_size) / (9*5) + 1)
|
||||
local slider_height = 4/pagemax
|
||||
local slider_pos = slider_height*(pagenum-1)+2.2
|
||||
local player_name = player:get_player_name()
|
||||
crafting.start_is[player_name] = start_i
|
||||
crafting.pages[player_name] = page
|
||||
local formspec = ""
|
||||
local main_list = "list[detached:creative;main;0,1.75;9,5;"..tostring(start_i).."]"
|
||||
local name = "nix"
|
||||
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]"..
|
||||
"image[-0.3,0.15;3,4.3;crafting_inventory_armor2.png]"..
|
||||
"list[current_player;main;0,3.75;9,3;9]"..
|
||||
|
||||
"list[detached:"..player_name.."_armor;armor;0.02,1.7;1,1;]"..
|
||||
"list[detached:"..player_name.."_armor;armor;0.02,2.7;1,1;1]"..
|
||||
"list[detached:"..player_name.."_armor;armor;0.98,1.7;1,1;2]"..
|
||||
"list[detached:"..player_name.."_armor;armor;0.98,2.7;1,1;3]"
|
||||
end
|
||||
formspec = "size[10,9.3]"..
|
||||
"image_button_exit[8.4,-0.1;0.75,0.75;close.png;exit;;true;true;]"..
|
||||
"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;]".. --bluestone
|
||||
"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_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_inventory_brew.png;brew;]".. --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]"..
|
||||
|
||||
"image[9.04," .. tostring(slider_pos) .. ";0.78,"..tostring(slider_height) .. ";crafting_slider.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, 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 = 'nix'
|
||||
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
|
||||
if fields.brew then
|
||||
set_inv("#brew")
|
||||
page = "brew"
|
||||
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-1)
|
||||
marker = string.sub(marker,1,1)
|
||||
|
||||
local player_name = player:get_player_name()
|
||||
local start_i = crafting.start_is[player_name]
|
||||
if not page then page = crafting.pages[player_name] end
|
||||
if page ~= crafting.pages[player_name] then
|
||||
start_i = 0
|
||||
end
|
||||
--if marker ~= nil and marker == "p" then
|
||||
--local ppage = string.sub(formspec,size)
|
||||
-- print('ppage ' .. (ppage or 'nope'))
|
||||
--minetest.chat_send_all(page)
|
||||
--start_i = ppage - 1
|
||||
--end
|
||||
--start_i = tonumber(start_i) or 0
|
||||
|
||||
if fields.creative_prev then
|
||||
start_i = start_i - 9*5
|
||||
end
|
||||
if fields.creative_next
|
||||
and start_i + 9*5 <= crafting.creative_inventory_size+1 then
|
||||
start_i = start_i + 9*5
|
||||
end
|
||||
if start_i < 0 then
|
||||
start_i = 0
|
||||
end
|
||||
|
||||
crafting.set_creative_formspec(player, start_i, start_i/(9*5) +1, false, page)
|
||||
end)
|
@ -1,2 +0,0 @@
|
||||
|
||||
default
|
@ -1,48 +0,0 @@
|
||||
default.chest_formspec =
|
||||
"size[9,9.75]"..
|
||||
"image_button_exit[8.4,-0.1;0.75,0.75;close.png;exit;;true;true;]"..
|
||||
"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]"..
|
||||
"image_button_exit[8.4,-0.1;0.75,0.75;close.png;exit;;true;true;]"..
|
||||
"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
|
||||
})
|
@ -1,166 +0,0 @@
|
||||
dofile(minetest.get_modpath("crafting").."/formspecs.lua")
|
||||
|
||||
local show_armor = true
|
||||
|
||||
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:set_velocity(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:get_pos())
|
||||
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)
|
||||
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_player2d.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.5,0;2,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]"..
|
||||
"image_button_exit[8.4,-0.1;0.75,0.75;close.png;exit;;true;true;]"..
|
||||
"background[-0.19,-0.25;9.41,9.49;crafting_formspec_inv.png]"..
|
||||
"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;]"..
|
||||
"list[detached:"..player_name.."_armor;armor;0,1;1,1;1]"..
|
||||
"list[detached:"..player_name.."_armor;armor;0,2;1,1;2]"..
|
||||
"list[detached:"..player_name.."_armor;armor;0,3;1,1;3]"
|
||||
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;1]"..
|
||||
"list[detached:"..player_name.."_armor;armor_legs;0,2;1,1;2]"..
|
||||
"list[detached:"..player_name.."_armor;armor_feet;0,3;1,1;3]"
|
||||
end
|
||||
end
|
||||
local split_form = ""
|
||||
split_form =
|
||||
"list[detached:split;main;7.99,3.15;1,1;]"
|
||||
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.05,1.54;1,1;]"..
|
||||
split_form..
|
||||
"inv"
|
||||
|
||||
player:set_inventory_formspec(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
|
||||
--[[minetest.after(0.5,function()
|
||||
dofile(minetest.get_modpath("crafting").."/creative.lua")
|
||||
crafting.set_creative_formspec(player, 0, 1)
|
||||
return
|
||||
end)]]
|
||||
else
|
||||
--init inventory
|
||||
set_inventory(player)
|
||||
end
|
||||
|
||||
--add hotbar images
|
||||
minetest.after(0.5,function()
|
||||
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)
|
||||
end
|
||||
end
|
||||
end)
|
||||
end)
|
||||
|
||||
local split_inv = minetest.create_detached_inventory("split", {
|
||||
allow_move = function(_, _, _, _, _, count, _)
|
||||
return count
|
||||
end,
|
||||
allow_put = function(_, _, _, stack, _)
|
||||
return stack:get_count() / 2
|
||||
end,
|
||||
allow_take = function(_, _, _, stack, _)
|
||||
return stack:get_count()
|
||||
end,
|
||||
})
|
||||
split_inv:set_size("main", 1)
|
Before Width: | Height: | Size: 1.5 KiB |
Before Width: | Height: | Size: 2.0 KiB |
Before Width: | Height: | Size: 2.2 KiB |
Before Width: | Height: | Size: 1.3 KiB |
Before Width: | Height: | Size: 346 B |
Before Width: | Height: | Size: 282 B |
Before Width: | Height: | Size: 83 B |
Before Width: | Height: | Size: 83 B |
Before Width: | Height: | Size: 1.4 KiB |
Before Width: | Height: | Size: 952 B |
Before Width: | Height: | Size: 184 B |
Before Width: | Height: | Size: 648 B |
Before Width: | Height: | Size: 519 B |
Before Width: | Height: | Size: 424 B |
Before Width: | Height: | Size: 544 B |
Before Width: | Height: | Size: 634 B |
Before Width: | Height: | Size: 324 B |
Before Width: | Height: | Size: 281 B |
Before Width: | Height: | Size: 210 B |
Before Width: | Height: | Size: 181 B |
Before Width: | Height: | Size: 428 B |
Before Width: | Height: | Size: 3.4 KiB |
Before Width: | Height: | Size: 422 B |
Before Width: | Height: | Size: 239 B |
Before Width: | Height: | Size: 2.1 KiB |
Before Width: | Height: | Size: 3.8 KiB |
Before Width: | Height: | Size: 82 B |
Before Width: | Height: | Size: 198 B |
Before Width: | Height: | Size: 171 B |
Before Width: | Height: | Size: 160 B |
Before Width: | Height: | Size: 203 B |
Before Width: | Height: | Size: 195 B |
Before Width: | Height: | Size: 210 B |
Before Width: | Height: | Size: 174 B |
Before Width: | Height: | Size: 153 B |
Before Width: | Height: | Size: 189 B |
Before Width: | Height: | Size: 186 B |
Before Width: | Height: | Size: 192 B |
Before Width: | Height: | Size: 150 B |
@ -15,16 +15,16 @@ if creative_mode_cache then
|
||||
-- To speed up digging in creative, hand 'maxlevel' and 'digtime' have been
|
||||
-- increased such that nodes of differing levels have an insignificant
|
||||
-- effect on digtime.
|
||||
local digtime = 96
|
||||
local digtime = 42
|
||||
local caps = {times = {digtime, digtime, digtime}, uses = 0, maxlevel = 256}
|
||||
|
||||
minetest.register_item(":", {
|
||||
type = "none",
|
||||
wield_image = "wieldhand.png",
|
||||
wield_scale = {x = 0.7, y = 2, z = 0},
|
||||
wield_scale = {x = 1, y = 1, z = 2.5},
|
||||
range = 10,
|
||||
tool_capabilities = {
|
||||
full_punch_interval = 0.9,
|
||||
full_punch_interval = 0.5,
|
||||
max_drop_level = 3,
|
||||
groupcaps = {
|
||||
crumbly = caps,
|
||||
@ -33,7 +33,7 @@ if creative_mode_cache then
|
||||
choppy = caps,
|
||||
oddly_breakable_by_hand = caps,
|
||||
},
|
||||
damage_groups = {fleshy = 5},
|
||||
damage_groups = {fleshy = 10},
|
||||
}
|
||||
})
|
||||
end
|
||||
|
@ -101,21 +101,22 @@ function creative.register_tab(name, title, items)
|
||||
creative.update_creative_inventory(player_name, items)
|
||||
local inv = player_inventory[player_name]
|
||||
local start_i = inv.start_i or 0
|
||||
local pagenum = math.floor(start_i / (3*8) + 1)
|
||||
local pagemax = math.ceil(inv.size / (3*8))
|
||||
local pagenum = math.floor(start_i / (3*9) + 1)
|
||||
local pagemax = math.ceil(inv.size / (3*9))
|
||||
return sfinv.make_formspec(player, context,
|
||||
"label[6.2,3.35;" .. minetest.colorize("#FFFF00", tostring(pagenum)) .. " / " .. tostring(pagemax) .. "]" ..
|
||||
"label[6.75,3.85;" .. minetest.colorize("#FFFF00", tostring(pagenum)) .. " / " .. tostring(pagemax) .. "]" ..
|
||||
[[
|
||||
image[4.06,3.4;0.8,0.8;creative_trash_icon.png]
|
||||
listcolors[#00000069;#5A5A5A;#141318;#30434C;#FFF]
|
||||
list[current_player;main;0,4.7;8,1;]
|
||||
list[current_player;main;0,5.85;8,3;8]
|
||||
list[detached:creative_trash;main;4,3.3;1,1;]
|
||||
background[-0.19,-0.25;9.41,10.48;creative_gui_formbg.png]
|
||||
image[4,3.7;1,1;creative_trash_icon.png]
|
||||
listcolors[#9990;#FFF7;#FFF0;#160816;#D4D2FF]
|
||||
list[current_player;main;0,5.5;9,3;9]
|
||||
list[current_player;main;0,8.74;9,1;]
|
||||
list[detached:creative_trash;main;4,3.7;1,1;]
|
||||
listring[]
|
||||
button[5.4,3.2;0.8,0.9;creative_prev;<]
|
||||
button[7.25,3.2;0.8,0.9;creative_next;>]
|
||||
button[2.1,3.4;0.8,0.5;creative_search;?]
|
||||
button[2.75,3.4;0.8,0.5;creative_clear;X]
|
||||
button[5.5.0,3.7;0.8,0.9;creative_prev;<]
|
||||
button[8.25,3.7;0.8,0.9;creative_next;>]
|
||||
button[2.1,3.9;0.8,0.5;creative_search;?]
|
||||
button[2.75,3.9;0.8,0.5;creative_clear;X]
|
||||
tooltip[creative_search;Search]
|
||||
tooltip[creative_clear;Reset]
|
||||
tooltip[creative_prev;Previous page]
|
||||
@ -123,12 +124,10 @@ function creative.register_tab(name, title, items)
|
||||
listring[current_player;main]
|
||||
field_close_on_enter[creative_filter;false]
|
||||
]] ..
|
||||
"field[0.3,3.5;2.2,1;creative_filter;;" .. minetest.formspec_escape(inv.filter) .. "]" ..
|
||||
"field[0.3,4.0;2.2,1;creative_filter;;" .. minetest.formspec_escape(inv.filter) .. "]" ..
|
||||
"listring[detached:creative_" .. player_name .. ";main]" ..
|
||||
"list[detached:creative_" .. player_name .. ";main;0,0;8,3;" .. tostring(start_i) .. "]" ..
|
||||
-- default.get_hotbar_bg(0,4.7) ..
|
||||
-- default.gui_bg .. default.gui_bg_img .. default.gui_slots ..
|
||||
creative.formspec_add, false)
|
||||
"list[detached:creative_" .. player_name .. ";main;0,0.5;9,3;" .. tostring(start_i) .. "]" ..
|
||||
creative.formspec_add, false, "size[9,9.75]")
|
||||
end,
|
||||
on_enter = function(self, player, context)
|
||||
local player_name = player:get_player_name()
|
||||
@ -157,15 +156,15 @@ function creative.register_tab(name, title, items)
|
||||
local start_i = inv.start_i or 0
|
||||
|
||||
if fields.creative_prev then
|
||||
start_i = start_i - 3*8
|
||||
start_i = start_i - 3*9
|
||||
if start_i < 0 then
|
||||
start_i = inv.size - (inv.size % (3*8))
|
||||
start_i = inv.size - (inv.size % (3*9))
|
||||
if inv.size == start_i then
|
||||
start_i = math.max(0, inv.size - (3*8))
|
||||
start_i = math.max(0, inv.size - (3*9))
|
||||
end
|
||||
end
|
||||
elseif fields.creative_next then
|
||||
start_i = start_i + 3*8
|
||||
start_i = start_i + 3*9
|
||||
if start_i >= inv.size then
|
||||
start_i = 0
|
||||
end
|
||||
|
BIN
games/default/files/creative/textures/creative_gui_formbg.png
Normal file
After Width: | Height: | Size: 2.1 KiB |
Before Width: | Height: | Size: 179 B After Width: | Height: | Size: 210 B |
Before Width: | Height: | Size: 550 B After Width: | Height: | Size: 550 B |
@ -2,7 +2,10 @@ sfinv = {
|
||||
pages = {},
|
||||
pages_unordered = {},
|
||||
contexts = {},
|
||||
enabled = true
|
||||
enabled = true,
|
||||
gui_bg = "bgcolor[#080808BB;true]",
|
||||
gui_bg_img = "background[-0.19,-0.25;9.41,9.49;gui_formbg.png]",
|
||||
gui_slots = "listcolors[#9990;#FFF7;#FFF0;#160816;#D4D2FF]",
|
||||
}
|
||||
|
||||
function sfinv.register_page(name, def)
|
||||
@ -36,17 +39,17 @@ function sfinv.get_nav_fs(player, context, nav, current_idx)
|
||||
end
|
||||
end
|
||||
|
||||
local theme_main = "bgcolor[#080808BB;true]" .. default.gui_bg ..
|
||||
default.gui_bg_img
|
||||
local theme_main = "bgcolor[#080808BB;true]" .. sfinv.gui_bg ..
|
||||
sfinv.gui_bg_img
|
||||
|
||||
local theme_inv = default.gui_slots .. [[
|
||||
list[current_player;main;0,4.7;8,1;]
|
||||
list[current_player;main;0,5.85;8,3;8]
|
||||
local theme_inv = sfinv.gui_slots .. [[
|
||||
list[current_player;main;0,4.5;9,3;9]
|
||||
list[current_player;main;0,7.74;9,1;]
|
||||
]]
|
||||
|
||||
function sfinv.make_formspec(player, context, content, show_inv, size)
|
||||
local tmp = {
|
||||
size or "size[8,8.6]",
|
||||
size or "size[9,8.75]",
|
||||
theme_main,
|
||||
sfinv.get_nav_fs(player, context, context.nav_titles, context.nav_idx),
|
||||
content
|
||||
|
@ -1 +1,28 @@
|
||||
dofile(minetest.get_modpath("sfinv") .. "/api.lua")
|
||||
|
||||
sfinv.register_page("sfinv:crafting", {
|
||||
title = "Crafting",
|
||||
get = function(self, player, context)
|
||||
return sfinv.make_formspec(player, context, [[
|
||||
listcolors[#9990;#FFF7;#FFF0;#160816;#D4D2FF]
|
||||
list[current_player;craft;4,1;2,1;1]
|
||||
list[current_player;craft;4,2;2,1;4]
|
||||
list[current_player;craftpreview;7.05,1.54;1,1;]
|
||||
list[detached:split;main;7.99,3.15;1,1;]
|
||||
image[1.5,0;2,4;default_player2d.png]
|
||||
]], true)
|
||||
end
|
||||
})
|
||||
|
||||
local split_inv = minetest.create_detached_inventory("split", {
|
||||
allow_move = function(_, _, _, _, _, count, _)
|
||||
return count
|
||||
end,
|
||||
allow_put = function(_, _, _, stack, _)
|
||||
return stack:get_count() / 2
|
||||
end,
|
||||
allow_take = function(_, _, _, stack, _)
|
||||
return stack:get_count()
|
||||
end,
|
||||
})
|
||||
split_inv:set_size("main", 1)
|
||||
|
Before Width: | Height: | Size: 2.1 KiB After Width: | Height: | Size: 3.4 KiB |