Attract-Mode Support Forum

Attract-Mode Support => Scripting => Topic started by: zpaolo11x on May 24, 2019, 05:14:13 AM

Title: Changing the source of an artwork
Post by: zpaolo11x on May 24, 2019, 05:14:13 AM
Let's say I have something like

testobject = fe.add_artwork("snap",0,0,200,200)

is it possible to change the "source" of the artwork data, for example from snap to flyer, on the fly?
Title: Re: Changing the source of an artwork
Post by: keilmillerjr on May 24, 2019, 05:25:57 AM
Quote from: https://github.com/mickelson/attract/blob/master/Layouts.md#Image
file_name - [image & artwork only] Get/set the name of the image/video file being shown. Note that if you set this on an artwork or a dynamic image object it will get reset the next time the user changes the game selection. If file_name is contained in an archive, this string should be formatted: "<archive_name>|"
Title: Re: Changing the source of an artwork
Post by: rand0m on May 24, 2019, 05:42:11 AM
Magic token and if statement should work but I think it would require a reload. perhaps use it with signal?
Title: Re: Changing the source of an artwork
Post by: zpaolo11x on May 24, 2019, 05:50:05 AM
Quote from: https://github.com/mickelson/attract/blob/master/Layouts.md#Image
file_name - [image & artwork only] Get/set the name of the image/video file being shown. Note that if you set this on an artwork or a dynamic image object it will get reset the next time the user changes the game selection. If file_name is contained in an archive, this string should be formatted: "<archive_name>|"

This is what I'm trying to do right now. My theme relies on .index_offset and .rawset_index_offset to work smoothly and file_name doesn't work with that (it works but each time the index_offset is changed it reverts to the old artwork). It seems that force-loading artwork with file_name=fe.get_art() etc. works smoothly enough, so it's a good workaround.
Title: Re: Changing the source of an artwork
Post by: zpaolo11x on May 24, 2019, 06:32:18 AM
Quote from: https://github.com/mickelson/attract/blob/master/Layouts.md#Image
file_name - [image & artwork only] Get/set the name of the image/video file being shown. Note that if you set this on an artwork or a dynamic image object it will get reset the next time the user changes the game selection. If file_name is contained in an archive, this string should be formatted: "<archive_name>|"

There are some issues with this solution: if the same artwork (say "snap") contains both audio and video, by default it loads video. The instructions says to use the "Art.ImageOnly" parameter, but that throws an error, and using "Art.ImagesOnly" (with an "s") doesn't seem to change either, still it tries to load videos.
Title: Re: Changing the source of an artwork
Post by: zpaolo11x on May 24, 2019, 08:24:49 AM
My bad, I forgot one parameter in the function call :/ Now it seems to work perfectly