User Tools

Site Tools


lua:scripting:examples:constates
lua>
do
 
local function menu_handler( ch )
    sendtochar(ch, "Beginning the menu test.\n\r")
 
    while true do
        sendtochar( ch, [[
[s]ex
[r]ace
[c]lass
[q]uit
]])
        local cmd=coroutine.yield()
 
        if cmd=="s" then
            sendtochar( ch, "Your sex: "..ch.sex.."\n\r")
        elseif cmd=="r" then
            sendtochar( ch, "Your race: "..ch.race.."\n\r")
         elseif cmd=="c" then
            sendtochar( ch, "Your class: "..ch.class.."\n\r")
        elseif cmd=="q" then
            return -- ends the con handler
        else
            sendtochar( "Unknown selection: "..cmd.."\n\r")
        end
    end
 end
 
start_con_handler( mob.descriptor, menu_handler, mob )
 
end
Beginning the menu test.
[s]ex
[r]ace
[c]lass
[q]uit
s
Your sex: male
[s]ex
[r]ace
[c]lass
[q]uit
r
Your race: wraith
[s]ex
[r]ace
[c]lass
[q]uit
c
Your class: illusionist
[s]ex
[r]ace
[c]lass
[q]uit
q
lua> 
lua/scripting/examples/constates.txt · Last modified: 2015/01/28 05:58 by vodur