Attract-Mode Support Forum

Attract-Mode Support => Scripting => Topic started by: dbinott on June 18, 2016, 11:10:05 AM

Title: Is there a file exists function or similar in squirrel? [SOLVED]
Post by: dbinott on June 18, 2016, 11:10:05 AM
I have looked around but can't really figure out if there is something like that.
Title: Re: Is there a file exists function or similar in squirrel?
Post by: Daimon on June 24, 2016, 12:33:00 AM
Try:

fe.load_module("file");
function file_exist(fullpathfilename)
   {
   try {file(fullpathfilename, "r" );return true;}catch(e){return false;}
   }
Title: Re: Is there a file exists function or similar in squirrel?
Post by: dbinott on June 28, 2016, 06:26:23 PM
sweet. thanks. worked great!
Title: Re: Is there a file exists function or similar in squirrel? [SOLVED]
Post by: calle81 on May 01, 2017, 03:57:21 AM
I need help with this file exist function. Trying to make a "default theme" when there is no video theme available. It will check for videotheme/"[Title].mp4". If that file does not exist load a background file and position and size the snap for that background.
I found this this snippet above but I'm not sure how to use it:

If anyone can shed some light on how to use this function it would be greatly appreciated.
Title: Re: Is there a file exists function or similar in squirrel? [SOLVED]
Post by: calle81 on May 01, 2017, 10:43:41 AM
To illustrate what I mean look at this video: https://www.youtube.com/watch?v=B9wIOi1hLeo&t=18s.

I want to improve this theme so that when there is no recorded hyperspin theme (these are just mp4 files) the snap is not played full screen. In the video you can see what currently happens at 1:15 when there is no video theme available. Thus I want to place the video themes in its own folder and have a check in the theme if the video theme file exists or not and adapt the theme to play the snap in a smaller window.
Title: Re: Is there a file exists function or similar in squirrel? [SOLVED]
Post by: calle81 on May 06, 2017, 05:14:00 PM
Soo

The file exist code breaks my theme. I load the the module and use this code:

If file_exist("videothemes/[DisplayName]/[Title].mp4"){
local snap = FadeArt( "snap", 0, 0, flw, flh );
snap.trigger = Transition.EndNavigation;
if ( my_config["Preserve_Aspect_Ratio"] == "Yes")
{
snap.preserve_aspect_ratio = true;
}
}

Anyone that can help me find the error?