Creating choice in custom dialogue

I’m pretty sure one of the options can’t be the function itself. However if you made it so after selecting an option, it runs that function, that should work.

The function has to stay in the dialogue data like so tho. As I can’t run the function from the UI, as there’s gonna be hundreds of different results from dialogue, and the UI can’t handle each individual one. Basically all I need is if the Yes option is selected, it to run the Yes option from the Dialogue (ie, numero 3, which thus is a function inside)

1 Like

It seems like this should work fine, and I’m surprised it isn’t. I’m sure if you review the code a few times and play around with it you should be able to find a solution. But hey, I’m not a scripter.

I wish you the best of luck.

Sorry, I just woke up, also happy the code I gave you helped a bit.

if type(v) == "function" then
  v()
  break;
end

Try adding this above the for iter = 1, #v.Msg do. As v is no longer a table, and doesn’t know how to handle a function from the looks of the code in those lines. However, if I wanted to do something along these lines, I wouldn’t have altered the table structure format, but instead concatenated a “function” variable into the table itself.

[3] = {Msg = 'Take a look!', Type = 'Dialogue', Function = function() end}

That way you can simply use

if v.Function then v.Function() end
1 Like