Engio invocation successful
This commit is contained in:
@@ -769,6 +769,41 @@ void World::invoke_choose(int64_t actor_id, int64_t place_id, std::string_view d
|
|||||||
assert(stack_is_clear());
|
assert(stack_is_clear());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Read a SimpleDynamic value from the streambuffer and push
|
||||||
|
// it onto the lua stack.
|
||||||
|
void push_simple_dynamic(lua_State *L, StreamBuffer *sb) {
|
||||||
|
SimpleDynamicTag type = sb->read_simple_dynamic_tag();
|
||||||
|
switch (type) {
|
||||||
|
case SimpleDynamicTag::NUMBER: {
|
||||||
|
lua_pushnumber(L, sb->read_double());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case SimpleDynamicTag::BOOLEAN: {
|
||||||
|
lua_pushboolean(L, sb->read_bool() ? 1:0);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case SimpleDynamicTag::STRING: {
|
||||||
|
std::string_view s = sb->read_string_view();
|
||||||
|
lua_pushlstring(L, s.data(), s.size());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case SimpleDynamicTag::VECTOR: {
|
||||||
|
double x = sb->read_double();
|
||||||
|
double y = sb->read_double();
|
||||||
|
double z = sb->read_double();
|
||||||
|
lua_newtable(L);
|
||||||
|
lua_pushnumber(L, x);
|
||||||
|
lua_rawseti(L, -2, 1);
|
||||||
|
lua_pushnumber(L, y);
|
||||||
|
lua_rawseti(L, -2, 2);
|
||||||
|
lua_pushnumber(L, z);
|
||||||
|
lua_rawseti(L, -2, 3);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default: throw StreamCorruption();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void World::invoke_engio(int64_t actor_id, int64_t place_id, std::string_view datapack) {
|
void World::invoke_engio(int64_t actor_id, int64_t place_id, std::string_view datapack) {
|
||||||
assert(stack_is_clear());
|
assert(stack_is_clear());
|
||||||
|
|
||||||
@@ -831,23 +866,7 @@ void World::invoke_engio(int64_t actor_id, int64_t place_id, std::string_view da
|
|||||||
// Push any additional args from the datapack.
|
// Push any additional args from the datapack.
|
||||||
try {
|
try {
|
||||||
while (!datasb.empty()) {
|
while (!datasb.empty()) {
|
||||||
SimpleDynamicTag type = datasb.read_simple_dynamic_tag();
|
push_simple_dynamic(L, &datasb);
|
||||||
switch (type) {
|
|
||||||
case SimpleDynamicTag::NUMBER: {
|
|
||||||
lua_pushnumber(L, datasb.read_double());
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case SimpleDynamicTag::BOOLEAN: {
|
|
||||||
lua_pushboolean(L, datasb.read_bool() ? 1:0);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case SimpleDynamicTag::STRING: {
|
|
||||||
std::string_view s = datasb.read_string_view();
|
|
||||||
lua_pushlstring(L, s.data(), s.size());
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default: return;
|
|
||||||
}
|
|
||||||
nargs++;
|
nargs++;
|
||||||
}
|
}
|
||||||
} catch (const StreamException &exc) {
|
} catch (const StreamException &exc) {
|
||||||
|
|||||||
@@ -53,5 +53,8 @@ function mkt()
|
|||||||
|
|
||||||
makeclass("engio")
|
makeclass("engio")
|
||||||
function engio.myfunction(actor, place, a, b, c)
|
function engio.myfunction(actor, place, a, b, c)
|
||||||
print("Myfunction actor=", actor," place=", place, " a=", a, " b=", b, " c=", c)
|
print("Myfunction actor=", actor," place=", place)
|
||||||
|
pprint("A:", a)
|
||||||
|
pprint("B:", b)
|
||||||
|
pprint("C:", c)
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user