I'm not sure how useful this is to anyone, but since I already wrote it:
Assigning discrete values to an array in a single line:
Language: lua
local Array = {}
--Because some of the values are all over the place
function assign_multi(string,...)
for i, v in ipairs(arg) do
Array[v] = string
end
end
assign_multi("Village",20,46,97,131,132)
assign_multi("Forest",2,3,133)
assign_multi("Village 2",88,141,166,168)
Checking if a key in keyboard has been pressed, then react after a set amount of frames:
Download inputdelay.luaLanguage: lua
function inputdelay(inputs, delay)
local is = input.get()
local start = false
if inputs ~= nil and (is[tostring(inputs)] ~=nil) then
console.log(is)
while (delay > 0) do
emu.frameadvance()
delay = delay -1
end
start = true
return start
end
return start
end
while true do
if inputdelay("C",30) then
gui.text(0,0,"Hi") --debugging
end
emu.frameadvance()
end
Mouse input checking:
Download mouse.luaLanguage: lua
--checks the mouse position during a click relative to the client and see if its within some range
function get_mouse_pos(x,y,width,height)
mx = input.getmouse().X
my = input.getmouse().Y
--input.getmouse() is already relative to client
if (mx > x and mx <x> y and my < y+height) then
return true
end
return false
end
while true do
if (input.getmouse().Left and get_mouse_pos(0,50,80,20)) then
gui.drawText(0,30,"Hello")
end
emu.frameadvance()
end