-
Notifications
You must be signed in to change notification settings - Fork 0
Module: K2
This is the main module. It initiates the framework environment and routes module calls. It also has a number of methods to help you with your code development.
-
self
- Default value: K2
- The name of the K2 world trigger. Recommended to leave this as it is -
k2_noscript
- Default value: 0
- If set to 1, halts all framework activity. Useful when the match ends to improve game stability -
k2_cfg_debug
- Default value: 0
- Enable (1) or disable (0) debugging -
k2_cfg_debug_rlvl
- Default value: 0
- Reporting level. Only works if debugging is enabled. 0 = Disabled (Recommended for production use). 1 = Show errors in console and screen. 2 = Show errors and warnings in console and screen. 3 = Show all in console and screen -
k2_cfg_debug_rcl
- Default value: -1
- Client id to which to send debug chat messages. -1 = All clients -
k2_cfg_trace
- Default value: 0
- Traces K2 framework calls if set to 1. Not recommended for production use as it creates large amounts of vars.
Checks if the argument is a valid K2 object. The callback var which holds the result is “1” if true, and “0” if false.
Parameter Options:
isObject string required The name of the object to check -v string required Callback var which holds the result -c string optional Compare the found object type against the provided option
Examples:
This example checks if the variable “my_array” is of type “array”. The result is stored in the variable “result_var”.
#$e# K2 Array.new "my_array";
#$e# K2 isObject my_array -v result_var -c "array";
#<# #result_var#;This example checks if the variable “my_array” is an object at all. The result is stored in the variable “result_var”.
#$e# K2 Array.new "my_array";
#$e# K2 isObject my_array -v result_var;
#<# #result_var#;Logs a message and displays it in the console or the screen, depending on the value of the config var “k2_cfg_debug_rlvl” and “k2_cfg_debug”. Although the options -e, -w and -d are all optional, you must provide at least one of them to determine the nature of the message.
Parameter Options:
log string required The message to log -e int optional If set to 1, marks the message as error -w int optional If set to 1, marks the message as warning -d int optional If set to 1, marks the message as debug info
Examples:
This example logs a message as error.
#$e# K2 log "something went wrong here" -e 1;This example logs a message as warning.
#$e# K2 log "this could lead to problems." -w 1;This method is meant to be used directly in the console and not in your script code. It lists all available modules that have been compiled into the framework.
Parameter Options:
lsmod int required Set this to 1 or anything else to show the list
Example:
This example will show a list of modules in the console.
#$e# K2 lsmod 1;This method is meant to be used directly in the console and not in your script code. It shows a manual page of the requested method or class in the console.
Parameter Options:
man string required The name of the class or method
Examples:
This example will show the manual of the “Array.new” method in the console.
#$e# K2 man Array.new;This example will show the manual of the “isObject” method in the console.
#$e# K2 man isObject;This example will show the manual of the “K2” class in the console.
#$e# K2 man K2;Replaces all occurrences of the search string with the replacement string and returns the resulting string in a callback variable.
Parameter Options:
srep string required The string to search in -v string required The callback variable which holds the resulting string -s string required The string to search for -r string optional The replacement string
Example:
This example will replace “bad” with “good” in the string “you are so bad”.
#$e# K2 srep "you are so bad" -v result -s "bad" -r "good";
#<# #result#;This method is meant to be used directly in the console and not in your script code. It shows the trace of most framework calls. Note that framework calls will only be stored if the config var “k2_cfg_trace” is set to “1”. It is HIGHLY recommended have this set to “0” when not needed. Use for debugging only!
Parameter Options:
tracedump int required Set this to "1" to show the traces
Example:
#$e# K2 tracedump 1;