Originally Posted by
snake
emm i have a question..
i=0
local function press(key)
if key==string.byte("o") then
i=i+1
end
local function tellme()
if i=1 then
echo("you press once")
elseif i=2 then
echo("you press twice")
elseif i=3 then
echo("how about stop clicking it already?")
end
add_hook("press","the key", press)
whats wrong here?..
i need to get different echo depends what time i clicked on "o" key...
but this script dnt work..
Firstly you need to end your ifs, like you do with functions.
Secondly you need to use == (two equals signs) to compare, one equals sign is a set statement,
a = b will set a as b where as
a == b will return true if a is equal to b.
Thirdly, you never call the tellme function.
Finally there isn't a hook called "press", you'll want "key_down" or "key_up"
i=0
local function press(key)
if key==string.byte("o") then
i=i+1
tellme()
end
end
local function tellme()
if i == 1 then
echo("you press once")
elseif i == 2 then
echo("you press twice")
elseif i == 3 then
echo("how about stop clicking it already?")
end
end
add_hook("key_down","the key", press)