-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathboot.lua
executable file
·94 lines (67 loc) · 2.32 KB
/
boot.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
--This is the Boot-Script of Cubo
--Feel free to play around with the scripts...
PreferZip=1;
--Set to 0, if you are interested in developing
--You can extract files from the data-zip and modify it. If you've set PreferZip to 0, Cubo will prefer the extracted (and possibly modified) files
--VERSION
VERSION=0.3;
USING("FILESYS");
logmode=0;
desiredmod="";
function PreParseCmdLine()
--print("COMMANDLINE");
for i=0,ARGS_Count()-1,1 do
local key=ARGS_Key(i);
local var=ARGS_Val(i);
if key=="log" then
logmode=1;
elseif key=="mod" then
desiredmod=var;
end;
end;
return 0;
end;
GLOBAL_SetVar("CuboVersion",VERSION);
PreParseCmdLine();
LOG_Mode(logmode);
print("Cubosphere - Beta 0.3 - starting");
print("###############################################");
print(" Copyright (C) 2009-2013 by the Cubosphere Team \n ");
print(" This program comes with ABSOLUTELY NO WARRANTY; for details see readme.");
print(" This is free software, and you are welcome to redistribute it under certain\n conditions; see readme for details. \n");
print("###############################################");
function MountAllZips()
local numf=FILESYS_StartListDirectory("/",true,false,false,true,".*data.*\\.zip"); --List root dir, list files, no dirs, not recursive, get the fullpath, filter *.zip
for i=0,numf-1,1 do
local zipfile=FILESYS_GetListDirectoryEntry(i);
if FILESYS_MountZip(zipfile,"/")~=0 then
print("Mounted ZIP: "..zipfile);
end;
end;
end;
--Mounting-Code:
--When executing this script, there is already the DATA-Dir mounted to the stack
if PreferZip==1 then
print("Mounted HDD dir: "..DIR_GetDataDir());
MountAllZips();
else
MountAllZips();
FILESYS_PopBottom(); --Remove the data-dir at the bottom..
FILESYS_MountHDDDir(DIR_GetDataDir(),"/");
print("Mounted HDD dir: "..DIR_GetDataDir());
end;
FILESYS_MountWriteableHDDDir(DIR_GetProfileDir(),"/user");
print("Mounted writeable HDD dir: "..DIR_GetProfileDir().." @ ".."/user");
if desiredmod~="" then
if FILESYS_FileExists("/mods/"..desiredmod.."/modboot.lua")==0 then
print("Cannot boot mod "..desiredmod);
GLOBAL_Quit();
else
print("Starting Modification : "..desiredmod);
MOD_SetName(desiredmod);
INCLUDEABSOLUTE("/mods/"..desiredmod.."/modboot.lua");
MENU_Load("init");
end;
else
MENU_Load("init");
end;