aboutsummaryrefslogtreecommitdiff
path: root/gamemode/config/sv_newplayer.lua
blob: 403e9334670da994bad6e71e4791993caaae10df (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
--- Holds the data new players should be spawned with.
-- If new inventories central to the gamemode are added,
-- players should probably spawn with them. Add the
-- inventory to np.data.
--@server sv_newplayer.lua
--@alias np

local np = {}
local inv = nrequire("inventory/inventory.lua")
nrequire("inventorysystem/equipment/sh_equipment.lua")
nrequire("inventorysystem/shapedinventory/sh_shaped.lua")
nrequire("inventorysystem/abilities/sh_abilities.lua")
nrequire("inventorysystem/skills/sh_skills.lua")
nrequire("inventorysystem/quests/sh_quests.lua")
local log = nrequire("log.lua")
--local itm = nrequire("inventory/item.lua")

--- The data that players spawn with.
-- @table data
-- @field inventories
-- @usage
-- local np = nrequire("config/sv_newplayer.lua")
-- local inv = nrequire("inventory/inventory.lua")
-- local invtbl = np.data.inventories
-- invtbl[#invtbl + 1] = {"My New Inventory",inv.CreateInventory("MyInventory"):Serialize()}
np.data = {
	inventories = {
		{"Equipment", inv.CreateInventory("Equipment"):Serialize()},
		{"Shaped Inventory",inv.CreateInventory("Shaped Inventory"):Serialize()},
		{"Abilities",inv.CreateInventory("Abilities"):Serialize()},
		{"Skills",inv.CreateInventory("Skills"):Serialize()},
		{"Quests",inv.CreateInventory("Quests"):Serialize()},
	},
}

--- Function called with a new player needs default data.
-- By default, this function just returns np.data
-- You can overwrite it to return any other table though.
-- @treturn table The new data to return
np.newdata = function()
	log.debug("newdata asked for")
	log.debug(table.ToString(np.data,"data",true))
	return np.data
end

--- Function to return metadata for a player.
-- This just returns a server and location for the player to spawn.
np.newmeta = function()
	log.debug("newmeta asked for")
	return {
		lastserver = "67.163.245.187:27015",
		lastlocation = "-1209 1544 -1770"
	}
end

return np