-
Notifications
You must be signed in to change notification settings - Fork 10
GlobalFunctions
youyihj edited this page Oct 25, 2023
·
8 revisions
Global functions to zenscript added by ZenUtils.
-
typeof
: get an object's type. Returns String. -
toString
: Returns a string representation of the object. -
addRegexLogFilter
: takes a string regex, log messages that match the regex won't be log and sent to players. (totally suppressed) -
arrayOf
: takes an int and an optional object, creates a new object array with given length, and filled with an optional element. -
intArrayOf
: takes an int and an optional int, creates a new int array with given length, and filled with an optional element. -
byteArrayOf
: takes an int and an optional byte, creates a new byte array with given length, and filled with an optional element. -
shortArrayOf
: takes an int and an optional short, creates a new short array with given length, and filled with an optional element. -
longArrayOf
: takes an int and an optional long, creates a new long array with given length, and filled with an optional element. -
floatArrayOf
: takes an int and an optional float, creates a new float array with given length, and filled with an optional element. -
doubleArrayOf
: takes an int and an optional double, creates a new double array with given length, and filled with an optional element. -
boolArrayOf
: takes an int and an optional float, creates a new bool array with given length, and filled with an optional element. -
scriptStatus
: no argument, Returns an int representing the phase of the game. 0 -> initializing game. 1 -> Reloading scripts. 2 -> the game has started.
import crafttweaker.item.IItemStack;
print(typeof(<ore:ingotIron>));
print(toString(<ore:ingotIron>));
// arrayOf returns Object[], which ZS doesn't expose. It is supposed to unchecked cast the result array with "left as"
val item as IItemStack = <item:minecraft:apple>;
val items as IItemStack[] = arrayOf(64, item);
print(items[15].commandString);
It will print:
[INITIALIZATION][CLIENT][INFO] crafttweaker.mc1120.oredict.MCOreDictEntry
[INITIALIZATION][CLIENT][INFO] <ore:ingotIron>
[INITIALIZATION][CLIENT][INFO] <minecraft:apple>
These method can also be called in package mods.zenutils.ZenUtils
. And due to internal limitation, the global function typeof
cannot receive primitive classes (int, double, etc.) as the parameter. You can only use typeof
method in the package to check the type of primitive classes.
- GlobalFunctions
- ScriptReloading
- SuppressErrorPreprocessor
- HardFailPreprocessor
- OrderlyMap
- IData Deep Update
- Template String
- Native Method Access
- Mixin
- CrTI18n
- CrTUUID
- CrTItemHandler
- CrTLiquidHandler
- ILiquidTankProperties
- StringList
- HexHelper
- StaticString
- Catenation
- PersistedCatenation
- PlayerStat
- IStatFormatter
- GameRuleHelper
- ZenCommand
- ZenCommandTree
- ZenUtilsCommandSender
- IGetCommandUsage
- ICommandExecute
- IGetTabCompletion
- CommandUtils