Skip to content

Commit

Permalink
Added SQLite module and Includes Updater
Browse files Browse the repository at this point in the history
  • Loading branch information
Programie committed Oct 14, 2013
1 parent 5a20807 commit 1038f84
Show file tree
Hide file tree
Showing 5 changed files with 114 additions and 0 deletions.
Binary file added modules/sqlite.dll
Binary file not shown.
Binary file added modules/sqlite.so
Binary file not shown.
1 change: 1 addition & 0 deletions scripts/main.nut
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dofile("scripts/includes.nut");
Binary file added tools/IncludesUpdater.exe
Binary file not shown.
113 changes: 113 additions & 0 deletions tools/IncludesUpdater.pb
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

0 comments on commit 1038f84

Please sign in to comment.