Two entity APIs share the same objects. With entity.* a field is its value (pawn.m_iHealth, pawn.m_iHealth = 100 writes it). With entities.* a field is an accessor (pawn.m_iHealth:get(), :set(v), :get_as("uint8")). Any schema field of the entity's class or of its parent classes works; the type comes from the game's schema (numbers, bool, vectors, colors, handles, handle lists, strings, pointers and embedded structures).
| Function | Parameters | Returns | Description |
|---|---|---|---|
entity.get_local_player() | pawn or nil | Also entity.get_local_player_or_spec(), entity.get_local_controller(). | |
entity.players:for_each(fn) | fn(pawn) | none | entity.controllers, entity.weapons, entity.projectiles; list:get_all() returns an array. |
entity.get_by_index(i) | entity or nil | get_by_handle(h), get_all(class), from_address(addr, class) | |
entities.players:for_each(fn) | fn(entry) | none | entry.entity, entry.handle. Lists: players, controllers, items, dropped_items, projectiles, all. for_each_z goes far to near. |
entities.get_local_pawn() | entity or nil | get_local_controller(), get_by_class(name), list(kind) |
Methods on every entity: get_address, get_class_name, get_name, get_health, get_team, is_alive, is_enemy, is_local, is_dormant, get_abs_origin, get_abs_angles, get_speed_vector, get_eye_pos, get_eye_angles, get_view_offset, get_bone_position(bone), get_hitbox_center(hitbox), get_bounding_box() (screen Rect), get_collision_bounds(), get_controller, get_pawn, get_active_weapon, get_weapons, get_observer_target, get_observer_mode, get_steam_id, get_string_steam_id, is_scoped, get_armor, get_flags, is_on_ground, get_prop(name), set_prop(name, v), cast(class). Weapons: get_def_index, get_data, get_type, get_clip, get_max_clip, get_max_speed, is_gun.
| Function | Parameters | Returns | Description |
|---|---|---|---|
trace.line(from, to, opts?) | opts.ignore: entity | result or nil | Ignores the local player by default. Result: hit, fraction, entity, normal, position, end_pos, start_in_solid. |
trace.hull(from, to, mins?, maxs?) | result or nil | Player hull when mins and maxs are omitted. | |
luna.local_state() | table | Local player movement state: origin, speed_vector, speed, on_ground, flags, move_type, health, duck_amount, max_speed, ... | |
game.engine:in_game() | bool | Also client_cmd(cmd), get_screen_size(), get_last_server_tick(). | |
game.global_vars.cur_time | number | real_time, frame_time, tick_count, frame_count, map_name | |
game.cvar:find(name) | ConVar or nil | get_float, get_int, get_bool, get_string, set_float, set_int, set_bool, .value. Shortcuts: cvar.get_float(name), ... | |
globals.curtime() | number | realtime, frametime, tickcount, tickinterval, framecount, mapname, fps | |
game.exec(command) | bool | Runs a console command. game.chat_print(text), game.play_sound(path) |