How to open inventory by asking a character to open it instead of GUI interface?

Started by xboxown, Sat 04/02/2023 04:38:13

Previous topic - Next topic

xboxown

   Hey guys,


  My game is about robots and robot world, the main hero does not have hands. He need to have another robot to join it which have hands, that robot when I talk to it in a dialog and pick a choice to show me it's inventory that is when the inventory pops up. Right now as default the player can have the inventory pop up under the menu choices above . I want to remove that completely and only have the player display the inventory by talking to the robot that joins you and ask it to show the inventory under the dialog script. How do I do that?

  The default template have multiple functions and loops, etc and calling other functions to open inventory and all stored under global scripts. Obviously I cannot call that function from dialog box editor. I don't know what to do. Thanks.

Cassiebsg

You can call anything from dialogues, no problem.
In dialogue you can add any AGS code, all you need to do is ident with at least a space the line(s) of code.

But you'll need to change the template defaults on how the inventory is called and accessed.

For that you need to provide us more info, like which template (if any) are you using on your game.

Edit:
Also how do you want to "see" your inventory? Will the new robot tell/list what he's carrying, will you want a GUI to open that will show/display the inventory window? Do you want the robot to show one item at a time?

If it's a GUI, then create your GUI first, test it, then just link to be opened when you talk to your robot. Close the dialog, and reopen the robot dialogue when you close the GUI.
There are those who believe that life here began out there...

xboxown

When I started my project I used the sierra template. The default sierra template that comes with AGS. I want to remove the icon when I hover on the top of the screen where to opens the inventory and have that execute only when you talk to that robot. Everything else I leave it as default. In my game I am not going to change the default GUI for the game from the sierra template as this is advanced features that I am not yet ready to do any changes. I am still in the beginner stages and using video tutorials to do modification in the game. So this project I am leave the template untouched. The only thing I want to change in the default template is remove the option to open the inventory and only have that opened through talking to that robot who will join the team.

In terms of how it shows the items...I am not changing the default inventory system..all I am changing the way to access it. Instead of accessing it through click a button when I move the mouse all the way to the top to show the UI interface, it is accessed only by talking to the robot and select in the dialog choice Show inventory. That is the only changes I want to do in the inventory system and GUI.

xboxown

https://imgur.com/TxSgPT9



This is the default interface template when I started the project and see that bag icon...I want that removed and I want the function to open the interface moved to the dialog box. I attempted to copy the code that opens the interface and I get an error that the function does not exist. Does that mean I have to copy the entire codes and including the functions and move it to the dialog box in order for it work?

This is the function show_inventory_window(); that displays the inventory system and when I copy and paste it, I get an error.

Cassiebsg

Okay, lets approach this by steps.

1) Open the top GUI (gIconbar), select the inventory button and delete it.

2) You need to put your code, _after_ the function show_inventory_window(). When placed in Global Script.

3) You probably need to import the function to use it in the dialogues (I'm pretty sure about it actually, which is why AGS can't find it). So... in order to do this open GlobalScript Header, and type in the following:

Code: ags
import function show_inventory_window();

4) Now you can call the function in your dialogue:
Code: ags
  show_inventory_window();

5) Hope this helps. :)

PS - Remember to adapt the close GUI code to what you want.
There are those who believe that life here began out there...

xboxown

This is the import as you said it is placed in the globalscript under edit script


When compiled this is the error message I am getting

Crimson Wizard

You need to put the "import" line in the script's header; only then it will be "seen" by other scripts.

Related article in the manual:
https://adventuregamestudio.github.io/ags-manual/ImportingFunctionsAndVariables.html

xboxown

IT COMPILED WITHOUT ERROR!!! IT WORKS HAHAHAHAHAH!!! THANK YOU!!!

SMF spam blocked by CleanTalk