Scripts / Images sequence script problem

Author
Message
MrOversea
5
Years of Service
User Offline
Joined: 26th Mar 2019
Location:
Posted: 16th Apr 2019 21:34

Hello! I have a question about the script from this thread
I`m not an expert in LUA, as i'm already wrote ))), maybe I don't understand something... in short:
I try to make something like this: Player comes into a Trigger Zone (or get close to entity, that acts like a Trigger Zone (I wrote about it). Script we talk about started and shows for Player some first image (First instruction for Player - who he is, where he is and what he got to do) and activated another entity-trigger from its IfUsed field. Player pressed E key and proceeded further to find second trigger. When player gets close to second trigger, starts another script (I mean the same script, but, of course with another name.) Second script shows sequence of images (more detailed instructions for Player), and activated one more entity - trigger from IfUsed field. Player pressed E key for each next image, then goes further, gets close to third trigger and recieved another sequence of images.

I understand, that all images we talk about must be placed in different folders, for a sample scriptbank\images\Mission1, scriptbank\images\Mission2 and scriptbank\images\Mission3. This folders must be defined in every script in string LoadImages("NAME OF FOLDER",0).

What I have on practice - If I placed on the map only first combination trigger/script with its images folder, everything works perfectly. But in case of adding second trigger/script something strange happens - first script shows me images not from its folder Mission1 but from folder, defined in another script, Mission2 or Mission3. Second script at the same time works normally.

Anybody can help?
Best regards, Oversea.
PM
Avenging Eagle
19
Years of Service
User Offline
Joined: 2nd Oct 2005
Location: UK
Posted: 17th Apr 2019 00:27
Can you post the scripts so members can take a closer look?

AE
MrOversea
5
Years of Service
User Offline
Joined: 26th Mar 2019
Location:
Posted: 17th Apr 2019 05:10
Of course, here it is:

This if the first script



This script is assigned to a first entity, in its properties I define "Spawn at start - Yes". In the folder scriptbank\images\Mission_01 I placed images 000.png and 001.png.

This is the second script:



This script is assigned to a second entity, in its properties I define "Spawn at start - No". (the name of second entity I define in If Used field of the first entity), In the folder scriptbank\images\Mission_02 I placed images 000.png, 001.png, 002.png etc.
Best regards, Oversea.
PM
AmenMoses
GameGuru Master
8
Years of Service
User Offline
Joined: 20th Feb 2016
Location: Portsmouth, England
Posted: 17th Apr 2019 16:58
My guess would be that the _init function is being called even though "Spawn at start - No".

Personally I would call the LoadImages from main the first time it is called.
Been there, done that, got all the T-Shirts!
PM
MrOversea
5
Years of Service
User Offline
Joined: 26th Mar 2019
Location:
Posted: 17th Apr 2019 18:14
AmenMoses, Thank You!

I `ve tried to change the script this way - removed LoadImages from _init and added it in _main.



So, what happens - if i add LoadImages before PlayerDist, GameGuru slows down, almost freezes in test game. If I add it after PlayerDist check, one image shows with small (almost invisible) freeze, but sequence of 15 images freezes GameGuru at all...

What I did now - for showing of the first image i use modified script, for the rest sequences - old version.

It works for me, but i wonder - what may be cause of freezes? The images I use are .png files, 1480 x 935 px (almost fullscreen), 72 DPI, about 1.5 - 2 Mb. , I can't make them smaller without quality loss.
Maybe, GG slows down when loaded about 25 Mb of images? But old version of the script works without this problem...
Best regards, Oversea.
PM
AmenMoses
GameGuru Master
8
Years of Service
User Offline
Joined: 20th Feb 2016
Location: Portsmouth, England
Posted: 17th Apr 2019 19:08
You want to make sure to only load the images once.

_main will get called every frame so you need to create a 'first_pass' flag to control that.
Been there, done that, got all the T-Shirts!
PM
smallg
Community Leader
19
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 17th Apr 2019 20:44
you really don't want to be using the LoadImages command at all, use LoadImage and sprites instead, much better for the end result as images are just loaded at their default size but sprites you can resize and position as needed and they will look (roughly) the same for everyone
lua guide for GG
https://steamcommunity.com/sharedfiles/filedetails/?id=398177770
windows 10
i5 @4ghz, 8gb ram, AMD R9 200 series , directx 11

Login to post a reply

Server time is: 2024-12-22 14:27:01
Your offset time is: 2024-12-22 14:27:01