Jump to content
  • 0

Help with gg.saveVariable()


slaimmials
 Share

Question

1 answer to this question

Recommended Posts

  • 0

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)

 

Edited by Count_Nosferatu
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • 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.