Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: sentient on Thu 20/05/2004 21:57:39

Title: Inventory problem
Post by: sentient on Thu 20/05/2004 21:57:39
Hello. I'm still stuck at the moment. I can't see any option in the inventory for checking if you have an item or not. I have a dialog I have set up with gets to a point and runs the run-script 1 command. In this script I want to check if you are carrying a certain item and to check against 4 variables i will want to have to check have been trigered. eg 1=triggered 0=not triggered. I can maybe set a flag for when you first pick up the object to do it, but that seems silly in a package designed for adventures. Is there a way to check if you are carrying a specific inv item or not?
Title: Re: Inventory problem
Post by: Scorpiorus on Thu 20/05/2004 22:13:40
Check out Text script global variables in the manual.

character[CHARID].inv[ x ]

So, you can have:

if (character[GetPlayerCharacter()].inv[5] > 0) {

Ã,  //run code only if the player has item (one or more) number 5

}
Title: Re: Inventory problem
Post by: sentient on Fri 21/05/2004 18:57:30
I really can't get my head around this scripting lark it is completley different from what I've done before. What is wrong with this ?


// main global script file
function dialog_request (int locationselect){
if (locationselect == 1)
if (character[GetPlayerCharacter()].inv[1] > 0);
SetPlayerCharacter(HANSON)}
Title: Re: Inventory problem
Post by: Scorpiorus on Fri 21/05/2004 19:08:09
Just two little corrections ;)

// main global script file
function dialog_request (int locationselect){
if (locationselect == 1)
if (character[GetPlayerCharacter()].inv[1] > 0) //no need for ';' here
SetPlayerCharacter(HANSON);
}
Title: Re: Inventory problem
Post by: sentient on Fri 21/05/2004 20:44:40
I've tried it as you said, but it still won't run. It says :
error: line3 expected ;

I've put a semi colon on the end of line 3 then it comes up with another error
Title: Re: Inventory problem
Post by: Scorpiorus on Fri 21/05/2004 21:08:41
Hmm, strange...

Could you copy&paste here what you have there now?
Title: Re: Inventory problem
Post by: sentient on Fri 21/05/2004 21:21:22
// main global script file
function dialog_request (int locationselect){
if (locationselect == 1)
if (character[GetPlayerCharacter()].inv[5] > 0)
SetPlayerCharacter(HANSON)};

that is what I have at the moment
Title: Re: Inventory problem
Post by: sentient on Fri 21/05/2004 21:23:47
This is right at the top of the global script. Line 3 is the if (locationselect ==1..... line.
Title: Re: Inventory problem
Post by: Scorpiorus on Fri 21/05/2004 21:56:44
Swop them ;)
...
SetPlayerCharacter(HANSON); }
Title: Re: Inventory problem
Post by: sentient on Fri 21/05/2004 23:24:10
That worked. I now can use these scripts to go to the room I want. I'm not sure how I can limit the initial options now. I only want say 1 option to be available in the dialogue until I have talked to a character for instance. Then the new location becomes clear and is added into the options. How would I do this? I can untick the show option to stop the options being shown. But where would I use the show command?
Title: Re: Inventory problem
Post by: Scorpiorus on Fri 21/05/2004 23:30:12
Check out a SetDialogOption (int topic, int option, int new_state) function in the manual to handle dialog options from within the text script.

Also, take a look into Conversations section where you'll find information about how to manipulate the options with the dialog script (see: option-off X, option-off-forever X, option-on X).
Title: Re: Inventory problem
Post by: sentient on Sat 22/05/2004 13:41:37
Every time I try to use this manual I have I wonder if it is the right one. On page 31, the scripting tutorial1 and 2 simply say wibble and wobble??!! Is this in all the manuals? I downloaded the 2.4 manual off the website and printed it off, all 133 pages.  I hope this is the right one.