Difference between revisions of "Procedure Flags"

From SlothMUD Wiki
Jump to: navigation, search
Line 33: Line 33:
 
|}
 
|}
  
 +
 +
= MUDL2 Example =
 +
<pre>
 +
addproc <mobile> mudl
 +
setproc <mobile> 0 intercept_ask_bss
 +
 +
if ('quest' = %s[1],
 +
(
 +
    send_msgs_for_ask(%a, %c, %1, %2, %3),
 +
 +
    cmd(%c, 'say Yes I have a quest for you!'),
 +
    set(flag(%f, 'procedure-flags', 'overrode-command'), true),
 +
    return(true)
 +
)),
 +
return(false)
 +
@
  
 
[[Category:Building]]
 
[[Category:Building]]

Revision as of 16:04, 21 March 2016

Overview

Procedure flags are flags that can be used to modify code behavior during and after special procedures are run. The flags are stored in an integer as a bitvector and can be accessed in C code via the pParam->iProcedureFlags variable. In MUDL2 the flags can be accessed using the %f global variable.


Flag Values

C Define MUDL Name Description
PROC_OVERRODE_COMMAND overrode-command The special procedure has handled the command entered by the player. This tells the MUD that it should abort processing the command after the procedures are complete since the command has already been handled.
PROC_ABORT_PROCS abort-procedures The special procedure uses this flag to tell the MUD to stop running procedures after the current one.
PROC_SUPPRESS_LOOK suppress-look The special procedure uses this flag to tell the MUD not to perform a "look" command once the player is added to a new room.
PROC_SUCCESS success This flag must be used with PROC_OVERRODE_COMMAND. This tells the MUD that it should act as if the command was successfully executed and make any modifications to player statistics as such. Currently used to indicate a spell was successfully cast so that the MUD will subtract the full mana cost of casting the spell.
PROC_SENT_MESSAGES sent-messages This flag is used to indicate whether messages to the players regarding this command have been sent. In the case of casting a spell, it would be the messages "Player utters the words, ...".


MUDL2 Example

addproc <mobile> mudl
setproc <mobile> 0 intercept_ask_bss

if ('quest' = %s[1],
(
    send_msgs_for_ask(%a, %c, %1, %2, %3),

    cmd(%c, 'say Yes I have a quest for you!'),
    set(flag(%f, 'procedure-flags', 'overrode-command'), true),
    return(true)
)),
return(false)
@

[[Category:Building]]