I think that's good for now
This commit is contained in:
parent
8da9e4ce87
commit
ae68cb00be
@ -7,7 +7,8 @@ end
|
||||
-- End of Lua Library inline imports
|
||||
player = player or ({})
|
||||
do
|
||||
player.INVENTORY_SIZE = vector.create2d(9, 4)
|
||||
player.CRAFT_INVENTORY_SIZE = vector.create2d(2, 2)
|
||||
player.MAIN_INVENTORY_SIZE = vector.create2d(9, 4)
|
||||
local create = vector.create2d
|
||||
local generate = formSpec.generate
|
||||
local FormSpec = formSpec.FormSpec
|
||||
@ -15,6 +16,7 @@ do
|
||||
local BGColor = formSpec.BGColor
|
||||
local List = formSpec.List
|
||||
local ListColors = formSpec.ListColors
|
||||
local ListRing = formSpec.ListRing
|
||||
local color = utility.color
|
||||
local colorScalar = utility.colorScalar
|
||||
local colorRGB = utility.colorRGB
|
||||
@ -47,7 +49,7 @@ do
|
||||
location = "current_player",
|
||||
listName = "craft",
|
||||
position = create(5.5, 1.75),
|
||||
size = create(2, 2),
|
||||
size = player.CRAFT_INVENTORY_SIZE,
|
||||
startingIndex = 0
|
||||
}
|
||||
),
|
||||
@ -67,7 +69,7 @@ do
|
||||
location = "current_player",
|
||||
listName = "main",
|
||||
position = create(0.5, 6.5),
|
||||
size = create(player.INVENTORY_SIZE.x, 1),
|
||||
size = create(player.MAIN_INVENTORY_SIZE.x, 1),
|
||||
startingIndex = 0
|
||||
}
|
||||
),
|
||||
@ -77,16 +79,22 @@ do
|
||||
location = "current_player",
|
||||
listName = "main",
|
||||
position = create(0.5, 8),
|
||||
size = create(player.INVENTORY_SIZE.x, player.INVENTORY_SIZE.y - 1),
|
||||
startingIndex = player.INVENTORY_SIZE.x
|
||||
size = create(player.MAIN_INVENTORY_SIZE.x, player.MAIN_INVENTORY_SIZE.y - 1),
|
||||
startingIndex = player.MAIN_INVENTORY_SIZE.x
|
||||
}
|
||||
)
|
||||
),
|
||||
__TS__New(ListRing, {location = "current_player", listName = "main"}),
|
||||
__TS__New(ListRing, {location = "current_player", listName = "craft"})
|
||||
}
|
||||
}
|
||||
))
|
||||
minetest.register_on_joinplayer(function(newPlayer)
|
||||
newPlayer:hud_set_hotbar_itemcount(player.INVENTORY_SIZE.x)
|
||||
newPlayer:get_inventory():set_size("main", player.INVENTORY_SIZE.x * player.INVENTORY_SIZE.y)
|
||||
newPlayer:hud_set_hotbar_itemcount(player.MAIN_INVENTORY_SIZE.x)
|
||||
local inventory = newPlayer:get_inventory()
|
||||
inventory:set_size("main", player.MAIN_INVENTORY_SIZE.x * player.MAIN_INVENTORY_SIZE.y)
|
||||
inventory:set_width("main", player.MAIN_INVENTORY_SIZE.x)
|
||||
inventory:set_size("craft", player.CRAFT_INVENTORY_SIZE.x * player.CRAFT_INVENTORY_SIZE.y)
|
||||
inventory:set_width("craft", player.CRAFT_INVENTORY_SIZE.x)
|
||||
newPlayer:set_inventory_formspec(playerInventory)
|
||||
end)
|
||||
end
|
||||
|
@ -1,6 +1,7 @@
|
||||
namespace player {
|
||||
|
||||
export const INVENTORY_SIZE = vector.create2d(9,4)
|
||||
export const CRAFT_INVENTORY_SIZE = vector.create2d(2,2)
|
||||
export const MAIN_INVENTORY_SIZE = vector.create2d(9,4)
|
||||
|
||||
const create = vector.create2d
|
||||
|
||||
@ -10,6 +11,7 @@ namespace player {
|
||||
const BGColor = formSpec.BGColor
|
||||
const List = formSpec.List
|
||||
const ListColors = formSpec.ListColors
|
||||
const ListRing = formSpec.ListRing
|
||||
|
||||
const color = utility.color
|
||||
const colorScalar = utility.colorScalar
|
||||
@ -40,10 +42,7 @@ namespace player {
|
||||
5.5,
|
||||
1.75
|
||||
),
|
||||
size: create(
|
||||
2,
|
||||
2
|
||||
),
|
||||
size: CRAFT_INVENTORY_SIZE,
|
||||
startingIndex: 0
|
||||
}),
|
||||
//! Craft output
|
||||
@ -69,7 +68,7 @@ namespace player {
|
||||
6.5
|
||||
),
|
||||
size: create(
|
||||
INVENTORY_SIZE.x,
|
||||
MAIN_INVENTORY_SIZE.x,
|
||||
1
|
||||
),
|
||||
startingIndex: 0
|
||||
@ -83,17 +82,30 @@ namespace player {
|
||||
8
|
||||
),
|
||||
size: create(
|
||||
INVENTORY_SIZE.x,
|
||||
INVENTORY_SIZE.y - 1
|
||||
MAIN_INVENTORY_SIZE.x,
|
||||
MAIN_INVENTORY_SIZE.y - 1
|
||||
),
|
||||
startingIndex: INVENTORY_SIZE.x
|
||||
startingIndex: MAIN_INVENTORY_SIZE.x
|
||||
}),
|
||||
//! List Rings.
|
||||
new ListRing({
|
||||
location: "current_player",
|
||||
listName: "main"
|
||||
}),
|
||||
new ListRing({
|
||||
location: "current_player",
|
||||
listName: "craft"
|
||||
})
|
||||
]
|
||||
}))
|
||||
|
||||
minetest.register_on_joinplayer((newPlayer: ObjectRef) => {
|
||||
newPlayer.hud_set_hotbar_itemcount(INVENTORY_SIZE.x)
|
||||
newPlayer.get_inventory().set_size("main", INVENTORY_SIZE.x * INVENTORY_SIZE.y)
|
||||
newPlayer.hud_set_hotbar_itemcount(MAIN_INVENTORY_SIZE.x)
|
||||
const inventory = newPlayer.get_inventory()
|
||||
inventory.set_size("main", MAIN_INVENTORY_SIZE.x * MAIN_INVENTORY_SIZE.y)
|
||||
inventory.set_width("main", MAIN_INVENTORY_SIZE.x)
|
||||
inventory.set_size("craft", CRAFT_INVENTORY_SIZE.x * CRAFT_INVENTORY_SIZE.y)
|
||||
inventory.set_width("craft", CRAFT_INVENTORY_SIZE.x)
|
||||
newPlayer.set_inventory_formspec(playerInventory)
|
||||
})
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user