More work on the LuaCall interface
This commit is contained in:
@@ -141,38 +141,32 @@ void AIntegrationGameModeBase::UpdateTangibles() {
|
||||
TangibleManager->DeleteFarawayTangibles();
|
||||
}
|
||||
|
||||
// void AIntegrationGameModeBase::InvokeEngioMove(const FString &action, const FVector &xyz, double facing) {
|
||||
// FTCHARToUTF8 utf8action(action);
|
||||
// std::string uaction(utf8action.Get(), utf8action.Length());
|
||||
// FlxStreamBuffer sb;
|
||||
// sb.write_string("engio");
|
||||
// sb.write_string("move");
|
||||
// sb.write_simple_dynamic_tag(SimpleDynamicTag::STRING);
|
||||
// sb.write_string(uaction);
|
||||
// sb.write_simple_dynamic_tag(SimpleDynamicTag::VECTOR);
|
||||
// sb.write_fvector(xyz);
|
||||
// sb.write_simple_dynamic_tag(SimpleDynamicTag::NUMBER);
|
||||
// sb.write_double(facing);
|
||||
// std::string_view datapk = sb.view();
|
||||
// FlxLockedWrapper w(LockableWrapper);
|
||||
// int64 player = w.GetActor();
|
||||
// w->play_call_function_lua_call(w.Get(), player, datapk.size(), datapk.data());
|
||||
// }
|
||||
|
||||
void AIntegrationGameModeBase::LuaCallInvoke(AActor *place) {
|
||||
void AIntegrationGameModeBase::LuaCallEnd(InvocationKind kind, int64 place_id) {
|
||||
std::string_view datapk = LuaCallBuffer.view();
|
||||
FlxLockedWrapper w(LockableWrapper);
|
||||
int64_t place_id = w.GetActor();
|
||||
if (place != nullptr) {
|
||||
place_id = UlxTangible::GetActorTangible(place)->TangibleId;
|
||||
if (place_id == 0) place_id = w.GetActor();
|
||||
uint32_t retpklen;
|
||||
const char *retpk;
|
||||
w->play_call_function(w.Get(), kind, place_id, datapk.size(), datapk.data(), &retpklen, &retpk);
|
||||
LuaCallResult.open(std::string_view(retpk, retpklen));
|
||||
}
|
||||
|
||||
void AIntegrationGameModeBase::LuaCallEnd(InvocationKind kind) {
|
||||
LuaCallEnd(kind, int64(0));
|
||||
}
|
||||
|
||||
void AIntegrationGameModeBase::LuaCallEnd(InvocationKind kind, AActor *place) {
|
||||
if (place == nullptr) {
|
||||
LuaCallEnd(kind, int64(0));
|
||||
} else {
|
||||
LuaCallEnd(kind, UlxTangible::GetActorTangible(place)->TangibleId);
|
||||
}
|
||||
w.PlayCallFunction(InvocationKind::LUA_CALL, place_id, datapk);
|
||||
}
|
||||
|
||||
void AIntegrationGameModeBase::ExecuteDebuggingCommand(FlxLockedWrapper &w, const FString &fs) {
|
||||
if (fs == "\\invokeplayer") {
|
||||
DPrint(TEXT("Trying to invoke 'myfunction' in lua"));
|
||||
FlxStreamBuffer sb;
|
||||
FlxStreamBuffer &sb = LuaCallBegin();
|
||||
sb.write_string("engio");
|
||||
sb.write_string("myfunction");
|
||||
sb.write_simple_dynamic_tag(SimpleDynamicTag::NUMBER);
|
||||
@@ -181,9 +175,7 @@ void AIntegrationGameModeBase::ExecuteDebuggingCommand(FlxLockedWrapper &w, cons
|
||||
sb.write_string("Howdy");
|
||||
sb.write_simple_dynamic_tag(SimpleDynamicTag::VECTOR);
|
||||
sb.write_fvector(FVector(2,3,4));
|
||||
std::string_view datapk = sb.view();
|
||||
int64 player = w.GetActor();
|
||||
w.PlayCallFunction(InvocationKind::LUA_CALL, player, datapk);
|
||||
LuaCallEnd(InvocationKind::LUA_INVOKE);
|
||||
} else {
|
||||
ConsoleOutput.AppendLine(TEXT("Unknown Command"));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user