-
Notifications
You must be signed in to change notification settings - Fork 6
/
Main.lua
64 lines (55 loc) · 1.74 KB
/
Main.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
62
63
64
--=============================================================================
--
-- lua/Main.lua
--
-- Created by Max McGuire ([email protected])
-- Copyright 2010, Unknown Worlds Entertainment
--
-- This script is loaded when the game first starts. It handles creation of
-- the main menu.
--=============================================================================
-- Set the name of the VM for debugging
decoda_name = "Main"
Script.Load("lua/Globals.lua")
Script.Load("lua/MainMenu.lua")
mods = { "ns2lua" }
maps =
{
{ name = "Range #1", fileName = "ns2_dm1.level" },
{ name = "Range #2", fileName = "ns2_dm2.level" },
{ name = "Test Level", fileName = "test.level" },
{ name = "Splay", fileName = "splay.level" },
}
--
-- Called when the user types the "map" command at the console.
--/
function OnCommandMap(mapFileName)
MainMenu_HostGame(mapFileName)
end
--
-- Called when the user types the "connect" command at the console.
--/
function OnCommandConnect(serverAddress)
MainMenu_JoinGame(serverAddress)
end
--
-- Called when the user types the "exit" command at the console or clicks the exit button.
--/
function OnCommandExit()
Main.Exit()
end
Event.Hook("Console_connect", OnCommandConnect)
Event.Hook("Console_map", OnCommandMap)
Event.Hook("Console_exit", OnCommandExit)
Event.Hook("Console_quit", OnCommandExit)
function OnConsoleMLua(...)
local str = table.concat( { ... }, " " ):gsub( "%s?([%[%]\\%.%?])%s?", "%1" )
Shared.Message( "(Menu) Running lua: " .. str )
local good, err = loadstring(str)
if not good then
Shared.Message( err )
return
end
good()
end Event.Hook("Console_mlua", OnConsoleMLua)
Main.SetMenu( kMainMenuFlash )