Difference between revisions of "Meta Expressions"

From VirindiPlugins
Jump to: navigation, search
m (Examples)
m (Examples)
Line 934: Line 934:
  
 
coordinatedistancewithz[wobjectgetphysicscoordinates[wobjectfindnearestbyobjectclass[14]],getplayercoordinates[]]<5
 
coordinatedistancewithz[wobjectgetphysicscoordinates[wobjectfindnearestbyobjectclass[14]],getplayercoordinates[]]<5
 
 
'''Use nearest portal.'''
 
 
actiontryuseitem[wobjectfindnearestbyobjectclass[14]]
 
  
  
Line 959: Line 954:
  
 
actiontryuseitem[wobjectfindnearestdoor[]]
 
actiontryuseitem[wobjectfindnearestdoor[]]
 +
 +
 +
'''Use nearest portal.'''
 +
 +
actiontryuseitem[wobjectfindnearestbyobjectclass[14]]
  
  
Line 969: Line 969:
  
 
actiontryapplyitem[wobjectfindininventorybytemplatetype[9060],wobjectgetplayer[]]
 
actiontryapplyitem[wobjectfindininventorybytemplatetype[9060],wobjectgetplayer[]]
 
 
'''Combine two motes'''
 
 
actiontryapplyitem[wobjectfindininventorybyname[Pyreal Mote], wobjectfindininventorybyname[Pyreal Mote]]
 
  
  
Line 988: Line 983:
  
  
'''Nearest Monster:'''
+
'''Select Nearest Monster:'''
  
 
actiontryselect[wobjectfindnearestmonster[]]
 
actiontryselect[wobjectfindnearestmonster[]]
Line 1,008: Line 1,003:
  
  
'''Select nearest Vendor:'''
+
'''Select Nearest Vendor:'''
  
 
actiontryselect[wobjectfindnearestbyobjectclass[25]]
 
actiontryselect[wobjectfindnearestbyobjectclass[25]]
  
  
'''Select nearest NPC:'''
+
'''Select Nearest NPC:'''
  
 
actiontryselect[wobjectfindnearestbyobjectclass[37]]
 
actiontryselect[wobjectfindnearestbyobjectclass[37]]
  
  
'''Use nearest Vendor:'''
+
'''Use Nearest Vendor:'''
  
 
actiontryuseitem[wobjectfindnearestbyobjectclass[25]]
 
actiontryuseitem[wobjectfindnearestbyobjectclass[25]]
  
  
'''Use nearest NPC:'''
+
'''Use Nearest NPC:'''
  
 
actiontryuseitem[wobjectfindnearestbyobjectclass[37]]
 
actiontryuseitem[wobjectfindnearestbyobjectclass[37]]
  
  
'''Use nearest door:'''
+
'''Use Nearest door:'''
  
 
actiontryuseitem[wobjectfindnearestdoor[]]
 
actiontryuseitem[wobjectfindnearestdoor[]]

Revision as of 12:25, 12 June 2015

These expressions can set and retrieve variables, react to object/char properties, use and combine objects, and more.

This adds the "Expression" meta condition and the "Expression Action" and "Chat Expression" meta actions.

The "/vt mexec [expression]" command can be used instead of the meta rules when appropriate. It is also a great testing tool.


There are two ways to use Expressions, your situation will determine the best choice.

The first is through sending the command like any other chat command. Ex: "/vt mexec [expression]". This can be useful if you want to issue the command without using a meta rule, or simply want to test an expression without using meta.


The second is by utilizing the "Expression" meta condition and the "Expression Action" and "Chat Expression" meta actions.

The "Expression" meta condition is like any other meta condition, if the parameters are met then it will initiate the action. You can use this to detect world objects, character properties, react to custom variables and more.

The "Expression Action" meta action initiates the expression written within.

The "Expression Chat" meta action is used to output expression strings to chat. You can use regex and meta functions to format an expression. When outputting numbers from a variable you must first convert it to a string.


Notes

  • true is the same as 1, false is the same as 0. There are no actual booleans, just numbers.
  • There are two extra operators added since monster expressions: the ^ (xor) operator, and the ; operator. The ; operator works on any two types and simply returns the value of the first one. It has the lowest possible precedence. The idea is to use it to string together commands when you don't care about the result.
  • Unlike monster expressions, meta expressions do not trim spaces from the ends of strings.
  • Set variables persist until cleared by a command or until relog.
  • Formatting during the conversion of number to string is a string like this: http://msdn.microsoft.com/en-us/library/kfsatb94%28v=vs.110%29.aspx
  • All operator characters which occur in a string must be escaped with \
  • All numbers in a string must also be escaped.


Function Information

Expand to view details and available examples.

There are currently 48 meta functions.


testvar[1]

Description: Tests if a meta variable is defined. Returns true if it is, or false otherwise.

Parameter count: 1

Param 0 (String): The variable name to test

Example: testvar[variableName]

getvar[1]

Description: Returns the value of a meta variable, or false if it is not defined.

Parameter count: 1

Param 0 (String): The variable name to get

Example: getvar[exampleVar]

setvar[2]

Description: Sets the value of a meta variable.

Parameter count: 2

Param 0 (String): The variable name to set

Example: variables can be strings or integers

setvar[exampleVar, variable]

setvar[exampleVar, 1]

touchvar[1]

Description: Sets the value of a meta variable to false if the variable was previously undefined. Returns true if the variable was previously defined, or false otherwise.

Parameter count: 1

Param 0 (String): The variable name to touch

Example: touchvar[exampleVar]

clearallvars[]

Description: Undefines all meta variables.
Parameter count: 0

clearvar[1]

Description: Undefines a single meta variable. Returns true if the variable was previously defined, otherwise false.

Parameter count: 1

Param 0 (String): The variable name to clear

Example: clearvar[exampleVar]

getcharintprop[1]

Description: Returns a character intvalue property, or false if the property is not defined.

Parameter count: 1

Param 0 (Number): IntValueKey property id.

getchardoubleprop[1]

Description: Returns a character doublevalue property, or false if the property is not defined.

Parameter count: 1

Param 0 (Number): DoubleValueKey property id.

getcharquadprop[1]

Description: Returns a character quadvalue property, or false if the property is not defined. Because expression variables are doubles, precision will be lost if the value is greater than 2^53-1 (~9 quadrillion)

Parameter count: 1

Param 0 (Number): QuadValueKey property id

getcharboolprop[1]

Description: Returns a character boolvalue property, or false if the property is not defined.

Parameter count: 1

Param 0 (Number): BoolValueKey property id

getcharstringprop[1]

Description: Returns a character stringvalue property, or false if the property is not defined.

Parameter count: 1

Param 0 (Number): StringValueKey property id.

getplayerlandcell[0]

Description: Returns the landcell the player is currently standing in as a number, including the landblock portion
Parameter count: 0

getplayercoordinates[0]

Description: Returns the global 3d coordinates for the player's current location, based on the game physics prediction model. Returns a coordinates object.
Parameter count: 0

coordinategetns[1]

Description: Returns the north/south portion of a coordinates object as a number.

Parameter count: 1

Param 0 (Coordinates): The coordinates object.

coordinategetwe[1]

Description: Returns the west/east portion of a coordinates object as a number.

Parameter count: 1

Param 0 (Coordinates): The coordinates object.

coordinategetz[1]

Description: Returns the z (vertical) portion of a coordinates object as a number.

Parameter count: 1

Param 0 (Coordinates): The coordinates object.

coordinatetostring[1]

Description: Returns the the string representation of a coordinates object.

Parameter count: 1

Param 0 (Coordinates): The coordinates object.

coordinateparse[1]

Description: Builds a coordinates object from a string. It should be of the form '00.0N, 00.0W'. Z coordinates are not specified. Returns false in case of parse failure.

Parameter count: 1

Param 0 (String): The coordinates string.

coordinatedistancewithz[2]

Description: Returns the 3d distance between two coordinates. The result is a number specified in meters.

Parameter count: 2

Param 0 (Coordinates): The first coordinates object.

Param 1 (Coordinates): The second coordinates object.

coordinatedistanceflat[2]

Description: Returns the 2d distance between two coordinates. The result is a number specified in meters. Z coordinates are ignored.

Parameter count: 2

Param 0 (Coordinates): The first coordinates object.

Param 1 (Coordinates): The second coordinates object.

wobjectgetphysicscoordinates[1]

Description: Queries the game's physics prediction model for the coordinates of a given object. Returns a coordinates object.

Parameter count: 1

Param 0 (WorldObject): The world object to examine.

wobjectgetname[1]

Description: Returns the name string for a given world object.

Parameter count: 1

Param 0 (WorldObject): The world object to examine.

wobjectgetobjectclass[1]

Description: Returns the objectclass for a given world object, as a number.

Parameter count: 1

Param 0 (WorldObject): The world object to examine.

wobjectgettemplatetype[1]

Description: Returns the game template type for a given world object, as a number.

Parameter count: 1

Param 0 (WorldObject): The world object to examine.

wobjectgetisdooropen[1]

Description: Returns the a boolean indicating if a door object is open.

Parameter count: 1

Param 0 (WorldObject): The door world object to examine.

wobjectfindnearestmonster[0]

Description: Returns a world object for the nearest monster, or false if no monsters are visible. Ignores blacklisted monsters.
Parameter count: 0

wobjectfindnearestdoor[0]

Description: Returns a world object for the nearest door, or false if no doors are visible.

Parameter count: 0

Example: http://www.virindi.net/junk/door.jpg

wobjectfindnearestbyobjectclass[1]

Description: Returns a world object for the nearest object of a given class number, or false if no matching objects are visible.

Parameter count: 1

Param 0 (Number): The objectclass number to look for.

wobjectfindininventorybytemplatetype[1]

Description: Returns a world object for the first inventory object of a given template type number, or false if no matching objects are visible.

Parameter count: 1

Param 0 (Number): The template type number to look for.

Example: http://www.virindi.net/junk/expr-usingtemplates.jpg

wobjectfindininventorybyname[1]

Description: Returns a world object for the first inventory object of a given name, or false if no matching objects are visible.

Parameter count: 1

Param 0 (String): The item name to look for.

wobjectfindininventorybynamerx[1]

Description: Returns a world object for the first inventory object of a given name regex, or false if no matching objects are visible.

Parameter count: 1

Param 0 (String): The item name to look for. This parameter is a regex.

wobjectgetselection[0]

Description: Returns a world object for the selected object, or false if nothing is selected.
Parameter count: 0

wobjectgetplayer[0]

Description: Returns a world object for the player.

Parameter count: 0

actiontryselect[1]

Description: Attempts to select a world object.

Parameter count: 1

Param 0 (WorldObject): The world object to attempt to select.

Example: http://www.virindi.net/junk/select.jpg

actiontryuseitem[1]

Description: Attempts to use a world object by itself (like a potion or door).

Parameter count: 1

Param 0 (WorldObject): The world object to attempt to use.

actiontryapplyitem[2]

Description: Attempts to use a world object on another world object. Returns false if failed and true if the attempt could possibly succeed.

Parameter count: 2

Param 0 (WorldObject): The world object to use first.

Param 1 (WorldObject): The world object to be used on.

isfalse[1]

Description: Takes any type and returns true if and only if it is a number with value 0 (false). Returns false otherwise.

Parameter count: 1

Param 0 (Any): The object to examine

istrue[1]

Description: Takes any type and returns true if and only if it is a number with a value other than 0 (true). Returns false otherwise.

Parameter count: 1

Param 0 (Any): The object to examine

iif[3]

Description: Examines the first parameter. If it is true, the second parameter is returned. Otherwise, the third parameter is returned. (If the first parameter is not a number, the third parameter is returned.)

Parameter count: 3

Param 0 (Any): The object to examine

Param 1 (Any): What to return if the first parameter is true.

Param 2 (Any): What to return if the first parameter is not true

randint[2]

Description: Returns a random integer between min and max

Parameter count: 2

Param 0 (Number): Minimum

Param 1 (Number): Maximum

cstr[1]

Description: Converts a number to a string.

Parameter count: 1

Param 0 (Number): The number to convert

strlen[1]

Description: Returns the number of characters in a string, as a number.

Parameter count: 1

Param 0 (String): The string to examine

getobjectinternaltype[1]

Description: Returns the internal typeid for a given object as a number. Values are: 0=none, 1=number, 3=string, 7=object.

Parameter count: 1

Param 0 (Any): The object to examine

cstrf[2]

Description: Converts a number to a string using a specified format.

Parameter count: 2

Param 0 (Number): The number to convert

Param 1 (String): The format string to use. See: http://msdn.microsoft.com/en-us/library/kfsatb94.aspx

stopwatchcreate[0]

Description: Creates and returns a stopwatch object. Counting is not started.

Parameter count: 0

Example: http://www.virindi.net/junk/stopwatch.jpg

stopwatchstart[1]

Description: Starts counting on a stopwatch. Returns the stopwatch

Parameter count: 1

Param 0 (Stopwatch): The stopwatch to start

stopwatchstop[1]

Description: Starts counting on a stopwatch. Returns the stopwatch.

Parameter count: 1

Param 0 (Stopwatch): The stopwatch to stop

stopwatchelapsedseconds[1]

Description: Measures the number of seconds elapsed on a stopwatch.

Parameter count: 1

Param 0 (Stopwatch): The stopwatch to query


Object Properties

Vtank Object Prop Enums

The following properties have been tested with /vt mexec

ObjectClass
Unknown 0
MeleeWeapon 1
Armor 2
Clothing 3
Jewelry 4
Monster 5
Food 6
Money 7
Misc 8
MissileWeapon 9
Container 10
Gem 11
SpellComponent 12
Key 13
Portal 14
TradeNote 15
ManaStone 16
Plant 17
BaseCooking 18
BaseAlchemy 19
BaseFletching 20
CraftedCooking 21
CraftedAlchemy 22
CraftedFletching 23
Player 24
Vendor 25
Door 26
Corpse 27
Lifestone 28
HealingKit 29
Lockpick 30
WandStaffOrb 31
Bundle 32
Book 33
Journal 34
Sign 35
Housing 36
Npc 37
Foci 38
Salvage 39
Ust 40
Services 41
Scroll 42
CombatPet 43
NumObjectClasses 44
getcharintprop
Species 2
ContainerSlots 7
BurdenUnits 5
TotalValue(pyreal) 20
SkillCreditsAvail 24
Level 25
Rank 30
Deaths 43
DateOfBirth(unix) 98
Gender 11
Age(seconds) 125
XPForVPReduction 129
ChessRank 181
Heritage 188
FishingSkill 192
TitlesEarned 262
SocRibbonCount(CH) 287
SocRibbonCount(WEB) 288
SocRibbonCount(RB) 289
MeleeMastery 354
RangedMastery 355
SummoningMastery 362
Augmentations
Reinforcement of the Lugians 218
Bleeargh's Fortitude 219
Oswald's Enchantment 220
Siraluun's Blessing 221
Enduring Calm 222
Steadfast Will 223
Ciandra's Essence 224
Yoshi's Essence 225
Jibril's Essence 226
Celdiseth's Essence 227
Koga's Essence 228
Shadow of the Seventh Mule 229
Might of the Seventh Mule 230
Clutch of the Miser 231
Enduring Enchantment 232
Critical Protection 233
Quick Learner 234
Charmed Smith 236
Innate Renewal 237
Archmage's Endurance 238
Enhancement of the Blade Turner 240
Enhancement of the Arrow Turner 241
Enhancement of the Mace Turner 242
Caustic Enhancement 243
Fiery Enhancement 244
Icy Enhancement 245
Storm's Enhancement 246
Infused Creature Magic 294
Infused Item Magic 295
Infused Life Magic 296
Infused War Magic 297
Eye of the Remorseless 298
Hand of the Remorseless 299
Master of the Steel Circle 300
Master of the Focused Eye 301
Master of the Five Fold Path 302
Frenzy of the Slayer 309
Iron Skin of the Invincible 310
Jack of All Trades 326
Infused Void Magic 328
InfusedVoid 328
Luminance/Ratings
AuraValor 333
AuraProtection 334
AuraGlory 335
AuraTemperance 336
AuraAetheria 338
AuraManaFlow 339
AuraPurity 342
AuraCraftsman 343
AuraSpecialization 344
AuraWorld 365
HealBoost Rating(armor/jewelry) 376
Vitality Rating(armor/jewelry) 379
Total DmgRating 307
Total DmgResist 308
Total CritDmg 314
Total CritDmgResist 316
Total DmgResist from Lum (nali + seer) 334
Total CritDmgResist from Lum (nali + seer) 336
getcharquadprop
TotalExperience 1
UnassignedExperience 2
LuminancePointsCurrent 6
getcharstringprop
Name 1
Title 5
FellowshipName 10
MonarchName 21
Patron 35
DateBorn 43
MonarchyDescription 47


Examples

Test for proximity to any portal.

coordinatedistancewithz[wobjectgetphysicscoordinates[wobjectfindnearestbyobjectclass[14]],getplayercoordinates[]]<5


Check if you have any Aged or Durable Legendary Keys in your inventory.

getobjectinternaltype[wobjectfindininventorybynamerx[\^\(Aged\|Durable\) Legendary Key\$]]==7


Check if there is any object currently selected.

getobjectinternaltype[wobjectgetselection[]]==7


Save the selected items name in a variable.

setvar[keyName,wobjectgetname[wobjectgetselection[]]]


Use nearest door

actiontryuseitem[wobjectfindnearestdoor[]]


Use nearest portal.

actiontryuseitem[wobjectfindnearestbyobjectclass[14]]


Use a Massive Mana Charge on yourself by name

actiontryapplyitem[wobjectfindininventorybyname[Massive Mana Charge], wobjectgetplayer[]]


Use a Mana Stone on yourself by template type

actiontryapplyitem[wobjectfindininventorybytemplatetype[9060],wobjectgetplayer[]]


Combine items in inventory by name:

actiontryapplyitem[wobjectfindininventorybyname[itemName], wobjectfindininventorybyname[itemName]]


Combine items in inventory by template type:

actiontryapplyitem[wobjectfindininventorybytemplatetype[#],wobjectfindininventorybytemplatetype[#]]

Where # is the template type number. Use wobjectgettemplatetype[wobjectgetselection[]] to obtain the template type number from an object.


Select Nearest Monster:

actiontryselect[wobjectfindnearestmonster[]]


Select item in inventory by name:

actiontryselect[wobjectfindininventorybyname[itemName]]


Select item in inventory by class:

actiontryselect[wobjectfindininventorybyclass[#]]


Select World Object by ObjectClass:

actiontryselect[wobjectfindnearestbyobjectclass[#]] -- Where # is the object class


Select Nearest Vendor:

actiontryselect[wobjectfindnearestbyobjectclass[25]]


Select Nearest NPC:

actiontryselect[wobjectfindnearestbyobjectclass[37]]


Use Nearest Vendor:

actiontryuseitem[wobjectfindnearestbyobjectclass[25]]


Use Nearest NPC:

actiontryuseitem[wobjectfindnearestbyobjectclass[37]]


Use Nearest door:

actiontryuseitem[wobjectfindnearestdoor[]]


Use inventory item by template type:

actiontryuseitem[wobjectfindininventorybytemplatetype[#]]