Alright, it's me again,
I wrote a new script for a another purpose just for fun, and I stumbled on something.
I can't seem to be able to make "ballXc" a real value(and not a nil value). Same goes with p3Xc and p4Xc...
Also, there is something wrong with the color for the first function... I don't know why.
I'm puzzled since I've checked like 10 times and I couldn't tell what is wrong...
If you're not in the mood to help, that's okay! ^^ I wrote this since I think I made a stupid mistake that shouldn't take a lot of time for you to debug it.
Here is the script:
Language: lua
function pixel(x,xc,y,yc,color)
gui.pixel(xc+x,yc-y,color)
end
function correction(screen,x,name)
if screen == 0 then
name = x
end
if screen == 1 then
name = x + 255
end
end
while true do
p1X = memory.readbyte(0x00A6)
p1Y = memory.readbyte(0x00D0)
p1Z = memory.readbyte(0x00BB)
p1m = memory.readbyte(0x0447)
p2X = memory.readbyte(0x00A5)
p2Y = memory.readbyte(0x00CF)
p2Z = memory.readbyte(0x00BA)
p3X = memory.readbyte(0x00A7)
correction(p3s,p3X,p3Xc)
p3Y = memory.readbyte(0x00D1)
p3Z = memory.readbyte(0x00BC)
p3m = memory.readbyte(0x0449)
p3s = memory.readbyte(0x00AE)
p4X = memory.readbyte(0x00A8)
correction(p4s,p4X,p4Xc)
p4Y = memory.readbyte(0x00D2)
p4Z = memory.readbyte(0x00BD)
p4m = memory.readbyte(0x044A)
p4s = memory.readbyte(0x00AF)
ballX = memory.readbyte(0x00A9)
correction(balls,ballX,ballXc)
ballY = memory.readbyte(0x00D3)
ballZ = memory.readbyte(0x00BE)
balls = memory.readbyte(0x00B0)
gui.drawbox(110,160,255,246)
X1 = 110 + 34.5/1.3
X2 = 110 + 165/1.3
X3 = 110 + 23/1.3
X4 = 110 + 176.5/1.3
Y1 = 130 + 59.5/1.3
Y2 = 130 + 105/1.3
N1 = 110 + 104.5/1.3
gui.line(X1,Y1,X2,Y1,"purple")
gui.line(X1,Y1,X3,Y2,"purple")
gui.line(X2,Y1,X4,Y2,"purple")
gui.line(X3,Y2,X4,Y2,"purple")
gui.line(N1,Y1,N1,Y2, "Black")
gui.drawbox(0,160,110,246)
gui.line(10,174.5,10,220,"black")
gui.line(10,174.5,15,174.5,"black")
gui.line(10,220,15,220,"black")
gui.pixel(15,234-ballZ/2,"blue")
gui.line(30,220,95.25,220,"black")
gui.line(65,220,65,205.25,"black")
pixel(ballXc/4,12.75,ballY/4,220,blue)
pixel(p1X/4,12.75,p1Y/4,220,red)
pixel(p2X/4,12.75,p2Y/4,220,red)
pixel(p3Xc/4,12.75,p3Y/4,220,red)
pixel(p4Xc/4,12.75,p4Y/4,220,red)
emu.frameadvance()
end
Here is the same code, but written with no function. That one does what I want it to do. I felt there were a lot of repetition, so I made functions in order to reduce lines...
Language: lua
while true do
gui.drawbox(110,160,255,246)
X1 = 110 + 34.5/1.3
X2 = 110 + 165/1.3
X3 = 110 + 23/1.3
X4 = 110 + 176.5/1.3
Y1 = 130 + 59.5/1.3
Y2 = 130 + 105/1.3
N1 = 110 + 104.5/1.3
gui.line(X1,Y1,X2,Y1,"purple")
gui.line(X1,Y1,X3,Y2,"purple")
gui.line(X2,Y1,X4,Y2,"purple")
gui.line(X3,Y2,X4,Y2,"purple")
gui.line(N1,Y1,N1,Y2, "Black")
gui.line(30,220,95.25,220,"black")
gui.line(65,220,65,205.25,"black")
BallY = memory.readbyte(0x00D3)/4
if memory.readbyte(0x00B0) == 0 then
BallX = memory.readbyte(0x00A9)/4
end
if memory.readbyte(0x00B0) == 1 then
BallX = memory.readbyte(0x00A9)/4 + 255/4
end
gui.pixel(12.75+BallX,220-BallY,"blue")
p1Y = memory.readbyte(0x00D0)/4
p1X = memory.readbyte(0x00A6)/4
gui.line(p1X+12.75,220-p1Y,p1X+12.75,212-p1Y,"red")
p2Y = memory.readbyte(0x00CF)/4
p2X = memory.readbyte(0x00A5)/4
gui.line(p2X+12.75,220-p2Y,p2X+12.75,212-p2Y,"red")
if memory.readbyte(0x00AE) == 0 then
p3X = memory.readbyte(0x00A7)/4
end
if memory.readbyte(0x00AE) == 1 then
p3X = memory.readbyte(0x00A7)/4 + 255/4
end
p3Y = memory.readbyte(0x00D1)/4
gui.line(p3X+12.75,220-p3Y,p3X+12.75,212-p3Y,"red")
if memory.readbyte(0x00AF) == 0 then
p4X = memory.readbyte(0x00A8)/4
end
if memory.readbyte(0x00AF) == 1 then
p4X = memory.readbyte(0x00A8)/4 + 255/4
end
p4Y = memory.readbyte(0x00D2)/4
gui.line(p4X+12.75,220-p4Y,p4X+12.75,212-p4Y,"red")
emu.frameadvance()
end
Those two codes should do the same thing...
Does someone knows why?