2020-02-08 18:34:26 +09:00
|
|
|
--
|
|
|
|
-- =====================================================================================
|
|
|
|
--
|
|
|
|
-- OpenMiner
|
2020-02-25 01:42:10 +09:00
|
|
|
--
|
2020-02-08 18:34:26 +09:00
|
|
|
-- Copyright (C) 2018-2020 Unarelith, Quentin Bazin <openminer@unarelith.net>
|
2020-02-25 01:42:10 +09:00
|
|
|
-- Copyright (C) 2019-2020 the OpenMiner contributors (see CONTRIBUTORS.md)
|
|
|
|
--
|
|
|
|
-- This file is part of OpenMiner.
|
2020-02-08 18:34:26 +09:00
|
|
|
--
|
2020-02-25 01:42:10 +09:00
|
|
|
-- OpenMiner is free software; you can redistribute it and/or
|
2020-02-08 18:34:26 +09:00
|
|
|
-- 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.
|
|
|
|
--
|
2020-02-25 01:42:10 +09:00
|
|
|
-- OpenMiner is distributed in the hope that it will be useful,
|
2020-02-08 18:34:26 +09:00
|
|
|
-- 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
|
2020-02-25 01:42:10 +09:00
|
|
|
-- along with OpenMiner; if not, write to the Free Software Foundation, Inc.,
|
2020-02-08 18:34:26 +09:00
|
|
|
-- 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",
|
2020-02-29 01:36:10 +01:00
|
|
|
tallgrass = "default:tallgrass",
|
|
|
|
iron_ore = "default:iron_ore"
|
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);
|
2020-02-29 03:27:04 +01:00
|
|
|
|
|
|
|
player_inv:add_stack("default:iron_ingot", 64);
|
|
|
|
player_inv:add_stack("default:gold_ingot", 64);
|
|
|
|
player_inv:add_stack("default:diamond", 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-23 18:00:20 +09:00
|
|
|
x = math.floor(screen_width / gui_scale / 2.0 - 176 / 2.0 + 0.5),
|
|
|
|
y = math.floor(screen_height / gui_scale / 2.0 - 166 / 2.0 + 0.5)
|
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},
|
|
|
|
|
2020-02-23 22:38:51 +09:00
|
|
|
inventory = "player",
|
2020-02-22 22:49:48 +09:00
|
|
|
player = "player",
|
2020-02-23 22:38:51 +09:00
|
|
|
inventory_name = "main",
|
2020-02-22 22:49:48 +09:00
|
|
|
size = {x = 9, y = 3},
|
|
|
|
offset = 9,
|
|
|
|
count = 9 * 3,
|
2020-03-01 12:28:26 +01:00
|
|
|
|
2020-03-01 15:45:09 +01:00
|
|
|
shift_destination = "inv_hotbar,inv_main",
|
2020-02-22 22:49:48 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
gui:inventory {
|
|
|
|
name = "inv_hotbar",
|
|
|
|
pos = {x = gui_pos.x + 7, y = gui_pos.y + 141},
|
|
|
|
|
2020-02-23 22:38:51 +09:00
|
|
|
inventory = "player",
|
2020-02-22 22:49:48 +09:00
|
|
|
player = "player",
|
2020-02-23 22:38:51 +09:00
|
|
|
inventory_name = "main",
|
2020-02-22 22:49:48 +09:00
|
|
|
size = {x = 9, y = 1},
|
|
|
|
offset = 0,
|
|
|
|
count = 9,
|
2020-03-01 12:28:26 +01:00
|
|
|
|
2020-03-01 15:45:09 +01:00
|
|
|
shift_destination = "inv_main,inv_hotbar",
|
2020-02-22 22:49:48 +09:00
|
|
|
}
|
|
|
|
|
2020-02-23 18:24:19 +09:00
|
|
|
gui:crafting {
|
2020-02-22 22:49:48 +09:00
|
|
|
name = "inv_crafting",
|
|
|
|
pos = {x = gui_pos.x + 97, y = gui_pos.y + 17},
|
2020-02-23 18:00:20 +09:00
|
|
|
result_pos = {x = gui_pos.x + 97 + 56, y = gui_pos.y + 17 + 10},
|
2020-02-23 18:24:19 +09:00
|
|
|
|
|
|
|
inventory = "temp",
|
|
|
|
size = 2,
|
2020-03-01 00:15:49 +01:00
|
|
|
|
2020-03-01 12:55:20 +01:00
|
|
|
shift_destination = "inv_main,inv_hotbar",
|
2020-02-08 02:48:39 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
gui:show(client)
|
|
|
|
end
|
2020-02-29 18:07:01 +01:00
|
|
|
|
|
|
|
function show_creative_window(client, screen_width, screen_height, gui_scale)
|
|
|
|
local gui = LuaGUI.new()
|
|
|
|
|
|
|
|
-- FIXME: Replace this by gui:set_size() and gui:set_centered()
|
|
|
|
local gui_pos = {
|
|
|
|
x = math.floor(screen_width / gui_scale / 2.0 - 195 / 2.0 + 0.5),
|
|
|
|
y = math.floor(screen_height / gui_scale / 2.0 - 136 / 2.0 + 0.5)
|
|
|
|
}
|
|
|
|
|
|
|
|
gui:image {
|
|
|
|
name = "img_background",
|
|
|
|
pos = gui_pos,
|
|
|
|
|
|
|
|
texture = "texture-creative_window",
|
|
|
|
clip = {x = 0, y = 0, width = 195, height = 136},
|
|
|
|
}
|
|
|
|
|
|
|
|
gui:inventory_data {
|
|
|
|
name = "inv_data",
|
|
|
|
|
|
|
|
width = 9,
|
|
|
|
height = 5,
|
|
|
|
|
|
|
|
items = {
|
|
|
|
-- Blocks
|
|
|
|
{"default:dirt"},
|
|
|
|
{"default:cobblestone"},
|
|
|
|
{"default:grass"},
|
|
|
|
{"default:leaves"},
|
|
|
|
{"default:wood"},
|
|
|
|
{"default:stone"},
|
|
|
|
{"default:sand"},
|
|
|
|
{"default:water"},
|
|
|
|
{"default:glass"},
|
|
|
|
{"default:coal_ore"},
|
|
|
|
{"default:planks"},
|
|
|
|
{"default:glowstone"},
|
|
|
|
{"default:workbench"},
|
|
|
|
{"default:furnace"},
|
|
|
|
{"default:iron_ore"},
|
|
|
|
{"default:flower"},
|
|
|
|
{"default:tallgrass"},
|
|
|
|
{"default:stone_bricks"},
|
|
|
|
{"default:bricks"},
|
|
|
|
{"default:clay"},
|
|
|
|
|
|
|
|
-- 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"},
|
|
|
|
},
|
|
|
|
|
|
|
|
is_unlimited = true,
|
|
|
|
}
|
|
|
|
|
|
|
|
gui:inventory {
|
|
|
|
name = "inv_creative_items",
|
|
|
|
pos = {x = gui_pos.x + 8, y = gui_pos.y + 17},
|
|
|
|
|
|
|
|
inventory = "temp",
|
|
|
|
inventory_name = "inv_data",
|
|
|
|
size = {x = 9, y = 5},
|
|
|
|
|
|
|
|
offset = 0,
|
|
|
|
count = 9 * 5,
|
|
|
|
}
|
|
|
|
|
|
|
|
gui:inventory {
|
|
|
|
name = "inv_hotbar",
|
|
|
|
pos = {x = gui_pos.x + 8, y = gui_pos.y + 111},
|
|
|
|
|
|
|
|
inventory = "player",
|
|
|
|
player = "player",
|
|
|
|
inventory_name = "main",
|
|
|
|
size = {x = 9, y = 1},
|
|
|
|
offset = 0,
|
|
|
|
count = 9,
|
|
|
|
}
|
|
|
|
|
|
|
|
gui:show(client);
|
|
|
|
end
|