Jump to content
  • 0

Help with gg.saveVariable()


slaimmials

Question

1 answer to this question

Recommended Posts

Quote from https://www.lua.org/manual/5.1/manual.html

Quote

5.1 – Basic Functions
The basic library provides some core functions to Lua.
If you do not include this library in your application, you should check carefully whether you need to provide implementations for some of its facilities.
assert (v [, message])
Issues an error when the value of its argument v is false (i.e., nil or false); otherwise, returns all its arguments. message is an error message; when absent,
it defaults to "assertion failed!"

Small change to a line from documentation

local configFile = gg.getFile()..'.cfg'
-- local var = assert(loadfile("directory"))()
local var = assert(loadfile(configFile), ' CONFIG FILE NOT FOUND !!! :-( ')()

If .cfg file does'nt exist, we will receive an error message:
 

Script ended:
Script error: luaj.o: /storage/emulated/0/....../test-assert.lua:5
`local var = assert(loadfile(configFile), ' CONFIG FILE NOT FOUND !!!  ')()`
 CONFIG FILE NOT FOUND !!!  (global 'assert')
..blah.. blah.. blah..

An example script looks like:

Examples of Lua scripts (#1lj25n68)

 

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.