21 posts
Posted 13 August 2014 - 03:41 AM
I am making a game and I am using this bit of code to display an image called MainMenu. Whenever I try testing this function, it responds with: attempt to index ? (a nil value)
How do I fix it?
function mainMenu()
term.clear()
term.getSize()
paintutils.loadImage(paint.MainMenu)
paintutils.drawImage(MainMenu, 1, 1)
end
7508 posts
Location
Australia
Posted 13 August 2014 - 03:55 AM
Take a look at
paintutils.loadImage and
paintutils.drawImage on the wiki to see the usage of each function.
21 posts
Posted 13 August 2014 - 04:05 AM
I did but it dosent make any sense to me
plz help
656 posts
Posted 13 August 2014 - 06:54 AM
paintutils.loadimage returns a table with the image data, paintutils.drawImage prints it to the screen. So…
paintutils.drawImage(paintutils.loadImage(path), xPos, yPos)
Try harder to understand the wiki, this could all be found there.
Edited by
7083 posts
Location
Tasmania (AU)
Posted 13 August 2014 - 07:06 AM
Psst - you missed a spot! ;)/>
SooBahkCode, if you're still having trouble, maybe elaborate on where you're defining "paint.MainMenu".
21 posts
Posted 13 August 2014 - 03:33 PM
Thnkz for the help. (By the way, im new at coding and couldnt understand the wiki and it didnt say to put paintutils.loadImage() inside of paintutils.drawImage ()!)
7508 posts
Location
Australia
Posted 13 August 2014 - 04:31 PM
well no, you don't have to do that. if you take a look at the example code from the wiki
local image = paintutils.loadImage("bar")
paintutils.drawImage(image, 3, 5)
this will load the image file 'bar' into a variable called
image. you may then notice that image is used as the first value for
drawImage, this gives it the image that was loaded from the file so that it can be drawn.
21 posts
Posted 13 August 2014 - 04:45 PM
Is this what you want me to do?
function mainMenu()
term.clear()
term.getSize()
local image = paintutils.loadImage(paint.MainMenu)
paintutils.drawImage(image, 1, 1)
end
If so, its giving me the same error.
21 posts
Posted 13 August 2014 - 04:51 PM
Nevermind! I finally got it working. Thanks for helping! It means a lot. Your advice really helped.