Inspect item and High Score in Text Parser game to look like Space Quest 3

Started by Rub, Tue 05/12/2023 17:13:27

Previous topic - Next topic

Rub

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[/img]]

Khris

Here's the gif:


The easiest way to have a score in the game is to use GiveScore(int score).
You can show this score by putting text on a label that contains a token found here

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.


Rub

So I actually did more digging.

Code: ags
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.

Code: ags
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


Khris

Use Game.DoOnceOnly:
Code: ags
  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?

Rub

Hi Khris

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

Code: ags
#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.

SMF spam blocked by CleanTalk