summaryrefslogtreecommitdiffstatshomepage
path: root/3rdparty/sol2/docs/source/tutorial/all-the-things.rst
diff options
context:
space:
mode:
Diffstat (limited to '3rdparty/sol2/docs/source/tutorial/all-the-things.rst')
-rw-r--r--3rdparty/sol2/docs/source/tutorial/all-the-things.rst22
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
---------------------