Scripts / showing and hiding sprites

Author
Message
MChapman
8
Years of Service
User Offline
Joined: 19th May 2015
Location: USA
Posted: 31st Mar 2016 01:53 Edited at: 31st Mar 2016 01:54
Is it possible to have if statements in the init function?

I have this


but I dont watn the image to be loaded until a variabels is set. so could I have this


sorry for the bad title name, this is for showing a sprite.
Markchapman10 is my Skype let's have some dev talk.
smallg
Community Leader
18
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 31st Mar 2016 09:45
You can but init functions are only run once when the model is first loaded into the game so its likely the value will be false if the script affecting the variable is loaded after the model with this script or the variable is changed while playing the game?

A better option is to check if watch_image == nil and var == alue and then create the image and sprite if those conditions are met during the main(e)
lua guide for GG
https://steamcommunity.com/sharedfiles/filedetails/?id=398177770
windows 10
i5 @4ghz, 8gb ram, AMD R9 200 series , directx 11
MChapman
8
Years of Service
User Offline
Joined: 19th May 2015
Location: USA
Posted: 31st Mar 2016 11:26
value, lol... My typo sorry. I can't get the sprite to show with show_image(0) but i did get it to half way work with


what I need is if show_clock == 1 then show image else dont show image. I've tried HideImage(0),ShowImage(0) and HideImage(watch_image) and showImage(watch_image) to no prevail.
Markchapman10 is my Skype let's have some dev talk.
smallg
Community Leader
18
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 31st Mar 2016 11:57
yh there's no show or hide for sprites, just repositioning them like that is the easiest way.
it's best not to recreate sprites that exist though, you should check theyre nil or do it in the init(e)

this will let you press e to toggle the watch sprite on or off
lua guide for GG
https://steamcommunity.com/sharedfiles/filedetails/?id=398177770
windows 10
i5 @4ghz, 8gb ram, AMD R9 200 series , directx 11
MChapman
8
Years of Service
User Offline
Joined: 19th May 2015
Location: USA
Posted: 31st Mar 2016 12:12 Edited at: 31st Mar 2016 12:27
Thank you, I'm not sure where I was messing up but you helped me fix it. here is the whole thing


I set it up for configuration, I've spent probably 2 days on this script and I've learned a lot from every one. This will eventually be my hud hopefully for my game. I had intended making it either come up as a watch in the center of the screen with a larger image, or be hud at the bottom of the screen but in due time.

the image, the attach files thing wouldn't load.
https://www.dropbox.com/s/btd0j5mpjvgj2n7/000.png?dl=0
Markchapman10 is my Skype let's have some dev talk.

Attachments

Login to view attachments

Login to post a reply

Server time is: 2024-05-03 09:37:15
Your offset time is: 2024-05-03 09:37:15