Builtins - Virtuverse/CustomAddons Wiki

Builtins

Builtins are internal methods exposed to the Lua Addons.

List

Reference

register_hook

register_hook tells the game client that you want a particular function called whenever a specific event happens within the game

Usage:

register_hook(<int:hook_id>, <str:function_name>)

Example:

register_hook(2, "on_equipment_changed")

function on_equipment_changed(item)
    console_log("Equipped: " .. item)
end

Hook Reference

Hook Id Arguments Notes
SYSTEM_ERROR 0 str:error_message Called whenever an internal error is caught within the game client
PLAYER_EQUIP_ITEM 2 str:item_name Called whenever an player changes their mainhand equipment

register_tick

register_tick tells the game client you want a particular function to be called at every frame of the game.

Usage:

register_tick(<str:function_name>)

Warning: on_tick functions can be incredibly expensive for a machine due to them running every frame, use sparingly. We'll be adding timeouts and slower asyncrounous call support in the near future.

get_metric

get_metric(<str:metric_name>) -> <?:?> 

get_metric will retrieve an internal metric from the game client, type and value is variable based on the metric name passed in.

Metric Reference

Metric Type Default Notes
weapon::recharge float 0.0 Returns the current recharge percent of the players equipped equipment, from 0.0 being just used, to 1.0 is ready to use.
weapon::durability float 0.0 Returns the durability of the players equipped item
weapon::durability_percent float 0.0 Returns the durability of the players equipped item in the range 0.0 (broken) to 1.0 (fully repaired).
weapon::durability_max float 0.0 Returns the maximum durability of the players equipped item
weapon::speed float 0.0 Returns the attacks per second value for the players equipped item
weapon::name str "" Returns the name of the currently equipped item, return an empty string if no item is equipped
weapon::ammo_count_uses int -1 Gets the ammo count of the current equipped item, as uses.
weapon::ammo_count_absolute int -1 Gets the ammo count of the current equipped item.
player::currency::aurum double 0.0 Gets the players current aurum count.
ui::mouse_position Vec2D {x=0.0, y=0.0} Returns the x and y pixel coordinates of the players mouse on screen