Add global variables 'actor' and 'place'
This commit is contained in:
@@ -1139,6 +1139,12 @@ const PrintBuffer *World::get_printbuffer(int64_t actor_id) {
|
||||
}
|
||||
|
||||
void World::clear_lthread_state() {
|
||||
LuaVar globals;
|
||||
LuaExtStack LS(state(), globals);
|
||||
LS.getglobaltable(globals);
|
||||
LS.rawset(globals, "actor", LuaNil);
|
||||
LS.rawset(globals, "place", LuaNil);
|
||||
|
||||
lthread_prints_.reset();
|
||||
lthread_actor_id_ = 0;
|
||||
lthread_place_id_ = 0;
|
||||
@@ -1147,6 +1153,24 @@ void World::clear_lthread_state() {
|
||||
}
|
||||
|
||||
void World::open_lthread_state(int64_t actor, int64_t place, int64_t thread, bool ppool, bool prints) {
|
||||
// Store actor and place in global variables.
|
||||
LuaVar lactor, lplace, tangibles, globals;
|
||||
LuaExtStack LS(state(), lactor, lplace, tangibles, globals);
|
||||
LS.getglobaltable(globals);
|
||||
if ((actor == 0) && (place == 0))
|
||||
{
|
||||
LS.rawset(globals, "actor", LuaNil);
|
||||
LS.rawset(globals, "place", LuaNil);
|
||||
}
|
||||
else
|
||||
{
|
||||
LS.rawget(tangibles, LuaRegistry, "tangibles");
|
||||
LS.rawget(lactor, tangibles, actor);
|
||||
LS.rawget(lplace, tangibles, place);
|
||||
LS.rawset(globals, "actor", lactor);
|
||||
LS.rawset(globals, "place", lplace);
|
||||
}
|
||||
|
||||
lthread_actor_id_ = actor;
|
||||
lthread_place_id_ = place;
|
||||
lthread_thread_id_ = thread;
|
||||
|
||||
Reference in New Issue
Block a user