using the same inventory item but replacing it names

Started by shayavr, Sat 05/09/2009 18:15:20

Previous topic - Next topic

shayavr

I could'nt find anything on the forums so i started this thread..
even though I'm sure it's an easy one..

I want to make a dialog in which the options are files names.
when the player pick a choice he get the inventory item of a file (a file like sprite for graphics), but the item name is the same as the players choice:

example:
interact on cabinet:
Display "You find several files in the cabinet-which one will you take?"
1. file 1
2. file 2
3. file 3
.
.
.
if the player chooses 1. file 1 a messege: "You take file 1" pops and the player get inventory item which is named file 1.
I want to do this without creating an inventory item for each option.
I'm still using AGS 2.72



the dude abides

Matti

From the manual under "Name property (inventory)":

Quote
(Formerly known as GetInvName, which is now obsolete)
(Formerly known as SetInvItemName, which is now obsolete)
(Formerly known as InventoryItem.GetName, which is now obsolete)
(Formerly known as InventoryItem.SetName, which is now obsolete)

String InventoryItem.Name;

Gets/sets the name of the inventory item. This is the name which is initially set under the Game tab, Inventory mode of the AGS Editor.
You can change this property if for example you want to change a 'bowl' to a 'bowl with water in' but want to use the same inventory item for it.

Note that the maximum length for the name of an inventory item is 24 characters - if the name you set is longer than this, it will be truncated.

Since you're using an old version I guess it's one of the former commands.

Khris

Yeah; if you want to do something as trivial as renaming an inventory item, best look at the MANUAL first, not the forums.

2.72 already uses InventoryItem.Name, so to do what you want, I'd use this:

Code: ags
// dialog script

// file 1
set-globalint 1 1
run-script 1

// file 2
set-globalint 1 2
run-script 1

// file 3
set-globalint 1 3
run-script 1

...

// global script

function dialog_request (int p) {
  if (p == 1) {  // add file x to inventory
    iFile.Name = String.Format("file %d", GetGlobalInt(1));
    player.AddInventory(iFile);
  }
}

shayavr

I used the manuel but couldn't figure out how to write the code since I'm new on this scripting thing..

thanks KhrisMUC, Mr Matti
the dude abides

SMF spam blocked by CleanTalk