Minor bug fixing, added patcher for Export.lua, added plugin options to enable/disable mod

This commit is contained in:
Pax1601
2023-02-18 12:52:43 +01:00
parent 433b4bdf56
commit 0308f7c6a3
51 changed files with 767 additions and 271 deletions

View File

@@ -1 +0,0 @@
local Olympuslfs=require('lfs');dofile(Olympuslfs.writedir()..'Scripts/OlympusExport.lua')

View File

@@ -137,7 +137,7 @@ function Olympus.move(ID, lat, lng, altitude, speed, category, taskOptions)
Olympus.notify("Olympus.move not implemented yet for " .. category, 2)
end
else
Olympus.notify("Error in Olympus.move " .. unitName, 2)
Olympus.notify("Error in Olympus.move " .. ID, 2)
end
end

BIN
scripts/OlympusPatcher.exe Normal file

Binary file not shown.

42
scripts/OlympusPatcher.py Normal file
View File

@@ -0,0 +1,42 @@
import shutil
import sys
START_STRING = "/* Olympus START */\n"
END_STRING = "/* Olympus END */\n"
EXPORT_STRING = "local Olympuslfs=require('lfs');dofile(Olympuslfs.writedir()..'Scripts/OlympusExport.lua')\n"
def main(flag):
if flag == "-i":
try:
with open("Export.lua", "r") as f:
shutil.copyfile("Export.lua", "Export.lua.bak")
lines = f.readlines()
if START_STRING in lines:
return
except FileNotFoundError:
print('File does not exist')
with open("Export.lua", "a") as f:
f.writelines(["\n", START_STRING, EXPORT_STRING, END_STRING, "\n"])
elif flag == "-u":
try:
with open("Export.lua", "r") as f:
shutil.copyfile("Export.lua", "Export.lua.bak")
lines = f.readlines()
except FileNotFoundError:
print('File does not exist')
with open("Export.lua", "w") as f:
block = False
for line in lines:
if line == START_STRING:
block = True
if not block:
f.write(line)
if line == END_STRING:
block = False
if __name__ == "__main__":
main(sys.argv[1])