Jump to content
  • 0

Save as .cfg between restarts of script


YeetMeister

Question

So im creating a script for FWD Assault

My problem is when i save values to different tables, the other tables just dissapear

Now i want to add values to an existing table, how to do that?

And after that when i close the script i wanted to save the values, with the desired address to a .cfg file and on executing the script it should open the .cfg file

Link to comment
Share on other sites

2 answers to this question

Recommended Posts

34 minutes ago, YeetMeister said:

i wanted to save the values, with the desired address to a .cfg file and on executing the script it should open the .cfg file

I dont get this

gg.saveVariable()

local t = {}

t['test1'] = {1, 2, 3, 4}

t['test2'] = 42

t['test3'] = 86.3

t['test4'] = 'weapon'

t[4] = t['test1']

gg.saveVariable(t, '/sdcard/test.lua') -- saved

local var = assert(loadfile('/sdcard/test.lua'))() -- loaded

-- Saving input between script restarts

local configFile = gg.getFile()..'.cfg'

local data = loadfile(configFile)

if data ~= nil then data = data() end

local input = gg.prompt({'Please input something'}, data)

if input == nil then os.exit() end

gg.saveVariable(input, configFile)

 

@Enyby

Link to comment
Share on other sites

4 hours ago, YeetMeister said:

I dont get this

gg.saveVariable()

local t = {}

t['test1'] = {1, 2, 3, 4}

t['test2'] = 42

t['test3'] = 86.3

t['test4'] = 'weapon'

t[4] = t['test1']

gg.saveVariable(t, '/sdcard/test.lua') -- saved

local var = assert(loadfile('/sdcard/test.lua'))() -- loaded

-- Saving input between script restarts

local configFile = gg.getFile()..'.cfg'

local data = loadfile(configFile)

if data ~= nil then data = data() end

local input = gg.prompt({'Please input something'}, data)

if input == nil then os.exit() end

gg.saveVariable(input, configFile)

 

@Enyby

local configFile = gg.EXT_CACHE_DIR .. "/" .. gg.getFile():match("[^/]+$") .. ".cfg"
local data = loadfile(configFile)
if data ~= nil then
  data = data()
end
local input = gg.prompt({'Please input something .'},data, {"number"}) -- type here number or text , which you want
gg.saveVariable(input, configFile)

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.