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
--Player 1:
--Coordinates:
p1X = memory.readbyte(0x00A6)
p1Y = memory.readbyte(0x00D0)
p1Z = memory.readbyte(0x00BB)
--Others things:
p1m = memory.readbyte(0x0447)--Power meter
--Player 2:
--Coordinates:
p2X = memory.readbyte(0x00A5)
p2Y = memory.readbyte(0x00CF)
p2Z = memory.readbyte(0x00BA)
--Others things:
--p2m = memory.readbyte(0x0447)
--Player 3:
--Coordinates:
p3X = memory.readbyte(0x00A7)
correction(p3s,p3X,p3Xc)
p3Y = memory.readbyte(0x00D1)
p3Z = memory.readbyte(0x00BC)
--Others things:
p3m = memory.readbyte(0x0449)
p3s = memory.readbyte(0x00AE)--Screen location (0 = Left, 1 = right(+255))
--Player 4:
--Coordinates:
p4X = memory.readbyte(0x00A8)
correction(p4s,p4X,p4Xc)
p4Y = memory.readbyte(0x00D2)
p4Z = memory.readbyte(0x00BD)
--Others things:
p4m = memory.readbyte(0x044A)
p4s = memory.readbyte(0x00AF)
--Ball
--Coordinates
ballX = memory.readbyte(0x00A9)
correction(balls,ballX,ballXc)
ballY = memory.readbyte(0x00D3)
ballZ = memory.readbyte(0x00BE)
--Others:
balls = memory.readbyte(0x00B0)
----------------------------------------------------------------------------------
gui.drawbox(110,160,255,246)--The box where the field will be.
--The field:
--X1___________X2 <--------------- Y1
--| |
--X3___________X4 <--------------- Y2
--Notes:
--Net height: 59
--Net X: 188
--Up:119 (Y1)
--Down:28 (Y2)
--Up right: 75+255 (X2)
--Down Right: 98+255 (X4)
--Up Left: 69(X1)
--Down Left: 46 (X2)
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")
--Net:
gui.line(N1,Y1,N1,Y2, "Black")
-----------------------------------------------------------------------------
--Second Radar
gui.drawbox(0,160,110,246)
--Radar for Z position
gui.line(10,174.5,10,220,"black")--Vertical line #1
gui.line(10,174.5,15,174.5,"black")--Up horizontal line
gui.line(10,220,15,220,"black")--Down horizontal line
--Ball
gui.pixel(15,234-ballZ/2,"blue")
--Radar for Y & X position
gui.line(30,220,95.25,220,"black")--Horizontal line
gui.line(65,220,65,205.25,"black")--Net
--Ball
pixel(ballXc/4,12.75,ballY/4,220,blue)
--Players
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
--Notes:
--Net height: 59
--Net X: 188
--Up:119
--Down:28
--Up right: 75+255
--Down Right: 98+255
--Up Left: 69
--Down Left: 46
while true do
gui.drawbox(110,160,255,246)--The box where the field will be.
--The field:
--X1___________X2 <--------------- Y1
--| |
--X3___________X4 <--------------- Y2
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")
--Net:
gui.line(N1,Y1,N1,Y2, "Black")
--Second Radar
-- gui.drawbox(0,160,110,246)
--Radar for Z position
-- gui.line(10,174.5,10,220,"black")--Vertical line #1
-- gui.line(10,174.5,15,174.5,"black")--Up horizontal line
--gui.line(10,220,15,220,"black")--Down horizontal line
--Ball
--BallZ = memory.readbyte(0x00BE)/2
--gui.pixel(15,234-BallZ,"blue")
--Radar for Y & X position
gui.line(30,220,95.25,220,"black")--Horizontal line
gui.line(65,220,65,205.25,"black")--Net
--Ball
--Y
BallY = memory.readbyte(0x00D3)/4
--X
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")
----------------
--Players
--1
--Y
p1Y = memory.readbyte(0x00D0)/4
--X
p1X = memory.readbyte(0x00A6)/4
gui.line(p1X+12.75,220-p1Y,p1X+12.75,212-p1Y,"red")
--2
--Y
p2Y = memory.readbyte(0x00CF)/4
--X
p2X = memory.readbyte(0x00A5)/4
gui.line(p2X+12.75,220-p2Y,p2X+12.75,212-p2Y,"red")
--3
--X
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
--Y
p3Y = memory.readbyte(0x00D1)/4
gui.line(p3X+12.75,220-p3Y,p3X+12.75,212-p3Y,"red")
--4
--X
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
--Y
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?