Skip to content

Script API

DoDoCat edited this page Apr 3, 2021 · 15 revisions

Introduction:

OpenMB has a individual script system like lua or python

Basic Information

Global Variable

Each global variable in the script file started with $

Local Variable

Each local variable in the script file started with %

Register Variable

There are 9 register variable in the system, you can store some specific value in them

Register Variable Description
reg0~5 Global Register Variable #1~#5
vect1~5 Global Vector Variable #1~#5

API:

OpenMB Engine:

Condition

Script Command Param Description
eq #1: Operation Value 1
#2: Operation Value 2
Operation Value 1==Operation Value 2?

Loop

Script Command Param Description
loop #1: Start Value
#2: End Value
#3: Step
Start a loop code region, and end with end

Game

Script Command Param Description
add_light #1: Light Type
#2: Light Name
#3: Light Position Vector
#4: Light Direction Vector
Add a specific light to the scene with specific name
assign #1: Variable Name
#2: Variable value
Assign a value to a specific variable
call #1: Function Name Call a function with specific name
case #1: Case condition name Case code block, always end with end
change_map #1: Map name Change specific map
change_return_main_menu None Return to main menu
change_screen_return None Shutdown current screen, and return to last screen(if has)
change_variable_value #1: Variable Name
#2: Variable Property
#3: value
Change a variable's value of property
change_ui #1: UI Layout ID defined in UI Layout xml file Start a new ui with specific ID defined in UI layout xml file
change_world_map #1: World map name Change current scene to a new world map
end None End Syntax
function #1: Function Name Start a function code region, and end with end
init_vector #1: Vector Variable Reset value a vector
namespace #1: Namespace name Define a namespace
remove_light #1: Light Name Remove a light with specific name
spawn #1: Character Type
#2: Character ID
#3: Character Team
#4: Spawn Vector
Spawn a character with specific id and name
store #1: Destion Value
#2: Source Value
Store value to destion value from source value
store_input_param #1: Dest value
#2: Parameter Index
Store input param from parameters stack(always use in function)
string_store_index #1: Dest value
#2: String ID
Store the specific string ID index defined in xml to a variable
string_store_str_by_index #1: Dest value
#2: String ID Index
Store the specific string by specific index defined in xml to a variable
switch #1: variable Start switch code block and end with end
trigger #1: Trigger Name
#2: Trigger Delay Time
#3: Trigger Frozen Time
Start a trigger code region, and end with end
vector_get_x #1: Destion Value
#2: Vector Variable
Get Vector Variable x value
vector_get_y #1: Destion Value
#2: Vector Variable
Get Vector Variable y value
vector_get_z #1: Destion Value
#2: Vector Variable
Get Vector Variable z value
vector_set_x #1: Vector Variable
#2: Value
Set Vector Variable x value
vector_set_y #1: Vector Variable
#2: Value
Set Vector Variable y value
vector_set_z #1: Vector Variable
#2: Value
Set Vector Variable z value

UI

Script Command Param Description
widget_add_item #1: widget name
#2: item
Widget with specific name add a item(Must impletment the IHasSubItem interface)

OpenMB.Mods.Common

OpenMB.Mods.KK