Fix issue in Rocket.lua script.
[Cafu-Engine.git] / config.lua
blob41f52461655016aaa7824e525b8a8d30e9a0561c
1 print=function(s)
2 Console.Print(tostring(s) .. "\n");
3 end;
5 exit=function()
6 quit=true;
7 end
9 -- Just for debugging the new physics code...
10 function ph(grav)
11 grav=grav or -9.81;
12 runMapCmd("wait(3); crate_001:SetGravity(0, 0, "..grav..");");
13 end
15 -- Load the console variables with persistent values.
17 CleanupPersistentConfig("config_p.lua");
18 local Result, ErrorMsg=loadfile("config_p.lua");
20 if (Result) then
21 Result();
22 else
23 print("\nWarning: Error when running config_p.lua ("..ErrorMsg..").\n");
24 end
25 end
28 -- Get the (sorted) list of files available as level intro music.
29 MusicFiles=Console.GetDir("Games/DeathMatch/Music", "f");
30 table.sort(MusicFiles, function (s1, s2) return s1:lower()<s2:lower(); end); -- Sort the titles regardless of case.
32 -- Filter the list (not every file is a good candidate for level intro music) and add the full path.
33 LevelIntroTitles={};
34 for FileNr, FileName in ipairs(MusicFiles) do
35 if ((FileName:sub(-4, -1)==".ogg" or FileName:sub(-4, -1)==".mp3") and FileName:find("Franka Jones, Track3")==nil) then
36 LevelIntroTitles[#LevelIntroTitles+1]="Games/DeathMatch/Music/"..FileName;
37 end
38 end
40 -- The client calls this function whenever the player enters a new level.
41 function StartLevelIntroMusic()
42 if (#LevelIntroTitles==0) then return end;
44 local NextTitleNr=0;
46 -- Read the index number of the next title to play.
47 local File=io.open("Games/DeathMatch/Music/NextTitle.txt", "r");
49 if (File) then
50 NextTitleNr=(File:read("*number") or 0) % #LevelIntroTitles;
51 File:close();
52 end
54 -- Update the next index number count.
55 local File=io.open("Games/DeathMatch/Music/NextTitle.txt", "w");
57 if (File) then
58 File:write((NextTitleNr+1) % #LevelIntroTitles);
59 File:close();
60 end
62 MusicLoad(LevelIntroTitles[NextTitleNr+1]); -- First array index is 1, not 0.
63 MusicSetVolume(0.5);
64 MusicPlay();
65 end
68 function pts2csv(fileName)
69 if fileName:sub(-4, -1):lower()==".pts" then
70 -- Strip the .pts suffix, if present.
71 fileName=fileName:sub(1, -5);
72 end
74 -- Load and run the point file in order to obtain the Points table.
75 dofile(fileName .. ".pts");
77 -- Write all points into a new csv file.
78 local csvFile=assert(io.open(fileName .. ".csv", "w"));
80 csvFile:write('"time","x","y","z","heading","info"\n');
81 for i=1, #Points do
82 csvFile:write("\"", table.concat(Points[i], "\",\""), "\"\n");
83 end
85 csvFile:close();
86 end
89 -- sv_AutoAddCompanyBot=true;
90 -- cl_maxLights=20;
93 sv_rc_password="ca3de"; -- Change this for your own (dedicated) servers!
94 cl_rc_password="ca3de";
97 print("config.lua processed.");