Jump to content

Real World Time Script. HELP!


Neon

Recommended Posts

Ok so I am trying to build a real-world time script that will update a given mission before it runs via a loader mission. I am stuck, I had it all figured out before I found out that DCS lua interpreter doesnt have textutils in it. If any of you more lua savvy modders could take a look and offer any advice that would be great.

 

local textutils = require('textutils')
local minizip				= require('minizip')
local OS_Hour = os.date("%H")
local OS_Min = os.date("%M")
local OS_Sec = os.date("%S")
local missionszip = 'GorgasV4.miz'
--local day = tostring"["Day"] = "..os.date( "%d" )..","
--local year = "["Year"] = "..os.date( "%Y" )..",""
--local month = "["Month"] = "..os.date( "%m" )..","
--local localtime = {["start_time"] = }..os.time{year=1970, month=1, day=1, hour=OS_Hour, min=OS_Min, sec=OS_Sec}..{,}



local zipFile = minizip.unzOpen('C:\\Dropbox\\GorgasV4.miz', 'rb')
zipFile:unzLocateFile('mission')
local misStr = zipFile:unzReadAllCurrentFile()
local misStrFunc = loadstring(misStr)()-- convert file to string
misTab={}
str=sContents
str:gsub(".",function(c) table.insert(t,c) end)
zipFile:unzClose()


--local z = zip.open(missionzip)

--sContents = z:extract('mission')

--zip:close()

--First lets read the file and put the contents in a table name tContents
--local file = io.open("mission", "r")
--sContents = file:read() -- capture file in a string
--file:close()
--tContents = textutils.unserialize(sContents) -- convert string to table


--Modify a specific line
table.remove(misTab, 13) 
table.insert(misTab, 13, [=[["Day"] =]=]..os.date( "%d" )..[=[,]=])

--Modify a specific line
table.remove(misTab, 14)
table.insert(misTab, 14, [=[["Year"] =]=]..os.date( "%Y" )..[=[,]=])

--Modify a specific line
table.remove(misTab, 15) 
table.insert(misTab, 15, [=[ ["Month"] =]=]..os.date( "%m" )..[=[,]=]) 

--Modify a specific line
table.remove(misTab, 17) 
table.insert(misTab, 17, [=[ ["start_time"] =]=]..os.time{year=1970, month=1, day=1, hour=OS_Hour, min=OS_Min, sec=OS_Sec}..[=[,]=]) 

-- Convert table to string and save the file
local misStr = TableSerialization(misTab, 0)
local misFile = io.open("misFile.lua", "w")											--mission
misFile:write(misStr)
misFile:close()
local zipFile = minizip.unzOpen('C:\\Dropbox\\GorgasV4.miz', 'w')
zipFile:zipAddFile("mission", "misFile.lua")
zipFile:unzClose()
os.remove("misFile.lua")

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...