Is there a way to parse/ concatenate the result of another function into the script component of the dialogue entry?
- addpartycall_dialogue.PNG (3.26 KiB) Viewed 814 times
From my understanding the name of the Lua function would be `AddPartyMember+name` (when using the 2nd method of registering a different Lua function per party member), so I'd need to call that specifically in the script/ conversation section since the generic function of `AddPartyMember` does not exist as a Lua function (and is the function called under the hood).
- addpartyfunction_dialogue.PNG (6.63 KiB) Viewed 814 times
I assume it's something close to the below as from what I've found `..` is how you concat strings together in Lua.
Code: Select all
"AddPartyMember" .. Actor["NPC"].Name .. "()"
While it doesn't cause an error (e.g. not registered as a Lua function error), it doesn't actually run as a function + the log message for it seems to NOT parse the `Actor[NPC]` variable.
- parsed_lua_function.PNG (13.62 KiB) Viewed 814 times
I've tried the variations of the following as well, which SEEMS to be how you call functions from strings in Lua but got an error. This error occurs before the function is actually called (I added a debug `Debug.Log("Adding Party Member");` to the very start of AddPartyMember (underyling Unity function)
Code: Select all
loadstring("return" .. "AddPartyMember" .. Actor["NPC"].Name .. "()");
Code: Select all
loadstring("return ".."AddPartyMember"..Actor["NPC"].Name.."()")();
- lua_concat_function_error.PNG (108.58 KiB) Viewed 814 times
Not sure what I'm doing wrong here / whether I'm close or way off :/