parent
f46b5f15ef
commit
9c03e850b5
@ -1,17 +1,26 @@ |
|||||||
#define SOL_ALL_SAFETIES_ON 1 |
#define SOL_ALL_SAFETIES_ON 1 |
||||||
#include <sol/sol.hpp> |
#include <sol/sol.hpp> |
||||||
|
#include <cassert> |
||||||
#include <iostream> |
#include <iostream> |
||||||
|
#include <fmt/core.h> |
||||||
|
#include "components.hpp" |
||||||
|
|
||||||
|
using namespace fmt; |
||||||
|
using namespace components; |
||||||
|
|
||||||
int main(int, char*[]) { |
int main(int, char*[]) { |
||||||
std::cout << "=== opening a state ===" << std::endl; |
std::cout << "=== opening a state ===" << std::endl; |
||||||
|
|
||||||
sol::state lua; |
sol::state lua; |
||||||
// open some common libraries
|
lua.open_libraries(sol::lib::base); |
||||||
lua.open_libraries(sol::lib::base, sol::lib::package); |
auto motion = Motion{1, -1}; |
||||||
lua.script("print('bark bark bark!')"); |
lua.new_usertype<Motion>("Motion", |
||||||
|
"dx", &Motion::dx, |
||||||
|
"dy", &Motion::dy |
||||||
|
); |
||||||
|
|
||||||
std::cout << std::endl; |
lua["motion"] = &motion; |
||||||
|
|
||||||
|
lua.script("print('dx', motion.dx, 'dy', motion.dy)"); |
||||||
return 0; |
return 0; |
||||||
} |
} |
||||||
|
Loading…
Reference in new issue