diff options
author | 2016-11-06 10:05:36 +0100 | |
---|---|---|
committer | 2016-11-06 10:05:36 +0100 | |
commit | c2a75cb1799a31aa5687e576d1c0bdd50825fded (patch) | |
tree | 59144f444d666ae20ac8fb2bc4e4553d330945ca /3rdparty/sol2/docs/source/tutorial/all-the-things.rst | |
parent | fffd464d345a6368cda7d90945d3409151218a06 (diff) |
Updated sol2, made lua console not crash for nil data (nw)
Diffstat (limited to '3rdparty/sol2/docs/source/tutorial/all-the-things.rst')
-rw-r--r-- | 3rdparty/sol2/docs/source/tutorial/all-the-things.rst | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/3rdparty/sol2/docs/source/tutorial/all-the-things.rst b/3rdparty/sol2/docs/source/tutorial/all-the-things.rst index fa9e73ac6c0..3695ac77fe2 100644 --- a/3rdparty/sol2/docs/source/tutorial/all-the-things.rst +++ b/3rdparty/sol2/docs/source/tutorial/all-the-things.rst @@ -47,6 +47,10 @@ running lua code int value = lua.script("return 54"); // value == 54 +To check the success of a loading operation: + +.. code-block:: cpp + // load file without execute sol::load_result script1 = lua.load_file("path/to/luascript.lua"); script1(); //execute @@ -59,6 +63,24 @@ running lua code // value2 == 24 +To check whether a script was successfully run or not (after loading is assumed to be successful): + +.. code-block:: cpp + + // execute and return result + sol::protected_function_result result1 = lua.do_string("return 24"); + if (result1.valid()) { + int value = result1; + // value == 24 + // yay! + } + else { + // ahhh :c + } + + +There is also ``lua.do_file("path/to/luascript.lua");``. + set and get variables --------------------- |