Files
pke/docs/lua help.txt
2026-03-08 16:50:54 +03:00

133 lines
4.9 KiB
Plaintext

Globals:
ACTION_FIRE = 0
ACTION_ALT_FIRE = 1
ACTION_RELOAD = 2
ACTION_USE = 3
ANIM_PLAYBACK_NONE = 0
ANIM_PLAYBACK_REPEAT = 1
EMovementDir_None = 1
EMovementDir_Forward = 2
EMovementDir_Backward = 4
EMovementDir_Left = 8
EMovementDir_Right = 16
EMovementDir_Jump = 32
PhysicsFilter_None = 64
PhysicsFilter_Player = 128
PhysicsFilter_Triggers = 256
PhysicsFilter_Usable = 512
PhysicsFilter_NPC = 1024
PhysicsFilter_Obstacle = 2048
kPhysicsFilter_AllAux = PhysicsFilter_Player | PhysicsFilter_Triggers | PhysicsFilter_Usable
engine.error(string message)
engine.warning(string message)
engine.create_entity(string classname) -- return an table to the new entity
engine.add_entity_to_world(entity) -- add entity to the world
engine.get_entity_from_id(integer id) -- return an entity table from
engine.find_entity_by_name(string name) -- return an entity table from
engine.play_sound(string filename) -- play 2d sound
engine.play_sound_3d(string filename, float x, float y, float z) -- play 3d sound
engine.get_delta() -- return delta time (float)
engine.trace_ray(float rayBeginX, float rayBeginY, float rayBeginZ, float rayEndX, float rayEndY, float rayEndZ, object ignoreTable) -- return a table with [pos_x, pos_y, pos_z, normal_x, normal_y, normal_z, entity_id, hit]
camera.get_position() -- return x, y, z
camera.get_front() -- return x, y, z
camera.get_right() -- return x, y, z
camera.get_up() -- return float
camera.get_pitch() -- return float
camera.set_yaw_pitch(float yaw, float pitch)
console.print(string message)
input.get_mouse_pos() -- return x, y
input.get_delta_mouse_pos() -- return x, y
input.lock_mouse(bool value) -- lock or unlock mouse capture
input.get_lock_mouse() -- return boolean
ui.draw_text(string text, float x, float y, object color) -- color is a table [r,g,b,a]
ui.draw_rect(float x, float y, float w, float h, object color) -- color is a table [r,g,b,a]
ui.draw_image(string filename, float x, float y, float w, float h, object color) -- color is a table [r,g,b,a]
ui.get_display_size() -- return x, y
ui.get_mouse_pos() -- return x, y
ui.calc_text_width(string text) -- return float
Entity properties:
string m_name -- read only
integer m_id -- read only
Entity callbacks:
on_init() -- on entity creation
on_shutdown() -- on entity destroy
on_update(delta) -- on entity update
on_collide(other) -- on entity collide with another entity
Entity methods:
load_model(string filename)
update_transform()
translate(float x, float y, float z) -- addition to the current position
set_position(float x, float y, float z) -- setting the position
get_position() -- return x, y, z
set_rotation(float x, float y, float z) -- setting the euler rotation
get_rotation() -- return x, y, z
set_rotation_from_vectors(float frontx, float fronty, float frontz,
float rightx, float righty, float rightz,
float upx, float upy, float upz) -- rotate around axis
get_classname() -- return the classname of the entity
get_id() -- return the id of the entity
mark_for_delete() -- mark entity to delete
set_name(string name) -- set entity name
get_name() -- return string
set_velocity(float x, float y, float z) -- setting the body velocity
get_velocity() -- return x, y, z
has_rigid_body() -- return boolean
create_box_body(float sizex, float sizey, float sizez, float mass, float friction, float damping, bool is_trigger, bool use_parameters)
create_sphere_body(float radius, float mass, float friction, float damping, bool is_trigger, bool use_parameters)
ForceBodyTransformUpdate() -- hack for forcing entity world transform to the rigid body
set_body_filter_group(integer group) -- set an physics group to the body
set_body_filter_mask(integer mask) -- set an physics group to the body
get_body_filter_group() -- return an current body group
get_body_filter_mask() -- return an current body mask
find_animation(string name) -- find an animation in the model
play_animation(integer id, integer mode) -- play an animation with specified mode (ANIM_PLAYBACK_NONE, ANIM_PLAYBACK_REPEAT)
stop_animation() -- stop a current animation
get_current_animation() -- return the id to the current playing animation
get_current_animation_time() -- return the current time of the current playing animation
get_animation_time(integer id) -- return the time of a animation
ActorBase methods:
activate_camera()
update_camera_look()
update_camera_movement(float nubmer)
update_body_movement(float nubmer)
get_action() -- return a current action mode (ACTION_FIRE, ACTION_ALT_FIRE, ACTION_RELOAD, ACTION_USE)
get_movement() -- return a current movement mode (EMovementDir_None, ...)
on_ground() -- return boolean
is_noclip() -- return boolean
create_player_body(float radius, float height, float mass, float friction, float damping)
create_player_body_box(float x, float y, float z, float mass, float friction, float damping)
Light methods:
set_color(float r, float g, float b)
get_color() -- return r, g, b
set_radius(float radius)
get_radius() -- return radius (float)