Skip to content

Commit 0dfd57c

Browse files
authored
Merge pull request #2 from droyti/experimental
3.0 Experimental to Master
2 parents a27b0d0 + 6ead306 commit 0dfd57c

File tree

6 files changed

+442
-469
lines changed

6 files changed

+442
-469
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
builds/

LoadAnyLevel.tseproj

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"formatVersion": "1",
3+
"tool": {
4+
"game": "TTDS"
5+
},
6+
"mod": {
7+
"name": "Load Any Level",
8+
"version": "3.0",
9+
"author": "Droyti"
10+
}
11+
}

WDC_pc_Boot_data/Boot.lua

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
--[[
1+
--[[
22
MIT License
33
Copyright (c) 2020 Droyti
44
Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -17,33 +17,33 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
1717
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
1818
SOFTWARE.
1919
--]]
20-
20+
-- params : ...
21+
-- function num : 0 , upvalues : _ENV
2122
local LIP = require("LIP.lua")
22-
23-
function file_exists(name)
24-
local f=io.open(name,"r")
25-
if f~=nil then io.close(f) return true else return false end
23+
file_exists = function(name)
24+
-- function num : 0_0 , upvalues : _ENV
25+
local f = (io.open)(name, "r")
26+
if f ~= nil then
27+
(io.close)(f)
28+
return true
29+
else
30+
return false
31+
end
2632
end
2733

28-
29-
if not file_exists("loadanylevel.ini") then
30-
local creation =
31-
{
32-
boot =
33-
{
34-
overrideBootSequence = false,
35-
archiveToLoad = 'Menu',
36-
scriptToLoad = 'Menu_Main'
37-
}
38-
};
39-
40-
LIP.save("loadanylevel.ini", creation)
34+
do
35+
if not file_exists("loadanylevel.ini") then
36+
local creation = {
37+
boot = {overrideBootSequence = false, archiveToLoad = "Menu", scriptToLoad = "Menu_Main"}
38+
}
39+
;
40+
(LIP.save)("loadanylevel.ini", creation)
41+
end
42+
local data = (LIP.load)("loadanylevel.ini")
43+
if (data.boot).overrideBootSequence then
44+
SubProject_Switch((data.boot).archiveToLoad, (data.boot).scriptToLoad .. ".lua")
45+
else
46+
LoadScript("BootTitle.lua")
47+
end
4148
end
4249

43-
local data = LIP.load("loadanylevel.ini")
44-
45-
if data.boot.overrideBootSequence then
46-
SubProject_Switch(data.boot.archiveToLoad, data.boot.scriptToLoad .. ".lua")
47-
else
48-
LoadScript("BootTitle.lua")
49-
end

WDC_pc_Boot_data/LIP.lua

Lines changed: 60 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
1-
--[[
2-
Copyright (c) 2012 Carreras Nicolas
3-
4-
Permission is hereby granted, free of charge, to any person obtaining a copy
5-
of this software and associated documentation files (the "Software"), to deal
6-
in the Software without restriction, including without limitation the rights
7-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8-
copies of the Software, and to permit persons to whom the Software is
9-
furnished to do so, subject to the following conditions:
10-
11-
The above copyright notice and this permission notice shall be included in all
12-
copies or substantial portions of the Software.
13-
14-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20-
SOFTWARE.
1+
--[[
2+
Copyright (c) 2012 Carreras Nicolas
3+
4+
Permission is hereby granted, free of charge, to any person obtaining a copy
5+
of this software and associated documentation files (the "Software"), to deal
6+
in the Software without restriction, including without limitation the rights
7+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8+
copies of the Software, and to permit persons to whom the Software is
9+
furnished to do so, subject to the following conditions:
10+
11+
The above copyright notice and this permission notice shall be included in all
12+
copies or substantial portions of the Software.
13+
14+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20+
SOFTWARE.
2121
--]]
2222
--- Lua INI Parser.
2323
-- It has never been that simple to use INI files with Lua.
@@ -29,52 +29,52 @@ local LIP = {};
2929
--@param fileName The name of the INI file to parse. [string]
3030
--@return The table containing all data from the INI file. [table]
3131
function LIP.load(fileName)
32-
assert(type(fileName) == 'string', 'Parameter "fileName" must be a string.');
33-
local file = assert(io.open(fileName, 'r'), 'Error loading file : ' .. fileName);
34-
local data = {};
35-
local section;
36-
for line in file:lines() do
37-
local tempSection = line:match('^%[([^%[%]]+)%]$');
38-
if(tempSection)then
39-
section = tonumber(tempSection) and tonumber(tempSection) or tempSection;
40-
data[section] = data[section] or {};
41-
end
42-
local param, value = line:match('^([%w|_]+)%s-=%s-(.+)$');
43-
if(param and value ~= nil)then
44-
if(tonumber(value))then
45-
value = tonumber(value);
46-
elseif(value == 'true')then
47-
value = true;
48-
elseif(value == 'false')then
49-
value = false;
50-
end
51-
if(tonumber(param))then
52-
param = tonumber(param);
53-
end
54-
data[section][param] = value;
55-
end
56-
end
57-
file:close();
58-
return data;
32+
assert(type(fileName) == 'string', 'Parameter "fileName" must be a string.');
33+
local file = assert(io.open(fileName, 'r'), 'Error loading file : ' .. fileName);
34+
local data = {};
35+
local section;
36+
for line in file:lines() do
37+
local tempSection = line:match('^%[([^%[%]]+)%]$');
38+
if(tempSection)then
39+
section = tonumber(tempSection) and tonumber(tempSection) or tempSection;
40+
data[section] = data[section] or {};
41+
end
42+
local param, value = line:match('^([%w|_]+)%s-=%s-(.+)$');
43+
if(param and value ~= nil)then
44+
if(tonumber(value))then
45+
value = tonumber(value);
46+
elseif(value == 'true')then
47+
value = true;
48+
elseif(value == 'false')then
49+
value = false;
50+
end
51+
if(tonumber(param))then
52+
param = tonumber(param);
53+
end
54+
data[section][param] = value;
55+
end
56+
end
57+
file:close();
58+
return data;
5959
end
6060

6161
--- Saves all the data from a table to an INI file.
6262
--@param fileName The name of the INI file to fill. [string]
6363
--@param data The table containing all the data to store. [table]
6464
function LIP.save(fileName, data)
65-
assert(type(fileName) == 'string', 'Parameter "fileName" must be a string.');
66-
assert(type(data) == 'table', 'Parameter "data" must be a table.');
67-
local file = assert(io.open(fileName, 'w+b'), 'Error loading file :' .. fileName);
68-
local contents = '';
69-
for section, param in pairs(data) do
70-
contents = contents .. ('[%s]\n'):format(section);
71-
for key, value in pairs(param) do
72-
contents = contents .. ('%s=%s\n'):format(key, tostring(value));
73-
end
74-
contents = contents .. '\n';
75-
end
76-
file:write(contents);
77-
file:close();
65+
assert(type(fileName) == 'string', 'Parameter "fileName" must be a string.');
66+
assert(type(data) == 'table', 'Parameter "data" must be a table.');
67+
local file = assert(io.open(fileName, 'w+b'), 'Error loading file :' .. fileName);
68+
local contents = '';
69+
for section, param in pairs(data) do
70+
contents = contents .. ('[%s]\n'):format(section);
71+
for key, value in pairs(param) do
72+
contents = contents .. ('%s=%s\n'):format(key, tostring(value));
73+
end
74+
contents = contents .. '\n';
75+
end
76+
file:write(contents);
77+
file:close();
7878
end
7979

8080
return LIP;

0 commit comments

Comments
 (0)