-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added SQLite module and Includes Updater
- Loading branch information
Showing
5 changed files
with
114 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
dofile("scripts/includes.nut"); |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
Enumeration | ||
#TYPE_EVENTS | ||
#TYPE_FUNCTIONS | ||
#TYPE_PLAYERCOMMANDS | ||
EndEnumeration | ||
|
||
Global serverBasePath$ = GetPathPart(ProgramFilename()) + "..\" | ||
Global NewList Events.s() | ||
Global NewList Includes.s() | ||
Global NewList PlayerCommands.s() | ||
|
||
Procedure addIncludes(type) | ||
Select type | ||
Case #TYPE_EVENTS | ||
directoryName$ = "events" | ||
Case #TYPE_FUNCTIONS | ||
directoryName$ = "functions" | ||
Case #TYPE_PLAYERCOMMANDS | ||
directoryName$ = "commands" | ||
EndSelect | ||
|
||
dir = ExamineDirectory(#PB_Any, serverBasePath$ + "scripts\" + directoryName$, "*.nut") | ||
If IsDirectory(dir) | ||
While NextDirectoryEntry(dir) | ||
name$ = DirectoryEntryName(dir) | ||
If DirectoryEntryType(dir) = #PB_DirectoryEntry_File | ||
name$ = Left(name$, Len(name$) - 4) | ||
|
||
Select type | ||
Case #TYPE_EVENTS | ||
AddElement(Includes()) | ||
Includes() = directoryName$ + "/" + name$ | ||
AddElement(Events()) | ||
Events() = name$ | ||
Case #TYPE_FUNCTIONS | ||
AddElement(Includes()) | ||
Includes() = directoryName$ + "/" + name$ | ||
Case #TYPE_PLAYERCOMMANDS | ||
AddElement(PlayerCommands()) | ||
PlayerCommands() = name$ | ||
EndSelect | ||
EndIf | ||
Wend | ||
FinishDirectory(dir) | ||
EndIf | ||
EndProcedure | ||
|
||
Procedure writeFileHeader(file) | ||
WriteStringN(file, "// Do not edit this file!") | ||
WriteStringN(file, "// Run " + GetFilePart(ProgramFilename()) + " from tools directory to update.") | ||
WriteStringN(file, "") | ||
EndProcedure | ||
|
||
addIncludes(#TYPE_PLAYERCOMMANDS) | ||
|
||
file = CreateFile(#PB_Any, serverBasePath$ + "scripts\events\playerCommand.nut") | ||
If IsFile(file) | ||
writeFileHeader(file) | ||
|
||
WriteStringN(file, "function onPlayerCommand(playerId, command)") | ||
WriteStringN(file, "{") | ||
WriteStringN(file, Chr(9) + "switch (command.slice(1))") | ||
WriteStringN(file, Chr(9) + "{") | ||
|
||
ForEach PlayerCommands() | ||
If PlayerCommands() <> "default" | ||
WriteStringN(file, Chr(9) + Chr(9) + "case " + Chr(34) + PlayerCommands() + Chr(34)+ ":") | ||
WriteStringN(file, Chr(9) + Chr(9) + Chr(9) + "dofile(" + Chr(34) + "scripts/commands/" + PlayerCommands() + ".nut" + Chr(34) + ");") | ||
WriteStringN(file, Chr(9) + Chr(9) + Chr(9) + "break;") | ||
EndIf | ||
Next | ||
|
||
WriteStringN(file, Chr(9) + Chr(9) + "default:") | ||
WriteStringN(file, Chr(9) + Chr(9) + Chr(9) + "dofile(" + Chr(34) + "scripts/commands/default.nut" + Chr(34) + ");") | ||
WriteStringN(file, Chr(9) + Chr(9) + Chr(9) + "return false;") | ||
|
||
WriteStringN(file, Chr(9) + "}") | ||
WriteStringN(file, Chr(9) + "return true;") | ||
WriteStringN(file, "}") | ||
|
||
CloseFile(file) | ||
EndIf | ||
|
||
addIncludes(#TYPE_EVENTS) | ||
addIncludes(#TYPE_FUNCTIONS) | ||
|
||
file = CreateFile(#PB_Any, serverBasePath$ + "scripts\includes.nut") | ||
If IsFile(file) | ||
writeFileHeader(file) | ||
|
||
WriteStringN(file, "// Includes") | ||
ForEach Includes() | ||
WriteStringN(file, "dofile(" + Chr(34) + "scripts/" + Includes() + ".nut" + Chr(34) + ");") | ||
Next | ||
|
||
WriteStringN(file, "") | ||
|
||
WriteStringN(file, "// Events") | ||
ForEach Events() | ||
WriteStringN(file, "addEvent(" + Chr(34) + Events() + Chr(34) + ", " + "on" + UCase(Mid(Events(), 1, 1)) + Mid(Events(), 2) + ");") | ||
Next | ||
|
||
CloseFile(file) | ||
EndIf | ||
; IDE Options = PureBasic 5.11 (Windows - x86) | ||
; CursorPosition = 68 | ||
; FirstLine = 48 | ||
; Folding = - | ||
; EnableXP | ||
; Executable = IncludesUpdater.exe | ||
; EnableCompileCount = 14 | ||
; EnableBuildCount = 13 | ||
; EnableExeConstant |