Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: barefoot on Thu 24/06/2010 21:02:33

Title: SOLVED: Objects visible and invisible conditions
Post by: barefoot on Thu 24/06/2010 21:02:33
Hi

Im trying to do a condition if some objects are Visible and some are not then do certain things.

Have used this:


if (!o44sc.Visible && !o35sc.Visible && !o22sc.Visible &&o28sc.Visible && o17sc.Visible)


also for multi conditions to apply if above code returns true

Is this legal scripting?

cheers for any help

-barefoot-


UPDATE... This now works ok and answered my question:


function region2_Standing()
{
if (!o44sc.Visible && !o35sc.Visible && !o22sc.Visible &&o28sc.Visible && o17sc.Visible)
Display("The Scales drop just enough to release the door");

if (!o44sc.Visible && !o35sc.Visible && !o22sc.Visible &&o28sc.Visible && o17sc.Visible)
cindy_bones.Say("Yes,Ive done it");

if (!o44sc.Visible && !o35sc.Visible && !o22sc.Visible &&o28sc.Visible && o17sc.Visible)
object[12].Move(425, 293, 4, eBlock, eAnywhere);

if (!o44sc.Visible && !o35sc.Visible && !o22sc.Visible &&o28sc.Visible && o17sc.Visible)
object[0].Move(206, 203, 4, eBlock, eAnywhere);

if (!o44sc.Visible && !o35sc.Visible && !o22sc.Visible &&o28sc.Visible && o17sc.Visible)
cindy_bones.Walk(254, 284, eBlock);
}








Title: Re: SOLVED: Objects visible and invisible conditions
Post by: Crimson Wizard on Fri 25/06/2010 03:32:15
As I like to say: sometimes it is a good idea to ask questions, for it makes you find the answer yourself faster  ;D


Just one note - I noticed the condition is exactly the same in all 5 cases. Unless this is not a real code but sort of experiment, I'd suggest you optimize it like that:

if (!o44sc.Visible && !o35sc.Visible && !o22sc.Visible &&o28sc.Visible && o17sc.Visible)
{
   Display("The Scales drop just enough to release the door");
   cindy_bones.Say("Yes,Ive done it");
   object[12].Move(425, 293, 4, eBlock, eAnywhere);
   object[0].Move(206, 203, 4, eBlock, eAnywhere);
   cindy_bones.Walk(254, 284, eBlock);
}
Title: Re: SOLVED: Objects visible and invisible conditions
Post by: barefoot on Fri 25/06/2010 08:11:34
I will certainly use your method Crimson to cut down script size  :=

many thanks

-barefoot-