MODULE: FadingThingsNonBlocking v2.29

Started by Lazarus, Wed 03/01/2007 11:43:26

Previous topic - Next topic

Lazarus

Firstly a big thank you to Ashen with helping me with this module.

Fading Objects, Characters & Gui's Non Blocking.

FadingThingsNonBlocking.zip Current version 2.29

Requirements:-  AGS 2.70 +

This Module is for fading objects, characters & Gui's Non Blocking function, in that you don't have to wait for these functions to finish before something else happens.
So you can fade in or out an object while messages are spoken for example.
-----------------------------------------------------------------------
This module allows for upto and including 50 different Objects, 300 different Characters and 50 different Gui's to be faded in/out simultaneously or staggered with the timer control. (Per Room)

This is reset PER ROOM.

At the moment the current ags limits are:
20  objects per room
300  characters
50  GUIs
-----------------------------------------------------------------------

This module uses the script O-names for all the commands.
-----------------------------------------------------------------------

Command examples:-
Code: ags

FadeObjectIn_NoBlock(oWax, 0, 0);
FadeObjectIn_NoBlock(oWax, 0, 0, 250);
FadeObjectOut_NoBlock(oWax, 100, 0);

FadeCharacterIn_Noblock (cEgo, 0, 0); 
FadeCharacterIn_Noblock (cEgo, 0, 0, 0, 100, 150); 
FadeCharacterOut_Noblock (cEgo, 100, 0);

FadeGuiOut_NoBlock(gMaingui, 100, 0);
FadeGuiIn_NoBlock(gMaingui, 0, 0, 250);

-----------------------------------------------------------------------
Objects & Gui's with a transparency of 100 will be turned off automatically
NPC Characters with a transparency of 100 will be moved to Room (-1). But NOT the player Character.
-----------------------------------------------------------------------

VALUE = Transparency: -
Fade Objects, Characters & Gui's In/Out by value which can be any value between 0 and 100.
0 = visible
Any number between = ghosting
100 = invisible
-----------------------------------------------------------------------

SPEED: -
Setting the speed of fading.
-20 = Even Faster etc..
 -1 = Fast etc..
  0 = normal
  1 = slow
  2 = slower
  3 = even slower etc..
-----------------------------------------------------------------------

TIMER:-
Timer is like a fuse on a bomb in that say you entered the figure 250, this will count down to 0 (zero) and then execute the command.
Entering the number 0 (zero) will execute straight away. (You cannot enter minus figures).

Also if you don't need the timer but want to use the new coordinates then just enter 0 (zero) for the timer.
-----------------------------------------------------------------------

OBJECTS: -
Objects now don't need to be ticked visible and have transparency set to 100 before use.
Instead you can leave the objects unticked so they are turned off, and then just use the FadeObjectIn function
as turning an object on is dealt within the function.

The FadeObjectOut function now turns objects OFF automatically if transparency = 100.

Commands:-
FadeObjectIn_NoBlock(oWax, 0, 0, 250);
Will fade the object Wax in, totally visble,speed normal with a 250 timer delay.
-----------------------------------------------------------------------

CHARACTERS: -
If characters are already starting in room 5 for example you will have to set that characters transparency
in that room, using a run-script under (Before Fadein) e.g.

character[EGO].Transparency =100; // Invisible
or
cEgo.Transparency = 100; // Invisible

Or you can have that character to start in room (-1) or from another room and just use the FadeCharacterIn function
and all transparencies are dealt with e.g.

Commands:-
FadeCharacterIn_Noblock (cEgo, 0, 0);
This will fadein character EGO totally visible using normal speed.

Also you can set where if needed new X and Y positions of a character when fading in,
this is an optional command, so you don't need to set these if you want to use the previous coordinates.
e.g.

FadeCharacterIn_Noblock (cEgo, 0, 0, 0, 100, 150);

If you want to use the new coordinates, BUT not the Timer then you must enter a number
for the Timer function like 0 (zero) for immediate executions.

This will fadein character EGO totally visible using normal speed, zero Timer and place the character
at the new given co-ordinates.

Now also if NPC characters are totally invisible (100) they are moved automatically to Room (-1).
-----------------------------------------------------------------------

GUI's
Added the ability to fade in/out gui's

Commands:-
FadeGuiOut_NoBlock(gMaingui, 100, 0);
Will fade out the gui totally invisible with normal speed.

FadeGuiIn_NoBlock(gMaingui, 0, 0, 250);
Will fade in the gui totally visible using normal speed with a delay.

-----------------------------------------------------------------------
-----------------------------------------------------------------------

Version History:
2.29 Changed Max Characters to 300 per room.

2.28 Fixed game pausing while skip cutscene is used, lowered define values of
       Objects,Characters and Gui's per room to speed up module.

2.27 Fixed typo error at line #168. (Thanks Scorpiorus).

2.26 Added support of fading in/out of GUI's.

2.25 Changed module name to "FadingThingsNonBlocking".

2.24 Bug Fix - Able to constantly repeate fade in/out of Objects
                     and Characters under room repeatedly execute.

2.23 Bug Fix - Characters and Objects now fade into current room
                     properly with Timer function.

2.22 Characters can now use optional new coordinates when
       fading in or use orignial coordinates.

2.21 Objects with a transparency of 100 will be turned off
       automatically.

2.20 NPC Characters with a transparency of 100 will be moved to
       room(-1). But NOT the player Character.

2.19 Characters are now able to be faded in from another room
       to player room. No need to set transparency before hand.

2.18 Objects can now be turned on within fade in function.
       No need to set transparency before hand.

2.17  Bug Fix - Fading in/out works when game is being skipped,
                      for example by the enter key.

2.16 Too many things to list.
*Currently using AGS Editor 2.70 (Build 2.70.601)*

Scorpiorus

I just have found there is a typo at line #168 in the module script where the code is:

Code: ags

if (Fading3 < MAXGUI) Fading1 ++;


instead of

Code: ags

if (Fading3 < MAXGUI) Fading3 ++;


as it is supposed to be.

Lazarus

Thanks Scorpiorus I've updated module
*Currently using AGS Editor 2.70 (Build 2.70.601)*

Lt. Smash

When I use your module, its nearly not possible to skip cutscenes.

What I did:
I added your module to my game.
I compiled my game without using any code from your module.
I pressed ESC to skip my intro sequence but what happened:

The game freezes until the cutscene is finish -> Then the game continues normally.
When I let the ESC pressed it only needs 10 seconds to finish the cutscene but thats very annoying.

Hope you can fix it.

Lazarus

Thanks again to Ashen for the help.

Module has been updated so there should't be a pause while using cutscenes.

Value of objects,characters and gui's have been lowered to speed up the module to 50 different Objects, 100 different Characters and 50 different Gui's as this is per room settings and should be enough for most people.
*Currently using AGS Editor 2.70 (Build 2.70.601)*

monkey0506

Quote from: monkey_05_06 on Fri 27/10/2006 09:34:56Well the current limit is 20 objects per room...so...that doesn't really make much sense. Also, why make a new module instead of just adding an optional BlockingStyle parameter to control whether the functions block?

Quote from: Lazarus on Tue 07/11/2006 09:30:07This module will be the final version unless there is any problems.

The FadingThingsNonBlocking will be a seperate module that can be used along side of this module.(They are not dependant on each other).

I never did understand the point of this. I can appreciate the existence of this module for fading characters/GUIs/objects in a non-blocking manner...but I don't understand why you were against making it into one module. It's simple enough to add a BlockingStyle parameter to control whether the function is run as blocking or not.

To demonstrate what I mean I've written a module called "Fading" which can be downloaded here. It's unnecessarily advanced with regard to the way I scripted it, but on that aspect I was playing around with AGS's inheritance system.

Basically I created a parent structure which contained all the generic information needed for each item (character/GUI/object), and then created 3 child structures (one for each type of item) which contained the item-specific data. Not really necessary to attain this effect, as I said, I was just taking a look at the inheritance capabilities.

Also I implemented 3 different ways of running the fading functions. Definitely not necessary...but maybe it will provide you some ideas of how to better group your functions.

There's no reason why you should be allowing for 50 objects per room. Seeing as the current system only allows for 20 objects per room this is a waste of memory, nothing more. And there's no reason you shouldn't be able to allot memory for every character. Granted, most people won't need 300 characters with these fading capabilities...but why not put that up to them? Properly implemented there's not really a significant amount of memory wasted by providing methods for all 300 characters.

The idea of a delayed function is nice so kudos on getting that one worked out. I didn't implement anything like that into my module because I figured most people could figure out how to delay the function themselves if they really needed it.

However, why would you have a parameter called SPEED if setting it higher actually makes the fading run slower? That's pretty illogical in my opinion. In my version, a higher speed amounts to a faster fading effect. And I'm not exactly sure how you've handled it (seeing as your speed settings work the opposite way of mine), but if the speed is negative I wait for X loops where X is the absolute value of speed (i.e., if speed is -5, I wait 5 game loops).

I've also implemented a BlockingStyle parameter to control whether the function is blocking or not.

I wasn't sure if changing the visibility settings/moving characters to a different room was really a good idea for this module, so in my version I only work with the transparency settings. It might make sense to set the transparency to 0 and the GUI/Object's Visible property to false...but I really don't like the idea of moving NPCs to another room. It would probably make more sense to just use the undocumented (i.e., unofficial, unsupported for human use, etc.) Character.on property which essentially works the same way as GUI.Visible and Object.Visible...except it's unsupported due to it's unverified nature (Chris hasn't verified that it works completely as intended, which is why it's still unsupported/undocumented).

Anyway, I didn't write "my version" of this thing to try and show you up or anything like that. If I had I'd have released my module with its own thread and everything. I wrote this more as a proof of concept that you can in fact implement both blocking and non-blocking fading within not just a single module, but actually within a single function (actually between the In/Out, Update, rep_ex, and rep_ex_always functions it comes up to 4 functions....but the user only calls one of them whether they want it blocking or not ;P). Also, let me reiterate once more, I saw this particular module as a good example of how AGS's inheritance system could be demonstrated (with a user example (as I haven't actually seen any of these); a built-in example includes all the GUIControl types (Button, Label, InvWindow, TextBox, etc.) which are inherited from the GUIControl class).

Lazarus

Module is updated to 2.29 to allow for 300 characters per room, I lowered the characters to 100 to try and stop the pausing effect when using cutscene function and to speed up the module, but as it happens with the way the update was rewritten Max values can be anything without effecting the cutscene function, as it checks if fading is needed or not.

Originally I was going to have both combined into the one module, but as I was having some problems with this one I decided it was easier to keep them seperate. They do work next to each other with no conflicts.

With the speed setup I was trying to keep it sort of constant with other settings in ags where negative values speed up animations for example.

With regards with your module and knowledge you are way more advanced than I'am.

With this module it was what I needed within my game and thought maybe other people would like, you are more than welcome to release yours if you wanted I wouldn't take to hard  :P

I have noticed in some games that I've played where a character or object is faded out that they forgot to remove them from the room, so I thought why not do it automatically for them.

As I said earlier your knowledge is way more advanced than mine, I'm still learning everything and no offence is taken, so any new ideas is always welcome.
*Currently using AGS Editor 2.70 (Build 2.70.601)*

monkey0506

Perhaps seeing as you're trying to match the way functions like Character.Animate work...you should redefine your SPEED parameter to delay. Seeing as that's what it really is. That might cause some confusion between the DELAY and TIMER parameters...

It's not my module, and as long as you properly document the way the speed parameter is intended to work then it's user error if they screw it up. It just seems a bit...counterintuitive thank you that's the word I was looking for. It seems a bit counterintuitive. But let me put it to you this way: "What can do?" (it's an inside joke you'd never get it)

Anyway, I appreciate the fact you're trying to learn. This is a good way to start. I didn't mean to be overly critical since I know that you don't know as much about AGS scripting as I do. Now that just sounds patronizing, but I've been working with AGS for well over 3 years now, and I've learned a lot. I don't mean to be patronizing or rude, or down-right flabby (whatever the hell that's supposed to mean; trust me, I don't know; I just worked an 11 hour graveyard shift and my brain may be experiencing hemorrhaging...). I was simply trying to point out some things that maybe could have been done better (for example, though it's not a requirement per se, it has become something of a standard to group module functions into a single structure; this helps prevent collisions with other module functions and whatnot as well as providing a uniform method of accessing the module's functions, etc.). Of course it's all just my two cents...and if you're going to start listening to a monkey on the internet...well... :P

Just don't get me started on some of the things I did when I first started scripting...oh the horror stories I could tell...I could make you want to rip your ears off the side of your head to make it all stop. Until you realize you're reading this on the internet. Then you would stop trying to remove your ears, and turn to your eyes instead....oh the sick demented things I envision you doing...wait...I've just been watching your avatar again haven't I? ;D

alexhans

Thanks for the Fading GUIs, I couldnt find a way to do that. 
Never let your sense of morals prevent you from doing what is right.

SinSin

#9
Hi and sorry for dragging this one up but i am stuck using this module, I am using it to fade Guis but i cant seem to get the desired effect
Problem :
               When testing the credit (triggered by a region ) The room loads up with the gui already visible when I'd like it to fade in when the region has been triggered, i have tried to change the Guis visible mode but this just makes the gui not appear at all.  any help would be greatly appreciated folks

Edit: i have now been able to make the Gui dissapear by placing

gText.Visible = False   //                            in the Global script and then i placed
gText.Visible = True   //                             In the  script for Region 1: Player walks onto region
    I can possibly finish off this mystery if I knew how to make a GUI completely transparent when visible
Currently working on a project!

monkey0506

I would imagine just change "gText.Visible = true;" to something like:

Code: ags
FadeGuiIn_NoBlock(gText, 0, 0, 0);

Lazarus

I'm sorry to largopredator who PM'd me with a problem, I've been suffering from an illness and have only just logged in.

The problem is as following:
Quote
Hi Lazarus,

Just thought I'd let you know your FadingThingsNonBlocking module isn't working too well with AGS 3.1.

I used it with 3.02 and it worked perfectly, but when I upgraded, instead of fading objects in, it shows the objects right away, just really bright. Then it comes down to regular brightness, and vice versa when it fades back out. I don't know what's going on with that.

I'm not familiar with the lastest versions, so if anyone can have a look at it I would be grateful thanks.
*Currently using AGS Editor 2.70 (Build 2.70.601)*

SMF spam blocked by CleanTalk