Displaying Inventory

Hi!

I have created a command called "Items". I would like this command when selected to display a list of objects that the player is currently carrying. How do I link this command to the player's inventory?


The easiest way to do this would be to make it run the built-in "inventory" command.

If you're using the desktop editor, I believe there's an option to show the core commands, and then you could change the pattern of the inventory command from ^i$|^inv$|^inventory$ to ^i$|^inv$|^inventory$|^items$.

If you're using the web editor, you could achieve the same effect by putting a line in the start script:

inventory.pattern = "^i$|^inv$|^inventory$|^items$"

Both of the methods above simply make "items" and alternate name for the "inventory" command.

Or if you want to make your own "items" command (because you have it do other things as well?) you could have it call the built-in "inventory" command like this:

do (inventory, "script")

or for a little more flexibility, you could look at the code of the inventory command, and modify it to better fit your needs. This is how "inventory" does it:

list = FormatObjectList(Template("CarryingListHeader"), game.pov, Template("And"), ".")
if (list = "") {
  msg (Template("NotCarryingAnything"))
}
else {
  msg (list)
}

Thank you mrangel. This worked! Now I can use a command in the game! I don't know how far I could have gotten in this project without the forum giving out useful information. Kudos!


This topic is now closed. Topics are closed after 60 days of inactivity.

Support

Forums