-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathserver2.lua
61 lines (54 loc) · 1.34 KB
/
server2.lua
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
57
58
59
60
61
local core=require'hack.scripts.http.core'
reload'hack.scripts.http.core'
local args={...}
local FPS_LIMIT=50
--[[
TODO:
* change game mode should stop the server
* saving/loading users
]]
local is_restart=false
if args[1]=="-r" and server then
server:stop()
is_restart=true
elseif args[1]=='-s' and server then
server:stop()
return
elseif args[1]=='-k' and server then
print("Deleting server data")
server:stop()
server=nil
return
end
if not server then
server=core:server{}
end
server:load_users()
function inst_plug( name, do_reload,args)
local plug=require('hack.scripts.http.'.. name)
if do_reload then
reload('hack.scripts.http.'.. name)
end
server:install_plugin(plug.plug(args or {}))
end
local general_plugs={
'map',
'messages',
'commands',
'spectate',
}
for i,v in ipairs(general_plugs) do
inst_plug(v,is_restart)
end
server.page_vars.message_of_the_day="Arena mode running"
if df.global.gametype==df.game_type.DWARF_ARENA or df.global.gametype==df.game_type.ADVENTURE_ARENA then
inst_plug('economy',is_restart,{server=server})
elseif df.global.gametype==df.game_type.DWARF_MAIN or df.global.gametype==DWARF_RECLAIM or df.global.gametype==DWARF_UNRETIRE then
inst_plug('possession',is_restart,{server=server})
else
error("This mode is not supported")
end
if FPS_LIMIT then
df.global.enabler.fps=FPS_LIMIT
end
server:start()