mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-04 18:41:51 +00:00
feat: component script reloading
This commit is contained in:
parent
267aebe7bd
commit
4761c520d5
6 changed files with 42 additions and 22 deletions
|
|
@ -223,6 +223,18 @@ static int l_raycast(lua::State* L) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int l_reload_component(lua::State* L) {
|
||||
std::string name = lua::require_string(L, 1);
|
||||
size_t pos = name.find(':');
|
||||
if (pos == std::string::npos) {
|
||||
throw std::runtime_error("missing entry point");
|
||||
}
|
||||
auto filename = name.substr(0, pos + 1) + "scripts/components/" +
|
||||
name.substr(pos + 1) + ".lua";
|
||||
scripting::load_entity_component(name, filename, filename);
|
||||
return 0;
|
||||
}
|
||||
|
||||
const luaL_Reg entitylib[] = {
|
||||
{"exists", lua::wrap<l_exists>},
|
||||
{"def_index", lua::wrap<l_def_index>},
|
||||
|
|
@ -238,5 +250,6 @@ const luaL_Reg entitylib[] = {
|
|||
{"get_all_in_box", lua::wrap<l_get_all_in_box>},
|
||||
{"get_all_in_radius", lua::wrap<l_get_all_in_radius>},
|
||||
{"raycast", lua::wrap<l_raycast>},
|
||||
{"reload_component", lua::wrap<l_reload_component>},
|
||||
{NULL, NULL}
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue