MCPcopy Create free account
hub / github.com/ThePhD/sol2 / main

Function main

examples/source/tutorials/writing_functions.cpp:10–28  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

8}
9
10int main() {
11
12 sol::state lua;
13
14 lua["my_func"] = my_function; // way 1
15 lua.set("my_func", my_function); // way 2
16 lua.set_function("my_func", my_function); // way 3
17
18 // This function is now accessible as 'my_func' in
19 // lua scripts / code run on this state:
20 lua.script("some_str = my_func(1, 'Da')");
21
22 // Read out the global variable we stored in 'some_str' in
23 // the quick lua code we just executed
24 std::string some_str = lua["some_str"];
25 SOL_ASSERT(some_str == "DaD");
26
27 return 0;
28}

Callers

nothing calls this directly

Calls 2

scriptMethod · 0.80
setMethod · 0.45

Tested by

no test coverage detected