KeyboardMovement region activate bool fails

Started by steptoe, Mon 26/12/2011 17:03:58

Previous topic - Next topic

steptoe

Hi

doing a few tests i have come across this problem.

I have a region activated by a bool which works fine.

However, I notice that it does not work with KeyboardMovement Pressing.

KeyboardMovement Tapping is fine and region events happen, but KeyboardMovement Pressing does not cause anything to happen.

All help appreciated

steptoe




Khris

Did you by any chance test this using a single Display command?
Because if you hold down one of the cursor keys, the Display box is removed again immediately so you probably just missed it.

In other words, on my end, the event is triggered just fine.

steptoe

#2
Khris

Edit: you are right about arrows skipping text. I did two Says and it ran second Say but skipped first. So, what can one do?  Unless I use Keyboard Movement None?

When the region is enabled the character Says something which depends on conditions.

If Say this
else Say this

Each condition has 1 Say only. Should I split Say into 2 parts?

as I said, it works with Keyboard Movement Tapping but not by Keyboard Movement Pressing.

Although game is mouse orientated people may well use the arrows.

Not sure where to take this from here.

cheers





monkey0506

steptoe, did it occur to you to try posting your code?

Because Khris already told you that this works fine if your code is properly implemented.

steptoe

#4
Hi Monkey

This works if using mouse walkto and keyboard tapping but not pressing as text flashes by. I tried putting else say before return, no avail.

EDIT: It does seem to work better if I put a small Wait in.

No doubt you will see if any errors.

Code: ags

function region3_WalksOnto()
{
  if (!region_activated) return;   // if not region_activated, exit the function

  
{
  if (region_activated==true &&cFrankj.HasInventory(iputty) && cFrankj.HasInventory(idetonator) && cFrankj.View==3)
  
  {
    
    RestoreWalkableArea(2);
   cFrankj.FaceLocation(115, 160);
   cFrankj.Say("Now to find those Nazis basterds!");
   cFrankj.Walk(120, 195, eBlock);
   object[6].Visible=false;
   object[2].Visible=true; 
   region[3].Enabled=false;
  
 }
  else  cFrankj.Say("I'm sure I have useful things around that will help me defeat those Nazis basterds!!");
  cFrankj.Say("I can't face them unless I'm well prepared!");

}
}


cheers

steptoe


Khris

You can change whether keypresses or mouse buttons can be used to skip text; to set it to mouse only, put SetSkipSpeech(4); in game_start.

In your code, you have a { that's superfluous, and you're testing if region_activated is true after this is already established. Neither of those is breaking your code, but you should really try to get your code straight anyway.
Near the end, the second Say command is always executed, regardless of the outcome of the condition, because you didn't encapsulate both in { and }. Not sure if how I put is what you want, but it definitely didn't make sense the way you put it.

Code: ags
function region3_WalksOnto()
{
  if (!region_activated) return;   // if not region_activated, exit the function

  if (cFrankj.HasInventory(iputty) && cFrankj.HasInventory(idetonator) && cFrankj.View == 3)
  {    
    RestoreWalkableArea(2);
    cFrankj.FaceLocation(115, 160);
    cFrankj.Say("Now to find those Nazis basterds!");
    cFrankj.Walk(120, 195, eBlock);
    object[6].Visible=false;
    object[2].Visible=true; 
    region[3].Enabled=false;
  }
  else
  {
    cFrankj.Say("I'm sure I have useful things around that will help me defeat those Nazis basterds!!");
    cFrankj.Say("I can't face them unless I'm well prepared!");
  }
}


Look at the drastic increase in readability simply due to proper indentation. Also, since this is in the room script, you don't have to use the object[] array, you can reference objects by their actual name (just like you did with the inventory items).

steptoe


SMF spam blocked by CleanTalk