SOLVED: standon after conditions met not working

Started by barefoot, Wed 17/11/2010 11:41:48

Previous topic - Next topic

barefoot

Hi

I am trying to script so that when certain frames from an animation show a region is disabled to stop it repeating after some text is displayed. Everything else works perfectly.

The region i am using is standing as it does not seem to work with walksonto..

Code: ags

function region1_Standing()
{
  
  if(player.HasInventory(ifakeinv1)&& player.HasInventory(ifakeinv2)&& player.HasInventory(ifakeinv3))
  {
   cindy_bones.Say("Yes, done them all, let's get them gates open");
   region[1].Enabled = false;
}
 }


MaybeI'm missing something? All help appreciated.

cheers

barefooot

I May Not Be Perfect but I Have A Big Heart ..

Khris

Are you using inventory items instead of variables to keep track of the game's state...!? :o Ok, nevermind that.

Not sure what the problem seems to be, you described what you want and how you tried to implement it but not what's going wrong.
Is the region not disabled? Is the text not showing?

WalksOnto should work fine as long as the game isn't in blocking mode, i.e. if you make a character walk over/onto a region with eBlock, the event is only triggered after the character finishes walking.

barefoot

Hi Khris

These conditions below are if Animation Frames (3 animations in total) are all true if player is on the Region is what i am trying for:

(object[0].Frame == 1)
(object[3].Frame == 4)
(object[6].Frame == 3)

THEN

cindy_bones.Say("Yes, done them all, let's get them gates open now");

This is not a neccessity but would be nice to implement it for the players sake.

Cheers
Barefoot

I May Not Be Perfect but I Have A Big Heart ..

Khris

Ok, that's

Code: ags
function region1_Standing()
{
  
  if(object[0].Frame == 1 && object[3].Frame == 4 && object[6].Frame == 3)
  {
    cindy_bones.Say("Yes, done them all, let's get them gates open");
    region[1].Enabled = false;
  }
}


Still, what doesn't work? You haven't told us yet.

barefoot

#4
Hi

This is what i have for the spinning animations: (standing region not working but otherwise ok)
Code: ags

// room script file

   function ogreenbut1_Interact()
  {
  cindy_bones.Walk(229, 330, eBlock);
  cindy_bones.FaceLocation(246, 216);
  PlayAmbientSound(1, 18, 150, 250, 110);

 
odice1.SetView(39);
odice1.Animate(0, 1,  eRepeat, eNoBlock);
}

    function oredbut1_Interact()
    {
   cindy_bones.Walk(229, 330, eBlock);
   cindy_bones.FaceLocation(246, 216);
    cprof_plum.FaceCharacter(cindy_bones);
 if (object[0].Animating) {
  object[0].StopAnimating();
   StopAmbientSound (1);
 }
  {
 if (object[0].Frame>6)
  Display("");

if (object[0].Frame == 0)
{
 Display("");
}
else if (object[0].Frame == 1)
{
 Display("");
  PlaySound(17);
 cindy_bones.AddInventory(ifakeinv1);
   cindy_bones.Say("Yes, got that one!");

} 
else if (object[0].Frame == 2)
{
 Display("");
}

else if (object[0].Frame == 3)
{
 Display("");
}


else if (object[0].Frame == 4)
{
 Display("");
}


else if (object[0].Frame == 5)
{
 Display("");
}

 else if (object[0].Frame == 6)
{
  Display("");
}
}
}


     function ogreenbut2_Interact()
     {
   cindy_bones.Walk(282, 330, eBlock);
   cindy_bones.FaceLocation(281, 216);
    cprof_plum.FaceCharacter(cindy_bones);
   PlayAmbientSound(1, 18, 150, 250, 110);
odice2.SetView(50);
odice2.Animate(0, 1,  eRepeat, eNoBlock);
}

     function oredbut2_Interact()
    {
   cindy_bones.Walk(282, 330, eBlock);
   cindy_bones.FaceLocation(281, 216);
    cprof_plum.FaceCharacter(cindy_bones);
 if (object[3].Animating) {
  object[3].StopAnimating();
   StopAmbientSound (1);
 }
  {
 if (object[3].Frame>6)
  Display("");

if (object[3].Frame == 0)
{
 Display("");
}
else if (object[3].Frame == 1)
{
 Display("");

} 
else if (object[3].Frame == 2)
{
 Display("");
}

else if (object[3].Frame == 3)
{
 Display("");
}


else if (object[3].Frame == 4)
{
 Display("");
   PlaySound(17);
 cindy_bones.AddInventory(ifakeinv2);
   cindy_bones.Say("Yes, got that one!");

}


else if (object[3].Frame == 5)
{
 Display("");
}

 else if (object[3].Frame == 6)
{
  Display("");
}



        function ogreenbut3_Interact()
        {
   cindy_bones.Walk(321, 330, eBlock);
   cindy_bones.FaceLocation(314, 211);
   PlayAmbientSound(1, 18, 150, 250, 110);
odice3.SetView(51);
odice3.Animate(0, 1,  eRepeat, eNoBlock);
}


      function oredbut3_Interact()
      {
  cindy_bones.Walk(321, 330, eBlock);
   cindy_bones.FaceLocation(314, 211);
 if (object[6].Animating) {
  object[6].StopAnimating();
   StopAmbientSound (1);
 }
  {
 if (object[6].Frame>6)
  Display("");

if (object[6].Frame == 0)
{
 Display("");
}
else if (object[6].Frame == 1)
{
 Display("");

} 
else if (object[6].Frame == 2)
{
 Display("");
}

else if (object[6].Frame == 3)
{
 Display("");
   PlaySound(17);
 cindy_bones.AddInventory(ifakeinv3);
   cindy_bones.Say("Yes, got that one!");

}


else if (object[6].Frame == 4)
{
 Display("");

}


else if (object[6].Frame == 5)
{
 Display("");
}

 else if (object[6].Frame == 6)
{
  Display("");
}
}
}

      function region1_WalksOnto()
      {
}

        function region1_Standing()
       { 
     if(object[0].Frame == 1 && object[3].Frame == 4 && object[6].Frame == 3)
  {
    cindy_bones.Say("Yes, done them all, let's get them gates open");
    region[1].Enabled = false;
  }
}

        function room_Load()
        {
  
       gload.Visible = true;
        gGui4.Visible = true;
         gInv.Visible=true;
        gSymbols.Visible = true;
      gNotes.Visible = true;
        gWalk.Visible = true;
        gRun.Visible = true;
      gload.Visible = true;
        gClose.Visible = true;
     gsave.Visible = true;
 cprof_plum.FollowCharacter(cindy_bones, 30, 95);
 cindy_bones.FaceLocation(246, 216);
     cprof_plum.FaceCharacter(cindy_bones);
}



      function oswitch_Interact()
     {
  
  
   if(player.HasInventory(ifakeinv1)&& player.HasInventory(ifakeinv2)&& player.HasInventory(ifakeinv3))
  {
    
     PlaySound(19);
    object[9].Visible = true;
 object[10].Visible = false;
 
 cindy_bones.Say("Come on Professor, the gates opened");
  cprof_plum.FollowCharacter(cindy_bones, 8, 90);
 cindy_bones.Walk(583,272, eBlock);
 cindy_bones.LoseInventory(ifakeinv1);
  cindy_bones.LoseInventory(ifakeinv2);
   cindy_bones.LoseInventory(ifakeinv3);
 cindy_bones.ChangeRoom(44, 520, 397);
   


  }
  else

{
  Display("You press the button but nothing happens");
  cindy_bones.Say("Mmm, all the buttons have to be the right symbols");
  
 } 
 }

 function room_AfterFadeIn()
{
  
cprof_plum.Say("Well well,what have we here then?");

  cindy_bones.Say("Looks like one of those fun spinning machines you get at the seaside");
  cprof_plum.Say("Strange place to have one!");
  cindy_bones.Say("But Professor, this is a strange place!");
  cprof_plum.Say("Yes, of course..");
  cindy_bones.Say("I think we have to spin the reels Professor");
cprof_plum.Say("Yes, you may well be right");
    cprof_plum.FollowCharacter(cindy_bones, 70, 95);
  
}

    function oObject11_Look()
    {
Display("You see gates ahead");
}

function oObject3_Look()
{
}

    function oObject3_Interact()
   {
  cindy_bones.Say("You don't want to tilt it!!");

}

     function hHotspot1_Look()
    {
Display("You see lots of operating buttons.. Start, Stop and Open");

}

       function hHotspot2_Look()
     {
Display("You see lots of writing.. but it looks gibberish! You can't quite understand it.. You need to study it more closer!");
cprof_plum.Say("It's definately not Egyptian!");
}

       function hHotspot3_Look()
      {
Display("You see 3 Symbols on what look like spinning reels");
}

      function odice1_Look()
    {
Display("You see Symbols on what looks like spinning reels");


}

      function odice2_Look()
      {
Display("You see Symbols on what looks like spinning reels");
}

     function odice3_Look()
    {
Display("You see Symbols on what looks like spinning reels");
}

      function oswitch_Look()
    {
Display("You see a button thats says Open... Maybe that opens the gates ahead?");
}

    function oObject11_Interact()
    {
  cindy_bones.Walk(524, 205, eBlock);
cindy_bones.Say("It's locked!");
cprof_plum.Say("We need to get it open then!");
}

     function hHotspot4_Look()
     {
Display("Uky when he ruled the lands");
}

     function region1_WalksOff()
    {
  
 }

     function region2_Standing()
    {
  }



The walksonto region does not display text :


Code: ags

      function region1_Standing()
    {
     if(object[0].Frame == 1 && object[3].Frame == 4 && object[6].Frame == 3)
  {
    cindy_bones.Say("Yes, done them all, let's get them gates open");
    region[1].Enabled = false;
  }
}


?????

Barefoot

I May Not Be Perfect but I Have A Big Heart ..

monkey0506

Just for the record, I refuse to help anyone who posts an entire room script file without any recognizable form of indentation style.

You're also still not giving any indication what actual output you are getting. You're using animations and checking the object frames..but are the frames ever getting the values you expect? Urgh..

barefoot

Quote from: monkey_05_06 on Wed 17/11/2010 17:49:46
Just for the record, I refuse to help anyone who posts an entire room script file without any recognizable form of indentation style.

You're also still not giving any indication what actual output you are getting. You're using animations and checking the object frames..but are the frames ever getting the values you expect? Urgh..

Monkey, script was only an example copy.. the problem is the end bit..

point taken about indentation, suppose it is a bit long to take in. cheers

Barfoot
I May Not Be Perfect but I Have A Big Heart ..

monkey0506

#7
I don't know what an "example copy" of code is, unless you're trying to say that you typed all of that from scratch instead of copy/pasting it from your game.

Let me say this again though..

You're also still not giving any indication what actual output you ARE getting.



P.S. Here's my rationale for the formatting:

Quote from: Khris on Wed 17/11/2010 11:52:20Not sure what the problem seems to be, you described what you want and how you tried to implement it but not what's going wrong.

Quote from: Khris on Wed 17/11/2010 13:23:05Still, what doesn't work? You haven't told us yet.

Quote from: monkey_05_06 on Wed 17/11/2010 17:49:46You're also still not giving any indication what actual output you are getting.

barefoot

Hi

Im not getting any output from the following:

Code: ags

      function region1_Standing()
     {
     if(object[0].Frame == 1 && object[3].Frame == 4 && object[6].Frame == 3)
    {
    cindy_bones.Say("Yes, done them all, let's get them gates open");
    region[1].Enabled = false;
    }
    }



I have used Walkoff instead...it works like above... It was just an 'indication' to player to interact with Gate Button... so function works.. I was going to use standing but it failed to work.. it gave no output..

cheers

barefoot
I May Not Be Perfect but I Have A Big Heart ..

monkey0506

What output ***ARE*** you getting?!

You say everything else is working but you're not telling us what that means. Is the region1_Standing function ever getting called?

Wersus

#10
Well, if the say command is not getting executed, it's quite easy to come to the conclusion that either your if statement is stopping the flow (try taking it off) or the whole function is never getting called. The latter one could be caused by several reasons. For example the function is not defined in the room's settings, the region is disabled somewhere else before it has the opportunity to run that function, the region is not painted correctly etc...


EDIT: So are you saying that with 'walks off' that function works? Then the only thing I can think of is that there's something wrong with the region's event list.

barefoot

Hi

Ok.. here's the scenerio..  you come to a spinning machine with 3 reels. Every time you stop a reel at the right symbol you hear a sound and the char says he has that one correct... When all 3 reels show the correct symbol the char should say that all the reels are done and that you now need to open the gate via a buton.. 

its all ok untill after the last reel shows the correct symbol.. but then nothing... the char does not say that all reels are done and about opening the gates...

This event is activated by a Region... If i nominate walksoff then it works ok, but does not work by selecting standing...

This is the code i have at the moment (works):

Code: ags

      function region1_WalksOff()
      {
      if(object[0].Frame == 1 && object[3].Frame == 4 && object[6].Frame == 3)
      cindy_bones.Say("Yes, done them all, let's get them gates open");
    region[1].Enabled = false;
    }


The animation frames seem to be correct.. Im sure there is something i am missing. The region is not used for anything else. It only checks the condiion of frames and runs events if they are correct.

barefoot

I May Not Be Perfect but I Have A Big Heart ..

Khris

What you want is after the third reel is in the correct position, something's supposed to happen, right?
You don't need a region for this.

Code: ags
bool All() {
  if(object[0].Frame == 1 && object[3].Frame == 4 && object[6].Frame == 3)
    cindy_bones.Say("Yes, done them all, let's get them gates open");
    return true;
  }
}

function ogreenbut1_Interact() {

  cindy_bones.Walk(229, 330, eBlock);
  cindy_bones.FaceLocation(246, 216);
  PlayAmbientSound(1, 18, 150, 250, 110);
  odice1.SetView(39);
  odice1.Animate(0, 1, eRepeat, eNoBlock);
}

function oredbut1_Interact() {

  cindy_bones.Walk(229, 330, eBlock);
  cindy_bones.FaceLocation(246, 216);
  cprof_plum.FaceCharacter(cindy_bones);

  if (object[0].Animating) {
    object[0].StopAnimating();
    StopAmbientSound (1);

    if (object[0].Frame == 1) {
      PlaySound(17);
      if (!All()) cindy_bones.Say("Yes, got that one!");
    } 
  }
}


As you can see, the last line calls the function further up, All(). If the player just stopped the third reel at the correct position, cindy_bones says the sentence about the gate and All() returns/equals true.
Thus if not all three reels are in place yet, instead she says "Yes, got that one!"

I'm really curious about all those else ifs doing absolutely nothing, where did you get that from?

Please rewrite the other two oredbutx and ogreenbutx functions to match mine.

Regarding the original problem, is the function's named ("region1_Standing") entered correctly in the text field in the region's event pane?

barefoot

#13
Hi Khris

thanks for your help. I assume the bool goes here:

Code: ags

    // room script file

     bool All() {
    if(object[0].Frame == 1 && object[3].Frame == 4 && object[6].Frame == 3)
    cindy_bones.Say("Yes, done them all, let's get them gates open");
    return true;
    }

   function ogreenbut1_Interact() {

  cindy_bones.Walk(229, 330, eBlock);
  cindy_bones.FaceLocation(246, 216);
  PlayAmbientSound(1, 18, 150, 250, 110);
  odice1.SetView(39);
  odice1.Animate(0, 1, eRepeat, eNoBlock);
  }


cheers, i will try it out.

baarefoot
I May Not Be Perfect but I Have A Big Heart ..

Matti

You should place it in the room script as objects are room dependant.

barefoot

Quote from: Matti on Thu 18/11/2010 18:33:55
You should place it in the room script as objects are room dependant.

SNAP

Cheers Matti

barefoot
I May Not Be Perfect but I Have A Big Heart ..

barefoot

#16
Hi

many many thanks Khris. With a bit of a tweek its there  :=

thanks again

Now i know about Boolean uses.

I am using the script with 'else' uses in another game, but point taken.

cheers

barefoot

I May Not Be Perfect but I Have A Big Heart ..

SMF spam blocked by CleanTalk