This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
Waitdev_'s profile picture

cross-api paintutils.drawImage

Started by Waitdev_, 16 May 2015 - 07:21 AM
Waitdev_ #1
Posted 16 May 2015 - 09:21 AM
Hey, i was just needing help, I'm programming an OS and i need to make backgrounds.

i'm making my os be a cross-program os, and i want to show images.

i have 3 files through different directory, and its not really working well.

the first code is a library of pictures, so heres what its like:

pic = paintutils.loadImage("example")


thats an example, but its what the code is sort of about, a list of variables. (used as api)

the second one is settings, and it is like this:

os.loadAPI("PaOS/backgrounds/imglib")
background = pic
--from the lib

the third one shows the pic, but this is where i am getting problems.

os.loadAPI("PaOS/settings")
os.loadAPI("PaOS/backgrounds/bglib")
paintutils.drawImage("pic,2,2")
if comes out with "home:3 expected img,x,y"
i don't get why it does this, but i need help with it.
Square789 #2
Posted 16 May 2015 - 07:46 PM
You are trying to use

paintutils.drawImage("pic,2,2")
which will try to draw an image called pic,2,2 , because you entered this value as a string.
this function needs three parameters, img, x and y.
Try

paintutils.drawImage(pic, 2, 2)
, it then calls the function with the table pic and the number values x and y, so then the picture should be drawn.
Edited on 16 May 2015 - 05:46 PM
Waitdev_ #3
Posted 17 May 2015 - 12:42 AM
You are trying to use

paintutils.drawImage("pic,2,2")
which will try to draw an image called pic,2,2 , because you entered this value as a string.
this function needs three parameters, img, x and y.
Try

paintutils.drawImage(pic, 2, 2)
, it then calls the function with the table pic and the number values x and y, so then the picture should be drawn.
thanks so much! this worked very well and took a very long time to work out before. (time saved x400)
Bomb Bloke #4
Posted 17 May 2015 - 02:06 AM
Remember, though, that to access global variables defined by an API you've loaded, you need to refer to them as <APIName>.<variableName>.

For example, if your first API is saved as "imglib", then your other scripts would access its "pic" variable as "imglib.pic" (sans quotes).
Waitdev_ #5
Posted 17 May 2015 - 04:20 AM
Remember, though, that to access global variables defined by an API you've loaded, you need to refer to them as <APIName>.<variableName>.

For example, if your first API is saved as "imglib", then your other scripts would access its "pic" variable as "imglib.pic" (sans quotes).
i got that when i was testing, but thanks for telling me :)/>