--Client                                            --Client
local eye_position = client.eye_position            --[ Returns x, y, z world coordinates of the local player's eye position, or nil on failure.
local log = client.log                              --  Logs a message to console in the [gamesense] format.
local screen_size = client.screen_size              --  Returns (width, height).
local callback = client.set_event_callback          --  Raises an error and prints a message in console upon failure.
local trace_bullet = client.trace_bullet            --  Returns entindex, damage. Entindex is nil when no player is hit or if players are skipped. ]

--Entity                                            --Entity
local get_local_player = entity.get_local_player()  --[ Returns the entity index for the local player, or nil on failure.
local get_player_name = entity.get_player_name      --  Returns the player's name, or the string "unknown" on failure
local get_players = entity.get_players              --  Returns an array of player entity indices. Dormant and dead players will not be added to the list.
local get_prop = entity.get_prop                    --  Returns the value of the property, or nil on failure. For vectors or angles, this returns three values.
local hitbox_position = entity.hitbox_position      --  Returns world coordinates x, y, z, or nil on failure.
local is_enemy = entity.is_enemy                    --  Returns true if the entity is on the other team. ]
                  --

--Renderer                                          --Renderer
local indicator = renderer.indicator                --[ Returns the Y screen coordinate (vertical offset) of the drawn text, or nil on failure. This can only be called from the paint callback.
local text = renderer.text                          --  Draw text, this can only be called from the paint callback. ]

--Ui                                                --Ui
local get = ui.get                                  --[ For a checkbox, returns true or false. For a slider, returns an integer. For a combobox, returns a string. For a multiselect combobox, returns an array of strings. For a hotkey, returns true if the hotkey is active. For a color picker, returns r, g, b, a. Throws an error on failure.
local combobox = ui.new_checkbox                    --  Returns a special value that can be passed to ui.get and ui.set, or throws an error on failure.
local reference = ui.reference                      --  Avoid calling this from inside a function. Returns a reference that can be passed to ui.get and ui.set, or throws an error on failure. This allows you to access a built-in pre-existing menu items. This function returns multiple values when the specified menu item is followed by unnamed menu items, for example a color picker or a hotkey.
local set = ui.set                                  --  For checkboxes, pass true or false. For a slider, pass a number that is within the slider's minimum/maximum values. For a combobox, pass a string value. For a multiselect combobox, pass zero or more strings. For referenced buttons, value is ignored and the button's callback is invoked. For color pickers, pass the arguments r, g, b, a. ]

local Abscissa, Ordinate = screen_size()
local Abscissa, Ordinate = tonumber(Abscissa), tonumber(Ordinate)

local Check = combobox("MISC", "Miscellaneous", "DMG")
local Damage = reference("RAGE", "Aimbot", "Minimum Damage") 

local function Pigu(c)
    if ((get(Check)) == true) then
        local Info = {}
        local PosE = {}
        local ToDamage = {}
        local EnemyIndex = get_players(true)

        for i = 1, #EnemyIndex do
            local Enemy = EnemyIndex[i]
            Enemy_Health = get_prop(Enemy, "m_iHealth")
            Enemy_Name = get_player_name(Enemy)
            Enemy_Pos_X, Enemy_Pos_Y, Enemy_Pos_Z = hitbox_position(Enemy, 3)
            Info[i] = {Enemy_Health, Enemy_Name}
            PosE[i] = {Enemy_Pos_X, Enemy_Pos_Y, Enemy_Pos_Z}
        end
        local PosM = {hitbox_position(get_local_player, 3)}
        for i = 1, #EnemyIndex do

            if (ent[i] == nil) then
                ent[i] = -1
            end

            if (ToDamage[i] > Info[i][1] and Damage <= Info[i][1]) then
                indicator(175, 227, 32, 255, Info[i][2])
            elseif (ToDamage[i] < Info[i][1] and Damage >= Info[i][1]) then
                indicator(227, 32, 32, 255, Info[i][2])
            end
        end
    end
end

local error = callback("paint", Pigu)
if error then
    log("set_event_callback failed: ", error)
end
 

Lua online compiler

Write, Run & Share Lua code online using OneCompiler's Lua online compiler for free. It's one of the robust, feature-rich online compilers for Lua language, running the latest Lua version 5.4. Getting started with the OneCompiler's Lua editor is easy and fast. The editor shows sample boilerplate code when you choose language as Lua and start coding.

Taking inputs (stdin)

OneCompiler's Lua online editor supports stdin and users can give inputs to programs using the STDIN textbox under the I/O tab. Following is a sample Lua program which takes name as input and prints hello message with your name.

name = io.read("*a")
print ("Hello ", name)

About Lua

Lua is a light weight embeddable scripting language which is built on top of C. It is used in almost all kind of applications like games, web applications, mobile applications, image processing etc. It's a very powerful, fast, easy to learn, open-source scripting language.

Syntax help

Variables

  • By default all the variables declared are global variables
  • If the variables are explicitly mentioned as local then they are local variables.
  • Lua is a dynamically typed language and hence only the values will have types not the variables.

Examples

-- global variables
a = 10

-- local variables

local x = 30
Value TypeDescription
numberRepresents numbers
stringRepresents text
nilDifferentiates values whether it has data or not
booleanValue can be either true or false
functionRepresents a sub-routine
userdataRepresents arbitary C data
threadRepresents independent threads of execution.
tableCan hold any value except nil

Loops

1. While:

While is also used to iterate a set of statements based on a condition. Usually while is preferred when number of iterations are not known in advance.

while(condition)
do
--code
end

2. Repeat-Until:

Repeat-Until is also used to iterate a set of statements based on a condition. It is very similar to Do-While, it is mostly used when you need to execute the statements atleast once.

repeat
   --code
until( condition )

3. For:

For loop is used to iterate a set of statements based on a condition.

for init,max/min value, increment
do
   --code
end

Functions

Function is a sub-routine which contains set of statements. Usually functions are written when multiple calls are required to same set of statements which increase re-usuability and modularity.

optional_function_scope function function_name( argument1, argument2, argument3........, argumentn)
--code
return params with comma seperated
end