Jump to content




cross-api paintutils.drawImage


4 replies to this topic

#1 Waitdev_

  • Members
  • 432 posts
  • LocationAdelaide

Posted 16 May 2015 - 08: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.

#2 Square789

  • Members
  • 39 posts
  • LocationUniverse:C:/MilkyWay/Sol/Earth/Europe/Germany

Posted 16 May 2015 - 06: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 by Square789, 16 May 2015 - 06:46 PM.


#3 Waitdev_

  • Members
  • 432 posts
  • LocationAdelaide

Posted 16 May 2015 - 11:42 PM

View PostSquare789, on 16 May 2015 - 06:46 PM, said:

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)

#4 Bomb Bloke

    Hobbyist Coder

  • Moderators
  • 7,099 posts
  • LocationTasmania (AU)

Posted 17 May 2015 - 01: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).

#5 Waitdev_

  • Members
  • 432 posts
  • LocationAdelaide

Posted 17 May 2015 - 03:20 AM

View PostBomb Bloke, on 17 May 2015 - 01:06 AM, said:

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 :)





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users