Dialog system : pausing script and resume on player's answer

Teto <[email protected]>
Newsgroups gmane.comp.lang.lua.bind.user
Message-ID <[email protected]>
Hi,

I'm trying to create a dialog system for a game with the possibility
of choosing between different answers (there might be more than 2
answers)

=========================
local speech = createSpeech("Welcome to the tutorial ! Do you want to
skip it ?");
speech:addAnswer('Yes',1);
speech:addAnswer('No',0);

-- answerValue could be either 1 or 0
local answerValue = MainState:showMessage(speech);
if(answerValue == 1) then
      -- Player wants to skip tutorial
else
      -- we create new dialogs ....
end
=========================

showMessage() is a C++ function that changes my C++ state machine to
the dialog system. I would like showMessage() to pause the script when
called. I would like the script to resume when the player answers the
question and return his answer (an integer, retrieved in the example
in "answerValue") possibly from a different function than
showMessage() (C++ function onAnswer() for example).

Then on the lua side, I will create  matching dialogs.

What is the best way to achieve this (if possible with luabind) ? I've
tried using the yield policy:
    luabind::class_<CSinglePlayerState>("CSinglePlayerState")
        .def("showMessage",&CSinglePlayerState::showMessage, yield)
        ,

but I get the error "Attempt to yield across metamethod". Do I
absolutely need to create a thread ? (I would like to keep things
simple).


Let me know if things are unclear or if this would be best asked on a lua forum.

Matt

------------------------------------------------------------------------------
Protect Your Site and Customers from Malware Attacks
Learn about various malware tactics and how to avoid them. Understand 
malware threats, the impact they can have on your business, and how you 
can protect your company and customers by using code signing.
http://p.sf.net/sfu/oracle-sfdevnl
_______________________________________________
luabind-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/luabind-user
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.