Help with your scripting

How to Create and Update an Image at Runtime?

How to Create and Update an Image at Runtime?

Postby Shando » 31 Mar 2022, 23:34

Hi all,

I have been trying to get my head around the TextureManager and Image functions and can't seem to get them to play nicely :( Basically, I am trying to create a Minimap that only shows the visited locations, so the texture displayed in the GUI needs to be updated via code.

It looks like I can load a base Texture using:
Code: Select all
myTex = textureManager.loadTexture ( "minimap.png", "" )


But I can't work out how to create an Image from this Texture so that I can then change through code using something like:
Code: Select all
myImg:setColourAt ( tVec, BLACK )


I believe it's something to do with creating a new Image (this is the bit I can't seem to get working) and then, possibly:
Code: Select all
myImg:createEmptyImageLike ( myTex )


Any help would be greatly appreciated

Shando
Ryzen 7 4800H 16GB GTX1650 Win 11 64
Love, Hope, Strength http://www.lovehopestrength.co.uk
User avatar
Shando
Skyline Moderator
Skyline Moderator
 
Posts: 560
Joined: 06 Mar 2013, 22:35
Location: Moffat Beach, Queensland
Skill: Programmer
Skill: Scripter
Skill: Level Designer

Re: How to Create and Update an Image at Runtime?

Postby Shando » 10 Apr 2022, 01:11

Hi again,

After a bit of digging, I think I worked out how to create an Image (using Image ( )):

Code: Select all
   myTex = textureManager.loadTexture ( "minimap.png", "" )
lprint("initMinimap: 4")
   myImg = Image ( )
lprint("initMinimap: 6")
   myImg:createEmptyImageLike ( myTex )


When I run the above code, the console logs the first lprint then Skyline crashes to desktop. I have tried this half a dozen times with the same result each time :(

I've checked the Skyline.log file and can't see anything that relates to this?

Any help would be greatly appreciated.

Thanks in advance

Shando
Ryzen 7 4800H 16GB GTX1650 Win 11 64
Love, Hope, Strength http://www.lovehopestrength.co.uk
User avatar
Shando
Skyline Moderator
Skyline Moderator
 
Posts: 560
Joined: 06 Mar 2013, 22:35
Location: Moffat Beach, Queensland
Skill: Programmer
Skill: Scripter
Skill: Level Designer

Re: How to Create and Update an Image at Runtime?

Postby Action52 » 04 Aug 2022, 11:33

no there is no log writter in Skyline, it makes it hard to find bugs random crashes still typically problem
User avatar
Action52
Skyline Apprentice
 
Posts: 25
Joined: 02 Jan 2022, 05:16
Skill: Audio


Return to Lua Scripting

Who is online

Users browsing this forum: No registered users and 4 guests

cron