Checking item

Started by ktalebian, Wed 27/12/2006 03:03:39

Previous topic - Next topic

ktalebian

Hi! How can I check to see if the player has  an item? I want to buy something in the game, and in the dialog, if the person has something, then they can buy the thing!
How can I do that?
thank you

also, can I set a variable in the conversation?

Sparky

Hi ktalebian-  Forgive me if you already know this. Inventory checks (and the answer to your other question) are covered in the manual, which you can read by hitting the F1 key while in the editor.

I think the variable you want is "Character.InventoryQuantity".

You seem to have a good attitude. I doubt you meant any harm, but you might want to be more careful about checking the manual before posting here in the future. Some people are really bothered by that. Best of luck with your questions!


ktalebian

Hi
thx for the reply.
Yes, I did check that out in the manuel, but the thing is that I want to do this inside the conversation script. There is no such thing in the conversation script (by conversation script I mean the dialog script, where you select the options, and the response.

thx again in advance

Khris

You can change the status of dialog options before starting the dialog.

Example:

1. I'd like to buy this, please.  (off)
2. I don't have any money.    (on)
3. Bye!  (on)

Code: ags
if (player.InventoryQuantity[iMoney.ID]==1) {
  dDialog.SetOptionState(1, eOptionOn);
  dDialog.SetOptionState(2, eOptionOff);
}
dDialog.Start();


To remove or add inventory items, use dialog_request.
From the menu, choose Script -> dialog_request, then use e.g.
Code: ags
#sectionstart...
function dialog_request(int param) {
  if (param==1) {
    player.LoseInventory(iMoney);
    player.AddInventory(iRope);
  }
  ...
}
#sectionend...


Now in the dialog script, use run-script 1.

And please, use the forum search. This has been answered before at least twice.

Da_Elf

i use a graphical variable for my money system. since in my game multiple items means multipe slots in the inventory window it would mean that 50 pieces of money would take 50 slots. So when i get the sack of money it sets my graphical varoable of "money" to = 50 so when you click on the sack in inventory to see how much the quantity is brought up by checking that variable

SMF spam blocked by CleanTalk