2020-02-08 18:34:26 +09:00
|
|
|
--
|
|
|
|
-- =====================================================================================
|
|
|
|
--
|
|
|
|
-- OpenMiner
|
|
|
|
-- Copyright (C) 2018-2020 Unarelith, Quentin Bazin <openminer@unarelith.net>
|
|
|
|
--
|
|
|
|
-- This program is free software; you can redistribute it and/or
|
|
|
|
-- modify it under the terms of the GNU Lesser General Public
|
|
|
|
-- License as published by the Free Software Foundation; either
|
|
|
|
-- version 2.1 of the License, or (at your option) any later version.
|
|
|
|
--
|
|
|
|
-- This program is distributed in the hope that it will be useful,
|
|
|
|
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
-- Lesser General Public License for more details.
|
|
|
|
--
|
|
|
|
-- You should have received a copy of the GNU Lesser General Public License
|
|
|
|
-- along with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
-- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
--
|
|
|
|
-- =====================================================================================
|
|
|
|
--
|
2019-01-04 18:05:35 +01:00
|
|
|
mod = LuaMod.new("default")
|
|
|
|
|
2020-01-30 21:53:28 +09:00
|
|
|
dofile("mods/default/blocks.lua")
|
|
|
|
dofile("mods/default/items.lua")
|
|
|
|
dofile("mods/default/recipes.lua")
|
2018-12-20 02:51:30 +01:00
|
|
|
|
2020-02-03 18:53:36 +09:00
|
|
|
openminer:world():terrain_generator():set_blocks({
|
|
|
|
dirt = "default:dirt",
|
|
|
|
grass = "default:grass",
|
|
|
|
stone = "default:stone",
|
|
|
|
log = "default:wood",
|
|
|
|
leaves = "default:leaves",
|
|
|
|
flower = "default:flower",
|
|
|
|
water = "default:water",
|
2020-02-19 20:08:46 +09:00
|
|
|
sand = "default:sand",
|
|
|
|
tallgrass = "default:tallgrass"
|
2020-02-03 18:53:36 +09:00
|
|
|
})
|
|
|
|
|
2019-04-07 18:20:15 +02:00
|
|
|
function init(player)
|
|
|
|
local player_inv = player:inventory()
|
2018-12-28 21:23:26 +01:00
|
|
|
|
2019-01-07 04:56:42 +01:00
|
|
|
player_inv:add_stack("default:workbench", 1);
|
|
|
|
player_inv:add_stack("default:dirt", 64);
|
|
|
|
player_inv:add_stack("default:grass", 64);
|
|
|
|
player_inv:add_stack("default:stone", 64);
|
|
|
|
player_inv:add_stack("default:glass", 64);
|
|
|
|
player_inv:add_stack("default:glowstone", 64);
|
|
|
|
player_inv:add_stack("default:furnace", 1);
|
2020-01-30 15:31:49 +09:00
|
|
|
player_inv:add_stack("default:stone_pickaxe", 1);
|
2020-02-03 19:01:11 +09:00
|
|
|
player_inv:add_stack("default:stone_axe", 1);
|
2019-01-07 04:56:42 +01:00
|
|
|
|
|
|
|
player_inv:add_stack("default:wood", 64);
|
|
|
|
player_inv:add_stack("default:planks", 64);
|
|
|
|
player_inv:add_stack("default:cobblestone", 64);
|
|
|
|
player_inv:add_stack("default:stick", 64);
|
2020-01-30 15:31:49 +09:00
|
|
|
player_inv:add_stack("default:stone_hoe", 1);
|
|
|
|
player_inv:add_stack("default:stone_shovel", 1);
|
|
|
|
player_inv:add_stack("default:iron_ore", 64);
|
2019-01-07 04:56:42 +01:00
|
|
|
player_inv:add_stack("default:coal", 64);
|
2018-12-20 02:51:30 +01:00
|
|
|
end
|
|
|
|
|
2020-02-15 14:42:29 +09:00
|
|
|
function show_inventory(client, screen_width, screen_height, gui_scale)
|
2020-02-08 02:48:39 +09:00
|
|
|
local gui = LuaGUI.new()
|
|
|
|
|
|
|
|
-- FIXME: Replace this by gui:set_size() and gui:set_centered()
|
|
|
|
local gui_pos = {
|
2020-02-15 14:42:29 +09:00
|
|
|
x = screen_width / gui_scale / 2.0 - 176 / 2.0,
|
|
|
|
y = screen_height / gui_scale / 2.0 - 166 / 2.0
|
2020-02-08 02:48:39 +09:00
|
|
|
}
|
|
|
|
|
2020-02-22 22:49:48 +09:00
|
|
|
gui:image {
|
|
|
|
name = "img_background",
|
2020-02-08 02:48:39 +09:00
|
|
|
pos = gui_pos,
|
2020-02-22 22:49:48 +09:00
|
|
|
|
|
|
|
texture = "texture-inventory",
|
|
|
|
clip = {x = 0, y = 0, width = 176, height = 166},
|
|
|
|
}
|
|
|
|
|
|
|
|
gui:inventory {
|
|
|
|
name = "inv_main",
|
|
|
|
pos = {x = gui_pos.x + 7, y = gui_pos.y + 83},
|
|
|
|
|
|
|
|
player = "player",
|
|
|
|
inventory = "main",
|
|
|
|
size = {x = 9, y = 3},
|
|
|
|
offset = 9,
|
|
|
|
count = 9 * 3,
|
|
|
|
}
|
|
|
|
|
|
|
|
gui:inventory {
|
|
|
|
name = "inv_hotbar",
|
|
|
|
pos = {x = gui_pos.x + 7, y = gui_pos.y + 141},
|
|
|
|
|
|
|
|
player = "player",
|
|
|
|
inventory = "main",
|
|
|
|
size = {x = 9, y = 1},
|
|
|
|
offset = 0,
|
|
|
|
count = 9,
|
|
|
|
}
|
|
|
|
|
|
|
|
gui:player_crafting {
|
|
|
|
name = "inv_crafting",
|
|
|
|
pos = {x = gui_pos.x + 97, y = gui_pos.y + 17},
|
2020-02-08 02:48:39 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
gui:show(client)
|
|
|
|
end
|