Add basic fromspec, set inventory sizes.

master
None 2015-01-24 18:29:20 +03:00
parent 550b85252b
commit c7cb140394
3 changed files with 40 additions and 18 deletions

View File

@ -1,6 +1,9 @@
clothing = {}
--{{{ Wear clothing
-- Wear clothing
clothing.update_skin = function(player)
-- Function gets the player's "wear" inventory list.
-- It's created by mod "inventory"
local weared = player:get_inventory():get_list("wear")
local skin = default.player_get_animation(player).textures[1]
for _,itemstack in ipairs(weared) do
@ -14,20 +17,12 @@ clothing.update_skin = function(player)
player:get_player_name()
)
end
--}}}
--{{{ Save and restore data
-- Save and restore data
minetest.register_on_joinplayer(function(player)
clothing.update_skin(player)
end)
minetest.register_on_newplayer(function(player)
-- Add inventory list for clothing
player:get_inventory():set_list("wear", {})
player:get_inventory():set_size("wear", 36)
end)
--}}}
--{{{ Cloth
-- Required values is:
-- "wear_image" (this image is adding on player skin)

View File

@ -147,9 +147,6 @@ minetest.register_on_joinplayer(function(player)
default.player_set_textures(player, {player:get_player_name() .. ".png"})
-- set GUI
if not minetest.setting_getbool("creative_mode") then
player:set_inventory_formspec(default.gui_suvival_form)
end
player:hud_set_hotbar_image("gui_hotbar.png")
player:hud_set_hotbar_selected_image("gui_hotbar_selected.png")
end)

View File

@ -1,3 +1,5 @@
inventory = {}
minetest.register_chatcommand("inv_test", {
func = function()
-- Called when command is run.
@ -7,10 +9,38 @@ minetest.register_chatcommand("inv_test", {
end
})
minetest.register_on_joinplayer(function(player)
minetest.register_on_newplayer(function(player)
local invref = player:get_inventory()
-- Something wrong
-- invref:set_lists({wear, main})
--
-- TODO: Set size and formspec
-- Main list
invref:set_size("main", 9)
-- Wear list, for clothes
invref:set_list("wear", {})
invref:set_size("wear", 36)
-- Left and right hand (is this needed?)
invref:set_list("left_hand", {})
invref:set_size("left_hand", 1)
invref:set_list("right_hand", {})
invref:set_size("right_hand", 1)
end)
minetest.register_on_joinplayer(function(player)
if not minetest.setting_getbool("creative_mode") then
player:set_inventory_formspec(inventory.gui_survival_form)
end
end)
inventory.gui_survival_form =
"size[9,5]"..
default.gui_bg..
default.gui_bg_img..
default.gui_slots..
"list[current_player;craft;2,0;3,3;]"..
"image[5,1;1,1;gui_furnace_arrow_bg.png^[transformR270]"..
"list[current_player;craftpreview;6,1;1,1;]"..
"list[current_player;left_hand;0.25,1;1,1;]"..
"list[current_player;right_hand;7.75,1;1,1;]"..
"list[current_player;main;0,3.5;9,1;]"..
default.get_hotbar_bg(0,3.5)