[init.lua] Creative inventory auto-filled by Registry.
This commit is contained in:
parent
f04993be26
commit
8ff23a02d3
@ -176,7 +176,7 @@ mod:block {
|
||||
fuel_stack:item():is_fuel() and
|
||||
(output_stack:item():id() == 0 or output_stack:amount() == 0
|
||||
or output_stack:item():id() == recipe:result():item():id()) then
|
||||
data.inventory:set_stack(2, 0, fuel_stack:item():stringID(), fuel_stack:amount() - 1)
|
||||
data.inventory:set_stack(2, 0, fuel_stack:item():string_id(), fuel_stack:amount() - 1)
|
||||
ticks_remaining = fuel_stack:item():burn_time()
|
||||
current_burn_time = fuel_stack:item():burn_time()
|
||||
data.useAltTiles = true;
|
||||
@ -198,8 +198,8 @@ mod:block {
|
||||
|
||||
if item_progress >= 200 and recipe then
|
||||
item_progress = 0;
|
||||
data.inventory:set_stack(0, 0, (input_stack:amount() - 1 > 0) and input_stack:item():stringID() or "", input_stack:amount() - 1)
|
||||
data.inventory:set_stack(1, 0, recipe:result():item():stringID(), output_stack:amount() + recipe:result():amount())
|
||||
data.inventory:set_stack(0, 0, (input_stack:amount() - 1 > 0) and input_stack:item():string_id() or "", input_stack:amount() - 1)
|
||||
data.inventory:set_stack(1, 0, recipe:result():item():string_id(), output_stack:amount() + recipe:result():amount())
|
||||
end
|
||||
|
||||
data.meta:set_int("ticks_remaining", ticks_remaining);
|
||||
|
@ -119,6 +119,13 @@ function show_inventory(client, screen_width, screen_height, gui_scale)
|
||||
end
|
||||
|
||||
function show_creative_window(client, screen_width, screen_height, gui_scale)
|
||||
items = {}
|
||||
for k, v in pairs(openminer:registry():items()) do
|
||||
if k ~= 1 then
|
||||
items[#items + 1] = {v:string_id()}
|
||||
end
|
||||
end
|
||||
|
||||
local gui = LuaGUI.new()
|
||||
|
||||
gui:set_size(195, 136)
|
||||
@ -138,72 +145,7 @@ function show_creative_window(client, screen_width, screen_height, gui_scale)
|
||||
width = 9,
|
||||
height = 7,
|
||||
|
||||
items = {
|
||||
-- Blocks
|
||||
{"default:dirt"},
|
||||
{"default:cobblestone"},
|
||||
{"default:grass"},
|
||||
{"default:oak_leaves"},
|
||||
{"default:oak_wood"},
|
||||
{"default:stone"},
|
||||
{"default:sand"},
|
||||
{"default:water"},
|
||||
{"default:glass"},
|
||||
{"default:coal_ore"},
|
||||
{"default:oak_planks"},
|
||||
{"default:glowstone"},
|
||||
{"default:workbench"},
|
||||
{"default:furnace"},
|
||||
{"default:iron_ore"},
|
||||
{"default:dandelion"},
|
||||
{"default:tallgrass"},
|
||||
{"default:stone_bricks"},
|
||||
{"default:bricks"},
|
||||
{"default:clay"},
|
||||
{"default:oak_slab"},
|
||||
{"default:portal"},
|
||||
{"default:netherrack"},
|
||||
{"default:soul_sand"},
|
||||
{"default:lava"},
|
||||
{"default:cactus"},
|
||||
{"default:deadbush"},
|
||||
{"default:debug"},
|
||||
|
||||
-- Items
|
||||
{"default:stick"},
|
||||
{"default:stone_axe"},
|
||||
{"default:stone_hoe"},
|
||||
{"default:stone_pickaxe"},
|
||||
{"default:stone_shovel"},
|
||||
{"default:stone_sword"},
|
||||
{"default:coal"},
|
||||
{"default:iron_ingot"},
|
||||
{"default:charcoal"},
|
||||
{"default:wooden_axe"},
|
||||
{"default:wooden_hoe"},
|
||||
{"default:wooden_pickaxe"},
|
||||
{"default:wooden_shovel"},
|
||||
{"default:wooden_sword"},
|
||||
{"default:brick"},
|
||||
{"default:clay_ball"},
|
||||
{"default:diamond"},
|
||||
{"default:gold_ingot"},
|
||||
{"default:iron_pickaxe"},
|
||||
{"default:iron_sword"},
|
||||
{"default:iron_axe"},
|
||||
{"default:iron_hoe"},
|
||||
{"default:iron_shovel"},
|
||||
{"default:diamond_pickaxe"},
|
||||
{"default:diamond_sword"},
|
||||
{"default:diamond_axe"},
|
||||
{"default:diamond_hoe"},
|
||||
{"default:diamond_shovel"},
|
||||
{"default:golden_pickaxe"},
|
||||
{"default:golden_sword"},
|
||||
{"default:golden_axe"},
|
||||
{"default:golden_hoe"},
|
||||
{"default:golden_shovel"},
|
||||
},
|
||||
items = items,
|
||||
|
||||
is_unlimited = true,
|
||||
}
|
||||
|
@ -52,7 +52,10 @@ void ScriptEngine::init() {
|
||||
|
||||
void ScriptEngine::initUsertypes() {
|
||||
m_lua.new_usertype<Registry>("Registry",
|
||||
"get_recipe", &Registry::getRecipe
|
||||
"get_recipe", &Registry::getRecipe,
|
||||
|
||||
"blocks", &Registry::blocks,
|
||||
"items", &Registry::items
|
||||
);
|
||||
|
||||
m_lua.new_usertype<World>("World",
|
||||
@ -80,6 +83,10 @@ void ScriptEngine::initUsertypes() {
|
||||
"useAltTiles", &BlockData::useAltTiles
|
||||
);
|
||||
|
||||
m_lua.new_usertype<Block>("Block",
|
||||
"string_id", &Block::stringID
|
||||
);
|
||||
|
||||
m_lua.new_usertype<Player>("Player",
|
||||
"inventory", &Player::inventory,
|
||||
|
||||
@ -111,7 +118,7 @@ void ScriptEngine::initUsertypes() {
|
||||
|
||||
m_lua.new_usertype<Item>("Item",
|
||||
"id", &Item::id,
|
||||
"stringID", &Item::stringID,
|
||||
"string_id", &Item::stringID,
|
||||
"burn_time", &Item::burnTime,
|
||||
"is_fuel", &Item::isFuel
|
||||
);
|
||||
|
Loading…
x
Reference in New Issue
Block a user