Few Lua Questions
Posted: Wed Jan 27, 2010 11:40 pm
I hate to ask here but i keep looking for a tutorials for this and i can't seem to get it working right.
My goal is to make me walk function take two tables as it's arguments then go through each element in the tables using them as coords to move.
I tried to just use a if statement to change mtX i = i+1... But i get an error saying lua30: attempt to perform arithmetic on local 'mtX' (a table value)
Sadly I removed that code. All i really need to know is how to pass and change a value of a table into my function.
Edit:I have no idea why this works like this cause i tried the exact same thing inside the function and i get the error...
My goal is to make me walk function take two tables as it's arguments then go through each element in the tables using them as coords to move.
I tried to just use a if statement to change mtX i = i+1... But i get an error saying lua30: attempt to perform arithmetic on local 'mtX' (a table value)
Sadly I removed that code. All i really need to know is how to pass and change a value of a table into my function.
Code: Select all
printf("fff\n");
function main()
myProc = openProcess( findProcess("fff") );
--attach( findWindow( fff" ));
printf( "Xenimus Hwnd: %s \n", myProc );
mouseX = 0x027C5B6C; --Mouse X position memory address
mouseY = 0x02484014; --Mouse Y position memory address
i = 0;
desX = {2730, 2729, 2721, 2710, 2707, 2712, 2714, 2727, 2730}; --These 2 will be my destination x, y... where i want to walk to.
desY = {2758, 2768, 2772, 2768, 2773, 2776, 2770, 2772, 2764};
setStartKey(key.VK_DELETE);
setStopKey(key.VK_END);
function moveTo(mtX, mtY)
curX = memoryReadInt(myProc, 0x02C84944); --My current X position
curY = memoryReadInt(myProc, 0x0157C78C); --My current Y position
x = (800 / 12 * (mtX - curX) + 400);
y = (600 / 10 * (mtY - curY) + 300);
printf("x: %d \n", x);
printf("y: %d \n", y);
memoryWriteFloat(myProc, mouseX, x);
memoryWriteFloat(myProc, mouseY, y);
mouseLClick();
yrest(1000);
end
start=1;
while(start==1) do
moveTo(desX, desY);
end
end
startMacro(main);
Code: Select all
while(start==1) do
curX = memoryReadInt(myProc, 0x02C84944); --My current X position
curY = memoryReadInt(myProc, 0x0157C78C); --My current Y position
if(curX - desX[i] == 0 and curY - desY[i] == 0) then
i = i+1;
end
moveTo(desX[i], desY[i]);
end