Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: tor.brandt on Sat 22/10/2016 10:05:12

Title: Keeping player interface active when carrying out function per default
Post by: tor.brandt on Sat 22/10/2016 10:05:12
If a function is run on e.g. a hotspot event, the whole game interface is disabled while the function is carried out.
E.g. if I have set a player.Say function, the game interface is disabled until the character has finished talking.

I seem to recall that you don't even have to script to keep the interface enabled by default, but I have looked everywhere (editor, help files, forum), and I just can't find it!
How do I make it so that the game interface is kept enabled by default, such that I have to enter into the function specifically when I want the interface to be disabled while carrying out the function?
Title: Re: Keeping game interface active when carrying out function per default
Post by: Slasher on Sat 22/10/2016 10:16:27
Game settings > When player interface is disabled, GUIs should > Display normally...
Title: Re: Keeping game interface active when carrying out function per default
Post by: tor.brandt on Sat 22/10/2016 10:23:52
Thanks, but that doesn't do it.

The cursor is still hidden, and I'm unable to click anywhere while it's carrying out the function.
What I'm after is that the player interface shouldn't be disabled in the first place.
Title: Re: Keeping player interface active when carrying out function per default
Post by: Khris on Sat 22/10/2016 10:38:48
What you're after is every action running non-blocking but still in sequence, I guess?
That's possible but complicated.

Is the GUI supposed to never get disabled at all? Is the player supposed to be able to interrupt the result of an interaction at any point? If we're mostly talking about the blocking walk over to the hotspot before the interaction takes place, I wrote the GotThere module for that: click (http://www.adventuregamestudio.co.uk/forums/index.php?topic=36383.msg477380)
Then there's Character.SayBackground.

Note however that many actions like walking, talking, animating can be non-blocking, but using several non-blocking commands in sequence will cause them to run at the same time.
If you want to tell AGS to run command A non-blocking, then command B non-blocking as soon as command A has finished, you need to actually script that. The easiest way is to use a timer, but you can only do that if you know the exact number of game frames it takes for command A to finish. Another way is to set a variable, then check stuff in repeatedly execute. An example would be sending the player off to coordinates on the screen, then repeatedly checking player.Moving and running the next non-blocking action as soon as it is false.

Anyway, you need to better describe how exactly you want the game to behave, I guess.
Title: Re: Keeping player interface active when carrying out function per default
Post by: tor.brandt on Sat 22/10/2016 11:03:18
@Khris:
Thank you for your reply, and for the link to your module!

Yes, what I'm mostly after is that the walk should be non-blocking, such that the player can interrupt the walk, in effect interrupting the entire function.

I tried using your module in the following way:
Code (ags) Select

function hWindow_Look()
{
  if (!GotThere()) GoFace(265, 135, eUp);
 
  else
  {
  player.FaceDirection(eDirectionUp);
  player.SayBackground("It's dark outside.");
  player.SayBackground("I can't see anything for the reflections in the glass.");
  }
}


In general settings I unchecked "automatically walk to hotspots in Look mode" (if I leave it checked, then the character still walks blockingly).
However, now the character doesn't walk at all, but simply carries out the "else" part right away.
What could I have done wrong?

Also, SayBackground works fine for my purpose (my purpose being that unless the hotspot is actually associated with game progress, the talking should be non-blocking) if there is only one instance of talk.
But
Code (ags) Select

player.SayBackground("It's dark outside.");
player.SayBackground("I can't see anything for the reflections in the glass.");

only displays the second line, since, as you mentioned, the non-blocking actions are carried out simultaneously.
But I'd like it to first display the first line and THEN the second.
I guess I will have to use the timer then... I'll try to sort that out.
Title: Re: Keeping player interface active when carrying out function per default
Post by: tor.brandt on Sat 22/10/2016 12:06:49
I have just imported GotThere as a separate script...
It's not supposed to be pasted into the globalscript or anything, is it?
Title: Re: Keeping player interface active when carrying out function per default
Post by: Khris on Sat 22/10/2016 15:44:15
No, importing it is correct.
You don't need walkto points for your hotspots since the coordinates are set in your interaction functions anyway.

I'm not sure what causes this, are you using other modules, or a template?
Title: Re: Keeping player interface active when carrying out function per default
Post by: monkey0506 on Sat 22/10/2016 17:00:36
Quote from: tor.brandt on Sat 22/10/2016 11:03:18Also, SayBackground works fine for my purpose... if there is only one instance of talk.
But [code] only displays the second line, since, as you mentioned, the non-blocking actions are carried out simultaneously.
But I'd like it to first display the first line and THEN the second.
I guess I will have to use the timer then... I'll try to sort that out.

The QueuedSpeech module (http://www.adventuregamestudio.co.uk/forums/index.php?topic=23806.0) should be able to do what you're looking for with the background speech.
Title: Re: Keeping player interface active when carrying out function per default
Post by: tor.brandt on Sat 22/10/2016 17:08:11
@Khris:
Ah yes, I'm using the LW_BASS template - do you know if that conflicts with your module?

@monkey0506:
Sounds great, thank you!
However, when I try to use the script, it says I need AGS ver. 3.4.0.3, but I cannot find a higher version than 3.4.0.12 anywhere?
Title: Re: Keeping player interface active when carrying out function per default
Post by: Cassiebsg on Sat 22/10/2016 18:09:19
3.4.0.3 is a lower version than .12.
Not sure how to fix that though.
Title: Re: Keeping player interface active when carrying out function per default
Post by: tor.brandt on Sat 22/10/2016 18:38:25
@Cassiebsg:
Oh, right, I read it as 3.4.0.1.2-ish :smiley:
Title: Re: Keeping player interface active when carrying out function per default
Post by: monkey0506 on Sun 23/10/2016 05:19:50
It's a bug in AGS, but as 3.4.0.3 is an alpha version it's doubtful that anyone will try to use the module with an earlier 3.4.0.x version. As you have the final release of AGS 3.4.0 (3.4.0.12), you can just delete the final digit from the line:

#ifver 3.4.0.3

(Line 3 of the module) So it should instead read:

#ifver 3.4.0

I have a mostly completed version 4.2 of the module which will use the SCRIPT_API_v340 preprocessor macro instead, which will make sure that the module has a sufficiently high AGS version without encountering this bug.
Title: Re: Keeping player interface active when carrying out function per default
Post by: tor.brandt on Sun 23/10/2016 15:54:29
@monkey0506:

Thanks, I'll try that!