Checking inventory and removing it in dialog script (SOLVED)

Started by Wayne Adams, Sun 01/03/2009 03:47:28

Previous topic - Next topic

Wayne Adams

Ok, so i may have missed it somewhere but i want to do inventory work in dialog scripts..

add-inv works just fine..

however if i try to check for inventory:
if (player.HasInventory(1)){
option-on 6
}
it gives me errors..

I've also searched for examples on the "run-script" command to remove inventory from player inside of a dialog, and I haven't found anything of use..

Also I'll note that I've just upgraded to 3.1.2 sp1, and all ran fine with the project.. until i started trying to be fancy that is :)

Thanks in advance guys.

Trent R

The obvious thing to ask if whether or not you've indented the normal script lines.

Also what kind of errors does it give you? And have you checked out the new Dialog functions in the manual? I'm not the best with dialogue, but I believe all of those will replace things like add-inv, option-on, etc. But the old ones still work due to backwards compatibility.


~Trent
To give back to the AGS community, I can get you free, full versions of commercial software. Recently, Paint Shop Pro X, and eXPert PDF Pro 6. Please PM me for details.


Current Project: The Wanderer
On Hold: Hero of the Rune

Khris

First of all, .HasInventory requires an InvItem as parameter, not the ID.

This should do it:
Code: ags
 if (player.HasInventory(inventory[1])) dDialog.SetOptionState(6, eOptionOn);


I'd think you can't mix dialog and non-dialog script like that, so use .SetOptionState.
Replace dDialog with the scriptname of your dialog; and for readability, replace inventory[1] with the scriptname of the inv item.

Wayne Adams

EDIT: This is working now, Thanks for the assist, Khris..
I think I understand the formatting and usage of the dislog script versus normal scripting a little better.


So, I tried running the dialog with the command in the format you gave Khris.. however. AGS still reports an undefined command..
Also.. in 3.1.2 sp1 the error reporter gives lines, but in the dialog script doesn't list the code with lines.. is there a way to toggle line numbers in dialog script?


EDIT: Sorry. here is the new line:
Code: ags

if (player.HasInventory(iInventory1)) dThornOldWatch.SetOptionState(6, eOptionOn);


Where iInventory1 is item in question, and dThornOldWatch is the dialog plant should be used in.




Trent R

But notice how Khris put a space in front of his line? If you wanted to, you could indent it 10 spaces. It just needs at least one to know to run it as a normal script line rather than dialogue.

[Edit]: Also, is your item actually called iInventory1? That seems like a hassle... much more readable script to called it iKey or iShoe or whatever. Khris used the inventory[] array which can be useful for things like while loops and when you don't know a specific item. But either one works really.

About the numbered lines in the dialog editor, I believe someone requested that in the Wishlist thread. I don't think it would hurt to go quote that post and add your support to it.



~Trent
To give back to the AGS community, I can get you free, full versions of commercial software. Recently, Paint Shop Pro X, and eXPert PDF Pro 6. Please PM me for details.


Current Project: The Wanderer
On Hold: Hero of the Rune

SMF spam blocked by CleanTalk