Hello there! We are conducting a survey to better understand the user experience in making a first edit. If you have ever made an edit on Gamepedia, please fill out the survey. Thank you!

Gumbo Script

From Shadowrun Wiki
Jump to: navigation, search

Temporary Links[edit | edit source]

Gumbo_Script_Reference

Gumbo_Script_101

Gumbo_Snippets

Overview[edit | edit source]

GumboScript is a basic script which uses plant text commands similar to a natural language to direct AI actions.

Script can be broken down to the following keywords:

Keyword Definition
Flow Refers to keywords that control the flow of the script. (e.g IF, ELSE, RETURN)
Verbs Keywords that defines an action to do or evaluate. (e.g. FILTER, DO, DEBUG, RUN)
Nouns Keywords used for evaluation. (e.g. Actors, Items, Variables)
Adjectives Keywords used to select attributes or types. (e.g. in_cover, flanked, in_range)
Math Refers to your standard math operators. (e.g. +, -, *, / )

Editing Gumbo Script[edit | edit source]

We recommend using Sublime Text 3 for editing Gumbo Script.

Installation[edit | edit source]

  1. Install Sublime Text 3
  2. Run Sublime Text 3
  3. Select Preferences -> Browse Packages...
  4. Browse to ..\Sublime Text 3\Installed Packages
  5. Download the Gumb Syntax Highlighter copy it to the above folder
  6. Restart Sublime Text

With the package installed, you should be able to select Gumbo from the bottom-right menu in sublime that dictates the syntax highlighting.

Theme[edit | edit source]

Following the installation of Sublime run the editor and setup package control.

Install the Predawn Theme

Tabs[edit | edit source]

Gumbo Script uses a 4 spaces or tab to indicate branching statements.

  1. Select the tab indicator at the bottom-right of the editor
  2. Set the Tab Width to 4

With that in place, you should be ready to start creating and editing in Gumbo Script!

Basic Flow[edit | edit source]

IF A
    IF B
        DO C
    ELSE
        RETURN E
DO D

The above snippet gives an example to how the Flow keywords work. A quick breakdown:

  1. If A is True, we continue to the IF B. Otherwise we skip to Do D.
  2. If B is True, we continue to DO C. Otherwise we skip to ELSE
  3. The AI will DO C. Then it will DO D
  4. If B was False, the code will RETURN E. It does not DO D
  5. If A was False, AI will still DO D

Basic Script[edit | edit source]

SELECT ENEMY NOT(in_cover)
IF SELECT INVENTORY MATCH(debuff)
    DO ITEM_SELECTION
VERB NOUN NOT(ADJECTIVE)
FLOW VERB NOUN MATCH(ADJECTIVE)
    VERB NOUN

A quick breakdown of the above script:

  1. The Actor is told to Select an Enemy not matching the attribute In_Cover
  2. If the Actor can Select an Inventory Item that has a matching attribute of debuff
  3. The Actor is told to use the selected item on the selected enemy

Basic Function[edit | edit source]

Functions or Methods are easy ways of re-using a code snippet without having to retype the whole thing. Take the Basic Script for example, you could retype the snippet anytime you would want an Actor to use a debuff. However, we can also change the code so it is accessible like this:

[DEBUFF]
SELECT ENEMY NOT(in_cover)
IF SELECT INVENTORY MATCH(debuff)
    DO ITEM_SELECTION

In brackets, set the name you want to access the function. (e.g. [Debuff], [Check Ammo]) Now the function can be called with the following:

RUN DEBUFF

Function Parameters[edit | edit source]

Functions may also have optional parameters to modify how they run.

Parameter Definition
@gate=<method> Defines a gating method that returns true or false. If false, the function will not run
@loops=<num> Defines the max number of times for the function to loop. Uses DEFAULT_LOOPS if not set
@throttle=<num> Defines the millisecond delay between actioons

The following script contains an example of a gated function.

[CAN_ENGAGE]
RETURN ENEMY MATCH(alive, in_sight)

[ENGAGE]
@gate=CAN_ENGAGE
IF SELECT ENEMY MATCH(alive, in_sight)
    MOVE ACTOR_SELECTION in_cover, sweet_range
    ELSEIF SELECT INVENTORY MATCH(attack)
        DO ITEM_SELECTION
RETURN

Given the above script, we call RUN ENGAGE

  1. The AI sees that it has a parameter it needs to fulfill and runs CAN_ENGAGE
  2. CAN_ENGAGE checks that there is an ENEMY that is alive and in sight then returns true or false
  3. If CAN_ENGAGE returns true, then ENGAGE continues to execute and the AI selects an enemy that is alive and in sight
  4. If CAN_ENGAGE returns false, then ENGAGE does not execute

Importing[edit | edit source]

Importing allows us to have an AI inherit functions from another. This is done at the beginning of the script before variables are declared.

{import gumbo_common}

With the above line included, a new script will have access to all of the function already created in gumbo_common.

Notes:

  • Functions created in the "child" script with the same name will override the imported script
  • Variables in the imported script are not accessible from the imported script.

Debugging[edit | edit source]

Debugging allows you to display text in the console and over the Actor. This is great for testing your logic and keeping track of variables within your script

Accessing the Debugger[edit | edit source]

With a scene loaded you can access dev mode to test your work.

  1. Ctrl + F1 enables dev mdoe
  2. Select the Debug tag and click "dbgai"

This causes every AI Actor to have a scrolling log above their heads showing their actions.

With the mouse hovered over an Actor, you may modify your log view:

  • Press . to cycle through modes
  • Press ' to expand the scrolling log

Finally you may open the Console window and select the Gumbo tab for a complete log of all actions that have been made.

Sample Debug[edit | edit source]

{string,GREETINGS,A New World}

[Hello_World]
DEBUG "Hello World"
DEBUG GREETINGS
SET GREETINGS "A Third World"
DEBUG "Hello World" GREETINGS

The above function breaks down a couple of ways to use the DEBUG Verb.

  • The first line outputs "Hello World" as a string.
  • The second line uses a String Variable and outputs its value "A New World"
  • In the third line we set GREETINGS to the new value "A Third World"
  • The final line outputs "Hello World, A Third World"