Proper file structure

master
Zughy 2022-06-08 18:45:15 +02:00
parent 1641b14871
commit 1206232e98
7 changed files with 63 additions and 102 deletions

View File

@ -6,7 +6,7 @@ Easily manage your mini-games on Minetest
## Customisation
Check config.txt to change spawn point, to add more items in the hotbar or to change physics values
Check SETTINGS.lua to change spawn point, add more items in the hotbar, and more
---

25
SETTINGS.lua Normal file
View File

@ -0,0 +1,25 @@
hub_manager.settings = {}
-- spawn point
hub_manager.settings.hub_spawn_point = vector.new(-205, 9, 204)
-- hotbar additional items
hub_manager.settings.hotbar_items = {
"",
"",
"",
"",
"",
"",
""
}
-- physics whilst in the lobby
hub_manager.settings.physics = {
speed=1,
jump=1,
gravity=1,
sneak=true,
sneak_glitch=false,
new_move=true
}

View File

@ -1,18 +0,0 @@
hub_spawn_point = -3.5, 3.0, -20.5
# hotbar additional items. The number corresponds with the number of the slot
1=
2=
3=
4=
5=
6=
7=
# physics overrides while in the lobby
speed=1
jump=1
gravity=1
sneak=true
sneak_glitch=false
new_move=true

View File

@ -1,13 +1,15 @@
local version = "0.1.0-dev"
local modpath = minetest.get_modpath("hub_manager")
local srcpath = modpath .. "/src/"
hub_manager = {}
dofile(modpath .. "/SETTINGS.lua")
dofile(srcpath .. "/api.lua")
dofile(srcpath .. "/chat.lua")
dofile(srcpath .. "/chatcmdbuilder.lua")
dofile(srcpath .. "/commands.lua")
dofile(srcpath .. "/load_config.lua")
dofile(srcpath .. "/items.lua")
dofile(srcpath .. "/player_manager.lua")
dofile(srcpath .. "/settings.lua")
minetest.log("action", "[HUB_MANAGER] Mod initialised, running version " .. version)

View File

@ -1,4 +1,20 @@
hub_manager = {}
local settings = table.copy(hub_manager.settings)
----------------------------------------------
-----------------GETTERS----------------------
----------------------------------------------
function hub_manager.get_hub_spawn_point()
return settings.hub_spawn_point
end
function hub_manager.get_additional_items()
return settings.hotbar_items
end
@ -13,6 +29,18 @@ end
----------------------------------------------
-----------------SETTERS----------------------
----------------------------------------------
function hub_manager.set_hub_physics(player)
player:set_physics_override(settings.physics)
end
function hub_manager.set_items(player)
local inv = player:get_inventory()
@ -29,8 +57,10 @@ function hub_manager.set_items(player)
local additional_items = hub_manager.get_additional_items()
-- eventuali oggetti aggiuntivi
for i = 1, 7 do
hotbar_items[i] = additional_items[i]
for i = 1, #additional_items do
if additional_items[i] ~= "" then
hotbar_items[i] = additional_items[i]
end
end
inv:set_list("main", hotbar_items)

View File

@ -1,78 +0,0 @@
local config_file = io.open(minetest.get_modpath("hub_manager") .. "/config.txt", "r")
assert(config_file ~= nil, "CAN'T LOAD HUB_MANAGER, config.txt IS MISSING!")
local data = string.split(config_file:read("*all"), "\n")
local hub_spawn_point = minetest.string_to_pos(string.match(data[1], "= (.*)"))
local additional_items = {}
local physics = {}
-- oggetti
for i = 3, 9 do
additional_items[i-2] = string.match(data[i], "=(.*)")
end
-- fisica
for i = 11, 13 do
physics[string.match(data[i], "(.*)=")] = tonumber(string.match(data[i], "=(.*)"))
end
local sneak = string.match(data[14], "=(.*)")
local sneak_glitch = string.match(data[15], "=(.*)")
local new_move = string.match(data[16], "=(.*)")
if sneak == "true" then
physics.sneak = true
else
physics.sneak = false
end
if sneak_glitch == "true" then
physics.sneak_glitch = true
else
physics.sneak_glitch = false
end
if new_move == "true" then
physics.new_move = true
else
physics.new_move = false
end
config_file:close()
function hub_manager.apply_hub_physics(player)
player:set_physics_override(physics)
end
----------------------------------------------
-----------------GETTERS----------------------
----------------------------------------------
function hub_manager.get_hub_spawn_point()
return hub_spawn_point
end
function hub_manager.get_additional_items()
return additional_items
end
----------------------------------------------
-----------------SETTERS----------------------
----------------------------------------------
function hub_manager.set_hub_physics(player)
player:set_physics_override(physics)
end