Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Messages - tor.brandt

#81
@Khris:

Thanks for the reply!
Hmm, yeah that amount of work seems a bit out of proportion :smiley:

It seems odd though, to have a pause game function in AGS (being an engine built specifically for point and click adventure games) that cannot override blocking scripts. I mean, in a classical point and click game, if the game cannot be paused e.g. while a character is speaking, then why have the pause function at all?
The only time I use the pause function when playing the classical games is when I'm interrupted (e.g. when someone speaks to me IRL), such that I'm not able to keep up with what is happening in the game. Because, I mean, whenever there is not a character speaking, a cutscene running, etc., then a classical point and click game can easily be left alone without pausing, because nothing will happen until the player resumes the game.

On second thought, there are of course such things as timers, and I know people are making all kinds of different types of games in AGS, so it's probably just me that's only used to one specific type of game.
However, it would definitely be nice if an overriding pause function was added to the next version of AGS :smiley:
#82
I'd like to make a PauseGame() function similar to the classical LucasArts games, such that I can pause anywhere in the game, including while characters are speaking, animations are run, cutscenes are running, etc. etc.

I have made an on_key_press PauseGame() function, and it's working fine, but I just accidentally discovered that (of course) it doesn't go through if a blocking script is running (e.g. if a character is speaking non-background-ingly).
I tried putting an IsKeyPressed() function in repeatedly_execute_always, but for that to work, of course, you would have to press and release the key pretty damn fast :smiley:

Is there a feasible way to make an OnKeyPress() function that somehow overrides the currently running blocking script (inherently, no more than one blocking script can run at any one time, right?)?
It would of course also have to somehow store that currently running blocking script, including the current "position" within that script, such that it could resume it at UnPauseGame().
#83
Quote from: Khris on Tue 08/11/2016 09:42:27
Do you have a run-script in any of your dialog scripts? That's the only thing I can imagine would cause that, other than some weird bug.

That's exactly the thing, so far I've been working solely on the UI for my game, and so I haven't even gotten to any dialog scripts yet, which is why I couldn't figure out what I could have possibly done to make the line appear.
Maybe by mistake I could have switched some "run script" on somewhere dialog-related, I'll have to look for that, thanks!
#84
Thanks!

So it's actually an AGS bug, kind of?
#85
For some reason AGS keeps adding the line
Code: ags
function dialog_request(int param) { }

at the bottom of my global script.

I take it that I add it accidentally myself, but I cannot figure out what I keep doing to add the line to the script.
Does anyone have suggestions for what could (semi-)automatically add the line?
#86
Ah, I see.
Thank you for the elaboration!

And thank you for drawing attention to the region function - I wasn't aware that you could do that,
and that seems like a really simple and great way to keep order.
Actually, I think I will simply go with that method instead of splitting into multiple scripts then :smiley:
#87
@Gurok:

Thanks for your reply!

Alas, I do not really understand what you've written.
I do not yet understand what "void", "struct", and "import static void" mean.
Besides I've not yet quite cracked the nut regarding pointers (although I'm slowly beginning to use them in my scripting), and I can't really grasp the syntax of your stubs...
So much still to learn!

If you want to take the time to tell me, I'd really like to know more about how your example works, though :grin:
#88
I know there are some types of code that (at least per default) need to be in the global script, such as inventory item functions and GUI functions.

I get confused very easily, and therefore it would be of great help for me, if it was possible to put all types of code in other scripts (e.g. to make a script solely for inventory item functions, one solely for GUI functions, etc. etc.).

Therefore I'd like to hear if it should after all be possible in some way to work around the limitations of AGS, and put all types of code in scripts that are not the global script?

Thanks!
#89
@Cassiebsg:
Thanks for the reply!
Yeah, I'm really after a way to make it general, so I won't have to put those lines into every single function :smiley:

I actually managed to get it to work with room functions (i.e. non-GUI/inv item functions):
Code: ags
function on_mouse_click(MouseButton button)
{
  if (IsGamePaused() == 1)
  {
  }
  
  else if (button == eMouseLeft)
  {
   Room.ProcessClick(mouse.x, mouse.y, mouse.Mode);
   mouse.Mode = eModeWalk;
   lblActionText.Text = "";
  }
  
  else if (button == eMouseLeftInv)
  {
    InventoryItem* item = InventoryItem.GetAtScreenXY(mouse.x, mouse.y);
    item.RunInteraction(mouse.Mode);
    mouse.Mode = eModeWalk;
    lblActionText.Text = "";
  }
}


I'm not sure if this solution will cause problems in some cases I haven't yet thought of, though...?

As you see, I also attempted doing something similar for inventory items (I set "override built-in inventory..." to True in General settings to make it work), and it actually works - but now, since the built-in handling of inv items is disabled, when I left click on an inv item, it only carries out the "use inv item alone" function, so that I'm not able to use an inv item with something else.
#90
I'd like to make it so that the mouse cursor mode and my action label text are reset after carrying out a function.

By "after carrying out a function" I mean e.g. if I have selected a "look at" mode and then clicked on e.g. a hotspot, e.g. making the player say something (that's the function), then the resetting should occur after the player has finished talking (i.e. after the entire function has been carried out).

And by "reset" I mean that the cursor mode should switch back to "walk to", which is my default mode, and the action label text should be set to "".
I know how to use mouse.Mode == eMode..., and .Text = "", but what I don't know is what these commands should be functions of.

I tried making them functions of on_mouse_click(), but that seemed to make a mess somehow - and besides I'm not sure if the resetting would actually occur before or after the additional functions of the given click.

I use five modes beside "walk to", namely "look at", "use", "pick up", "talk to", and "use inv", and the resetting should occur after carrying out functions of them all. Also, if any mode beside "walk to" is selected, and I click on eLocationNothing (except for inv items!), then the resetting should occur as well.
#91
@Arlann:

I see you replied almost at the same time as I made my last edit, so you probably didn't see that, but thanks.

I actually tried something similar to your suggestions, but as it turned out, it was simply because I had forgotten to assign the UnlockView() command to both mouse buttons.
Anyway, your suggestions really helped me out :smiley:
#92
@ Arlann:

I just noticed, however, that when the character hos spoken (i.e. have been animated with his speech view), he does not return to the idle view again.
I have to make him walk before he switches back again.
Have you experienced something like that?

edit: Whoops, sorry, I was a little too fast there.
It was just because I had only put the UnlockView() command as a function of left mouse buttion click, and therefore it did not unlock when clicking right button (performing look at).
#93
Thanks for the replies!

@Danvzare:
I actually tried using a negative number for the delay int, but yeah, that just weirdly made the character switch to the animated (i.e. walking) normal view like Arlann says.

@Snarky:
Thanks for the individual frame tip, that works perfectly!
And yeah, it might be a better solution to make a repeatedly_execute() Character.Animate() function instead, thanks.

@Arlann:
Thanks for the code bit.
I actually tried using that right now, and strangely there is still a delay from the character stops moving before he starts animating, sometimes more than a second.
I don't understand why...

edit: No, now I found out it was because I had forgotten an old code bit that counteracted your bit. Now it works perfectly :smiley:
#95
In my game I want a character to become shaky after a certain event.
For this purpose I've used
Code: ags
player.AnimationSpeed = 0;
player.SetIdleView(7, 0);


where view 7 consists of two frames, such that the character 'jumps' up and down continuously whenever he is not walking.

However, I have two problems here:
1. Even with delay 0 in the idle view, there is still a bit of a delay after the character stops walking before he switches to the idle view. Is it possible to make him switch to the idle view faster in any way?
2. Even with animation speed 0, the shaking is not fast enough. Is is possible to make the character animate faster in any way?

On closer inspection, it seems that only the normal (i.e. walking) view is affected by AnimationSpeed. If that's correct, how do I change the animation speed of other views?
#96
Thanks for your code, Khris!
I modified it in the following way, and even though it's probably not the most elegant piece of scripting, it does the job:

Code: ags

function repeatedly_execute()
{
  // Inventory GUI: 
  // - make visible if mouse "touches" trigger zone
  // - make invisible if mouse leaves inventory GUI
  if (!gInventoryBar.Visible && mouse.y <= INVENTORY_POPUP_POSITION)
  {
    gInventoryBar.Visible = true;
  }
	
  if (gInventoryBar.Visible && mouse.y > gInventoryBar.Height)
  {
    gInventoryBar.Visible = false;
  }
	
// Action Label Text	// We always display the name of what is under the mouse, except when an inventory item is active:
// If the player has an inventory item selected and hovers over the same inventory item, 
// we display nothing to indicate that an item can not be used on itself.
 // If the player has an inventory item selected and hovers over a hotspot, an object, a character, or another inventory item,
// we display: "Use [name of active inventory item] with [name of that which the mouse is over]".

  if (player.ActiveInventory == null)
  {
    lblActionText.Text = Game.GetLocationName(mouse.x, mouse.y);
  }
  
  else
  {
    if (GetLocationType(mouse.x, mouse.y) == eLocationHotspot)
    {
      lblActionText.Text = String.Format("Use %s with %s", player.ActiveInventory.Name, Game.GetLocationName(mouse.x, mouse.y));
    }
    
    else if (GetLocationType(mouse.x, mouse.y) == eLocationObject)
    {
      lblActionText.Text = String.Format("Use %s with %s", player.ActiveInventory.Name, Game.GetLocationName(mouse.x, mouse.y));
    }
    
    else if (GetLocationType(mouse.x, mouse.y) == eLocationCharacter)
    {
      lblActionText.Text = String.Format("Use %s with %s", player.ActiveInventory.Name, Game.GetLocationName(mouse.x, mouse.y));
    }
    
    else if (GetLocationType(mouse.x, mouse.y) == eLocationNothing)
    {
      String action = Game.GetLocationName(mouse.x, mouse.y);
      InventoryItem *i = InventoryItem.GetAtScreenXY(mouse.x, mouse.y);
      if (i != null) action = i.Name;
      
      if (player.ActiveInventory != null)
      {
        if (i == null || i == player.ActiveInventory) action = "";
        if (action.Length > 0)
        {
          action = String.Format("Use %s with %s", player.ActiveInventory.Name, action);
          lblActionText.Text = action;
        }
        
        else 
        {
          lblActionText.Text = "";
        }
      }
    }
  }
}


Now it's working perfectly! :smiley:
#97
This is my current modified version of the repeatedly_execute function of the LW_BASS TwoClickHandler module:

Code: ags

function repeatedly_execute()
{
  // Inventory GUI: 
  // - make visible if mouse "touches" trigger zone
  // - make invisible if mouse leaves inventory GUI
  if (!gInventoryBar.Visible && mouse.y <= INVENTORY_POPUP_POSITION)
  {
    gInventoryBar.Visible = true;
  }
	
  if (gInventoryBar.Visible && mouse.y > gInventoryBar.Height)
  {
    gInventoryBar.Visible = false;
  }
	
  // Action Text
  // We always display the name of what is under the mouse, with one exception:
  // IF the player has an inventory item selected and hovers over the same inventory item, 
  // we display nothing to indicate that an item can not be used on itself
  if (player.ActiveInventory == null)
  {
    lblActionText.Text = Game.GetLocationName(mouse.x, mouse.y);
  }
  else
  {
    InventoryItem *i = InventoryItem.GetAtScreenXY(mouse.x, mouse.y);
    if (i != null && (i.ID == player.ActiveInventory.ID))
    {
      lblActionText.Text = "";
    }

///This is the part I need help with:
    else
    {
      if (GetLocationType(mouse.x, mouse.y) == eLocationNothing)
      {
        lblActionText.Text = String.Format("Use %s with %s", player.ActiveInventory.Name, Game.GetLocationName(mouse.x, mouse.y));
      }
      
      else
      {
        lblActionText.Text = String.Format("Use %s with %s", player.ActiveInventory.Name, Game.GetLocationName(mouse.x, mouse.y));
      }
    }
  }
}


As you see, I've made it so that if an inventory item is active (i.e. is the current cursor), the action label will display "Use [active inv. item] with [that which the cursor is currently over]".

I'd like to make it so that even if an inventory item is active, if the cursor is not over an object, a hotspot, or an inventory item, the action label displays nothing at all.
I tried using the GetLocationType function, and then script that if an inventory item is active, and the current location type is eLocationNothing, the action label displays nothing. This works fine, except that since inventory items is of the location type eLocationNothing, the action label displays nothing when an inventory item is active and the cursor is over another inventory item.

Is there a way around this?
(It seems strange to me that there is no separate location type called "eLocationInvItem" or something, but perhaps there is a good reason for including inv. items in the eLocationNothing type?)

To recap: I'd like my action label to display "Use [active inv. item] with [the name of that which the cursor is over]" when the cursor is over an object, hotspot, another inventory item, and possibly also characters (in my current game there are not yet any characters beside the player character, but it'd be nice to know how to include these in the function for future purposes).

PS. In the code I've marked the part I need help with, but I've included the whole repeatedly_execute function just in case...
#98
Oooh I see, I wasn't aware that I needed the String.Format part.

And thanks for the player.ActiveInventory.Name correction, now it's working perfectly :smiley:
#99
I'm trying to modify the LW_BASS module, such that when an inventory item is active, the action text will display "Use [active inventory item] with [the hotspot/object/etc. which the cursor is currently over]".

What is wrong with this line:
Code: ags
lblActionText.Text = ("Use %s with %s", player.ActiveInventory, Game.GetLocationName(mouse.x, mouse.y));
?

AGS says there is a parse error.
Now, there may be other errors, and I'm not even sure if I'm using player.ActiveInventory and/or Game.GetLocationsName() correctly here, but I just can't see the parse error.
SMF spam blocked by CleanTalk