Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 16 additions & 7 deletions examples/lua/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,20 @@ int main(int argc, char** argv)

std::string new_package_path = s["package"]["path"];

sol::function function = s.script_file("scripts/example.lua");

do
try
{
sol::table module_example = s.load_file("scripts/example.lua").call();
sol::function update_func = module_example["update"];
do
{
std::this_thread::sleep_for(std::chrono::milliseconds(16));
} while (!update_func(50.0 / 1000));
}
catch (const sol::error& e)
{
std::this_thread::sleep_for(std::chrono::milliseconds(16));
} while (!function.call(50.0 / 1000));
std::cerr << "Error: " << e.what() << std::endl;
return -1;
}
#else
kaguya::State s;
s.openlibs();
Expand All @@ -65,11 +73,12 @@ int main(int argc, char** argv)
s["package"]["path"] = package_path;

auto function = s.loadfile("scripts/example.lua");
auto update = function();
auto module_example = function();
auto update_func = module_example["update"];
do
{
std::this_thread::sleep_for(std::chrono::milliseconds(50));
} while (!update(50.0 / 1000));
} while (!update_func(50.0 / 1000));
#endif
return 0;
}
2 changes: 1 addition & 1 deletion yasio/bindings/lyasio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -795,7 +795,7 @@ end

char version[32];
snprintf(version, sizeof(version), "%x.%x.%x", (YASIO_VERSION_NUM >> 16) & 0xff, (YASIO_VERSION_NUM >> 8) & 0xff, YASIO_VERSION_NUM & 0xff);
YASIO_EXPORT_ANY(version);
yasio_lib["version"] = std::string(version);

return yasio_lib.push(); /* return 'yasio' table */
}
Expand Down
Loading