| 7 | #include <iostream> |
| 8 | |
| 9 | int main(int, char*[]) { |
| 10 | std::cout << "=== customization: vec3 as table ===" |
| 11 | << std::endl; |
| 12 | |
| 13 | sol::state lua; |
| 14 | lua.open_libraries(sol::lib::base); |
| 15 | |
| 16 | std::cout << "registering entities into Lua ..." |
| 17 | << std::endl; |
| 18 | register_lua(lua); |
| 19 | std::cout << "running script ..." << std::endl; |
| 20 | |
| 21 | const auto& script = R"lua( |
| 22 | local e = entity.new() |
| 23 | local pos = e.position |
| 24 | print("pos type", type(pos)) |
| 25 | print("pos", pos.x, pos.y, pos.z) |
| 26 | e.position = { x = 52, y = 5.5, z = 47.5 } |
| 27 | local new_pos = e.position |
| 28 | print("pos", pos.x, pos.y, pos.z) |
| 29 | print("new_pos", new_pos.x, new_pos.y, new_pos.z) |
| 30 | )lua"; |
| 31 | |
| 32 | sol::optional<sol::error> result = lua.safe_script(script); |
| 33 | if (result.has_value()) { |
| 34 | std::cerr << "Something went horribly wrong: " |
| 35 | << result.value().what() << std::endl; |
| 36 | } |
| 37 | |
| 38 | std::cout << "finishing ..." << std::endl; |
| 39 | |
| 40 | std::cout << std::endl; |
| 41 | return 0; |
| 42 | } |
nothing calls this directly
no test coverage detected