Post by [HÐ]UnKnown on Nov 22, 2010 9:53:51 GMT -8
This is for my personal use. Disregard this thread.
number, string, boolean, table, function, nil, userdata, thread
Numbers
> print(2+2)
4
> print(2-7)
-5
> print(7*8)
56
> print(7/8)
0.875
Numbers not rounded into integers. They are floating points or "real numbers"
Assign values to variables using = operator
> x = 7
> print(x)
7
The variable x is created when the number 7 is assigned to it. use the print() function again to print out the value of x. now we can use the value in x for other calculations.
> x = x * 9
> print(x)
63
> print(x*2) -- will not change the value of x
126
> print(x)
63
Strings
print("hello")
hello
Assign variables to strings
who = "Lua user"
> print(who)
Lua user
You can concatenate (join together) strings together using the .. operator between two strings.
> print("hello ")
hello
> print("hello " .. who) -- the variable "who" was assigned above
hello Lua user
> print(who)
Lua user
Notice that the .. operator does not change the value of message unless the = assignment operator is used, just like numbers.
> message = "hello " .. who
> print(message)
hello Lua user
Unlike some other languages, you cannot use the + operator to concatenate strings. i.e.:
> message = "hello " + who
stdin:1: attempt to perform arithmetic on a string value
stack traceback:
stdin:1: in main chunk
[C]: ?
cmd('unbind space')
clientbase=getBaseAddr "client.dll"
vguibase=getBaseAddr "vguimatsurface.dll"
function ground() return (readmem(clientbase+0x51D0F0,4)~=-1) end
function gui() return (readmem(vguibase+0x117314,4)==1) end
jump=(function(bool) cmd((bool and "+" or "-").."jump") end)
while keyDown(35)==0 do
jump((ground() and (keyDown(32)~=0) and not gui()))
wait(5)
end
number, string, boolean, table, function, nil, userdata, thread
Numbers
> print(2+2)
4
> print(2-7)
-5
> print(7*8)
56
> print(7/8)
0.875
Numbers not rounded into integers. They are floating points or "real numbers"
Assign values to variables using = operator
> x = 7
> print(x)
7
The variable x is created when the number 7 is assigned to it. use the print() function again to print out the value of x. now we can use the value in x for other calculations.
> x = x * 9
> print(x)
63
> print(x*2) -- will not change the value of x
126
> print(x)
63
Strings
print("hello")
hello
Assign variables to strings
who = "Lua user"
> print(who)
Lua user
You can concatenate (join together) strings together using the .. operator between two strings.
> print("hello ")
hello
> print("hello " .. who) -- the variable "who" was assigned above
hello Lua user
> print(who)
Lua user
Notice that the .. operator does not change the value of message unless the = assignment operator is used, just like numbers.
> message = "hello " .. who
> print(message)
hello Lua user
Unlike some other languages, you cannot use the + operator to concatenate strings. i.e.:
> message = "hello " + who
stdin:1: attempt to perform arithmetic on a string value
stack traceback:
stdin:1: in main chunk
[C]: ?
Test Script:
cmd('unbind space')
clientbase=getBaseAddr "client.dll"
vguibase=getBaseAddr "vguimatsurface.dll"
function ground() return (readmem(clientbase+0x51D0F0,4)~=-1) end
function gui() return (readmem(vguibase+0x117314,4)==1) end
jump=(function(bool) cmd((bool and "+" or "-").."jump") end)
while keyDown(35)==0 do
jump((ground() and (keyDown(32)~=0) and not gui()))
wait(5)
end