DynamicMenuScript

From GECK
Jump to: navigation, search


An example UDF script.

Description

A skeleton UDF script for MessageBoxExAlt.

Think of it as a three step process:

  1. First call the UDF and pass a value of -1 for iButton. This builds the message box.
  2. At the end of the UDF is MessageBoxExAlt, which actually brings up the message built by the UDF.
  3. After the message box has appeared and the player has selected an option, it will run the UDF once more, but this time with a valid iButton input, which will be used to determine what effect should happen.

Syntax

[help]
call DynamicMenuScript iButton:int{-1}

Example

scn DynamicMenuScript

int iButton

int iIndex
string_var sMenu

begin function { iButton } ; pass -1 by default

    let iIndex := -1
    let sMenu := "^My Menu^"

    ; Add option
    let iIndex += 1
    let sMenu += "|option1"
    if iButton == iIndex 
        ; first option logic
        return
    endif

    ; Add option
    let iIndex += 1
    let sMenu += "|option2"
    if iButton == iIndex 
        ; next option logic
        return
    endif

    ; Add option
    let iIndex += 1
    let sMenu += "|option3"
    if iButton == iIndex 
        ; next option logic
        return
    endif

    ; Use the same script as callback
    MessageBoxExAlt DynamicMenuScript $sMenu

end

See Also