Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Rub on Tue 05/12/2023 17:13:27

Title: Inspect item and High Score in Text Parser game to look like Space Quest 3
Post by: Rub on Tue 05/12/2023 17:13:27
Hello guys!

Thank you in advance for any help.

I'd like to include code for  two things in order to advance development of my free game.

It is a text parser. So far I just need two things added to complete the main structure.

One is a high score and the ability to inspect items. Both in the way the SQ3  does it.

I've had no luck trying to use the manual for this. My Script is set to 3.2.1 compatibility since I've been using a template from an 
older version of AGS the whole time. So perhaps this has also caused some issues for me.

I also attached a GIF of the SQ3 inventory interaction I'm  speaking of.

Again, any direction at  all even so I can figure it out on  my own is appreciated. If in the end I truly understand the code involved
in this, then that's even better.

Any advice welcomed!

Cheers!

(https://pasteboard.co/hGtLBjVTF1Io.gif)

https://pasteboard.co/hGtLBjVTF1Io.gif[/img]](https://pasteboard.co/hGtLBjVTF1Io.gif) (http://[img)
Title: Re: Inspect item and High Score in Text Parser game to look like Space Quest 3
Post by: Khris on Tue 05/12/2023 20:33:35
Here's the gif:
(https://gcdnb.pbrd.co/images/hGtLBjVTF1Io.gif)

The easiest way to have a score in the game is to use GiveScore(int score) (https://adventuregamestudio.github.io/ags-manual/Globalfunctions_General.html#givescore).
You can show this score by putting text on a label that contains a token found here (https://adventuregamestudio.github.io/ags-manual/EditorGUI.html?highlight=score&case_sensitive=0#interface-text)

As for the inventory, you can use a standard InvWindow GUIControl. Instead of graphical representations, simply draw the text on the sprite. (You can also do this dynamically with scripting.)
Then you need to turn on custom inv click handling in General settings and implement an eMouseLeftInv block inside the GlobalScript's on_mouse_click that displays a second GUI. You can use a custom property for the sprite slot and the description, and display both on the GUI using a button's image and a label.
Title: Re: Inspect item and High Score in Text Parser game to look like Space Quest 3
Post by: Rub on Tue 05/12/2023 20:36:59
Thank you Khris
Title: Re: Inspect item and High Score in Text Parser game to look like Space Quest 3
Post by: Rub on Tue 05/12/2023 23:09:13
So I actually did more digging.

else if (Parser.Said("look itemname") && (player.InventoryQuantity[iItem.ID])) {
    ShowInvCloseup(number of the sprite for closeup,  "Add extra comment here.");
  }
This  is a global command. Exactly what I was looking to do. Perfect.

To add the score.

I figured out how to add score after looking at something.

else if (Said("look [spoiler]boar's head[/spoiler]")) {
    Display("Its a [spoiler]wild Boar's head mounted on the wall[/spoiler], it looks...well preserved.");
    GiveScore(5);
But I don't know how to stop it from giving score. Like a exploit. Any ideas welcomed!

Cheers

Title: Re: Inspect item and High Score in Text Parser game to look like Space Quest 3
Post by: Khris on Tue 05/12/2023 23:47:36
Use Game.DoOnceOnly (https://adventuregamestudio.github.io/ags-manual/Game.html#gamedoonceonly):
  if (Game.DoOnceOnly("look at gopher repellent")) GiveScore(5);
You just need to pass a unique string for each situation.

Is ShowInvCloseup part of the template?
Title: Re: Inspect item and High Score in Text Parser game to look like Space Quest 3
Post by: Rub on Wed 06/12/2023 09:15:43
Hi Khris

Yes the script in the global section of the template has this also

#sectionstart ShowInvCloseup
function ShowInvCloseup(int sprite, String description)
{
  gCloseup.BackgroundGraphic=sprite; //This changes the closeup sprite.
  gCloseup.Visible= true; //This turns the GUI on.
  Wait(1); //This just fixes an odd bug.
  DisplayAtY(130, description); //This is the closeup text description, displayed right below the closeup image.
  gCloseup.Visible=false; //And finally the closeup GUI turns off again.
  }

So together with the previous script I wrote there, it makes the ability to bring up a detailed view possible.
This is all from the template I have not written anything myself nor tried to implement it yet.