testo
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
testo [2014/06/20 18:58] – created vodur | testo [2015/01/31 05:31] (current) – vodur | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | start_con_handler( descriptor, func, … ) | ||
+ | |||
+ | Creates a coroutine of the given function and sets it as the con state handler to the target descriptor. Any additional arguments to start_con_handler are passed to func when it is called. The con state handler handles all player input from the given descriptor. Entered commands are accessed within the handler function through coroutine.yield(). | ||
+ | |||
+ | The general logic is thus: start_con_handler creates a coroutine of func func coroutine is set as descriptor' | ||
+ | |||
+ | Example 1: confirming an action (example uses luai for convenience) | ||
+ | |||
+ | < | ||
+ | luai | ||
+ | lua> | ||
+ | |||
+ | adssd | ||
+ | </ | ||
+ | |||
+ | <code lua> | ||
+ | for i=1,2000 do | ||
+ | | ||
+ | end | ||
+ | |||
+ | for i=30,3000 do | ||
+ | blah(" | ||
+ | end | ||
+ | </ | ||
+ | |||
+ | <code lua> | ||
+ | do | ||
+ | |||
+ | local function confirm_handler( ch ) | ||
+ | sendtochar(ch, | ||
+ | |||
+ | while true do | ||
+ | local cmd=coroutine.yield() | ||
+ | |||
+ | if cmd==" | ||
+ | ch: | ||
+ | return | ||
+ | elseif cmd==" | ||
+ | sendtochar(ch, | ||
+ | return | ||
+ | else | ||
+ | sendtochar(ch, | ||
+ | end | ||
+ | end | ||
+ | end | ||
+ | |||
+ | start_con_handler( mob.descriptor, | ||
+ | |||
+ | end | ||
+ | </ | ||
+ | |||
+ | < | ||
+ | Are you sure you want to declare yourself a butthead? [Y/n] | ||
+ | Y | ||
+ | You gossip 'I AM BUTTHEAD' | ||
+ | lua> | ||
+ | </ | ||
+ | |||
+ | See also [[: | ||
- | Properties | ||
- | < | ||
- | ^Field^Get^Set^ | ||
- | | [[.str|str]] | 0 | 5 | | ||
- | | [[.class|class]] | 0 | | | ||
- | | [[.fighting|fighting]] | 0 | | | ||
- | | [[.affects|affects]] | 0 | | | ||
- | | [[.dex|dex]] | 0 | 5 | | ||
- | | [[.level|level]] | 0 | 5 | | ||
- | | [[.size|size]] | 0 | 5 | | ||
- | | [[.move|move]] | 0 | 5 | | ||
- | | [[.hitroll|hitroll]] | 0 | 5 | | ||
- | | [[.damtype|damtype]] | 0 | | | ||
- | | [[.sex|sex]] | 0 | 5 | | ||
- | | [[.himher|himher]] | 0 | | | ||
- | | [[.silver|silver]] | 0 | 5 | | ||
- | | [[.pkdeaths|pkdeaths]] | 0 | | | ||
- | | [[.ischarm|ischarm]] | 0 | | | ||
- | | [[.isneutral|isneutral]] | 0 | | | ||
- | | [[.vit|vit]] | 0 | 5 | | ||
- | | [[.clan|clan]] | 0 | | | ||
- | | [[.cha|cha]] | 0 | 5 | | ||
- | | [[.mobkills|mobkills]] | 0 | | | ||
- | | [[.isimmort|isimmort]] | 0 | | | ||
- | | [[.heshe|heshe]] | 0 | | | ||
- | | [[.clanrank|clanrank]] | 0 | | | ||
- | | [[.luc|luc]] | 0 | 5 | | ||
- | | [[.description|description]] | 0 | 5 | | ||
- | | [[.scroll|scroll]] | 0 | | | ||
- | | [[.explored|explored]] | 0 | | | ||
- | | [[.beheads|beheads]] | 0 | | | ||
- | | [[.bank|bank]] | 0 | | | ||
- | | [[.questpoints|questpoints]] | 0 | | | ||
- | | [[.proto|proto]] | 0 | | | ||
- | | [[.isfollow|isfollow]] | 0 | | | ||
- | | [[.align|align]] | 0 | 5 | | ||
- | | [[.maxmana|maxmana]] | 0 | 5 | | ||
- | | [[.groupsize|groupsize]] | 0 | | | ||
- | | [[.ingame|ingame]] | 0 | | | ||
- | | [[.dis|dis]] | 0 | 5 | | ||
- | | [[.position|position]] | 0 | | | ||
- | | [[.pkills|pkills]] | 0 | | | ||
- | | [[.longdescr|longdescr]] | 0 | 5 | | ||
- | | [[.isevil|isevil]] | 0 | | | ||
- | | [[.shortdescr|shortdescr]] | 0 | 5 | | ||
- | | [[.vnum|vnum]] | 0 | | | ||
- | | [[.mana|mana]] | 0 | 5 | | ||
- | | [[.hp|hp]] | 0 | 5 | | ||
- | | [[.wis|wis]] | 0 | 5 | | ||
- | | [[.mobdeaths|mobdeaths]] | 0 | | | ||
- | | [[.con|con]] | 0 | 5 | | ||
- | | [[.int|int]] | 0 | 5 | | ||
- | | [[.race|race]] | 0 | 5 | | ||
- | | [[.isactive|isactive]] | 0 | | | ||
- | | [[.maxmove|maxmove]] | 0 | 5 | | ||
- | | [[.isgood|isgood]] | 0 | | | ||
- | | [[.achpoints|achpoints]] | 0 | | | ||
- | | [[.inventory|inventory]] | 0 | | | ||
- | | [[.ispc|ispc]] | 0 | | | ||
- | | [[.remorts|remorts]] | 0 | | | ||
- | | [[.money|money]] | 0 | | | ||
- | | [[.hisher|hisher]] | 0 | | | ||
- | | [[.maxhp|maxhp]] | 0 | 5 | | ||
- | | [[.agi|agi]] | 0 | 5 | | ||
- | | [[.pet|pet]] | 0 | 5 | | ||
- | | [[.name|name]] | 0 | 5 | | ||
- | | [[.room|room]] | 0 | | | ||
- | | [[.attacktype|attacktype]] | 0 | 5 | | ||
- | | [[.isnpc|isnpc]] | 0 | | | ||
- | | [[.damnoun|damnoun]] | 0 | | | ||
- | | [[.gold|gold]] | 0 | 5 | | ||
- | | [[.damroll|damroll]] | 0 | 5 | | ||
- | | [[.stance|stance]] | 0 | | | ||
- | </ |
testo.1403290711.txt.gz · Last modified: 2014/06/20 18:58 by vodur