Trying to show variables in inventory

Still relatively new, but making progress.

I have a command that replicates the Inventory command, and I'm trying to modify it so instead of just showing the object, it shows the object and a variable associated with it. In this case, what version it has been upgraded to. So, instead of having each version of an object be its own object, I was looking to have one type of object with a version that goes up and down as the game progresses.

So the list would output "Program Name v{program.version}" with the inventory list.

I can get it to work with a Look At, but not via the inventory list.

Thanks in advance...


spoilsbrowed

Just a polite nudge to whom it may concern, if you could please catergorise my IFComp entry?
To play the amazing game run 3, player have to run and jump to pass different levels of obstacles. People remember this game as a game everyone play at school. Good luck and have fun guys!


Post above is spam.

I think it might go to a game of some sort, but the first sentence is copied from another post to make it look like it fits in this site.


Io

Edit: Oops. How do you delete replies?


You'd probably want something like:

items = NewStringList()
foreach (program, GetDirectChildren(game.pov)) {
  if (not GetBoolean (program, "scenery")) {
    name = GetDisplayName (program)
    if (HasAttribute (program, "version")) {
      name = name + " v" + program.version
    }
    list add (items, name)
  }
}
if (ListCount (items) > 0) {
  msg (Template ("CarryingListHeader") + FormatList (items, ", ", Template("And"), "") + ".")
}
else {
  msg (Template ("CarryingListHeader"))
}

That should behave just like the default "inventory" command, except that it includes the "version" attribute for any object that has one.


the key thing thing in mrangel's excellent functional code for what you want, is the:

'GetDisplayName (OBJECT)' Function/Script
// and/or also the:
'GetDisplayAlias (OBJECT)' Script/Function

http://docs.textadventures.co.uk/quest/functions/corelibrary/getdisplayname.html
http://docs.textadventures.co.uk/quest/functions/corelibrary/getdisplayalias.html

for example:

object_variable = create ("katana_object")

object_variable.parent = room

object_variable.alias = "katana"

msg ("Katana Name: " + object_variable.name) // Katana Name: katana_object

msg ("Katana Parent (location): " + object_variable.parent.name) // Katana Parent (location): room

msg ("Katana Alias: " + object_variable.alias) // Katana Alias: katana

object_variable.alias = GetDisplayAlias (object_variable) + " (equipped)"

msg ("Katana Alias: " + object_variable.alias) // Katana Alias: katana (equipped)

object_variable.alias = GetDisplayAlias (object_variable) + " (equipped_2)"

msg ("Katana Alias: " + object_variable.alias) // Katana Alias: katana (equipped) (equipped_2)

// note that the Object's built-in 'alias' String Attribute is also what will be displayed on the right panel as a button and also in the big text box on the left as hypertext

----------

// you can NOT change the Object's built-in 'name' String Attribute, as it is the 'ID' used by quest:

object_variable.name = GetDisplayName (object_variable) + " (equipped)" // ERROR!

----------------------------------

// but you CAN do do this, two examples:

// example 1:

object_variable.alias = GetDisplayName (object_variable) + " (equipped)"

msg ("Katana Alias: " + object_variable.alias) // Katana Alias: katana_object (equipped)

// example 2:

object_variable.alias = "katana"

object_variable.alias = GetDisplayName (object_variable) + " (equipped) " + GetDisplayAlias (object_variable) + " (equipped_2)"

msg ("Katana Alias: " + object_variable.alias) // Katana Alias: katana_object (equipped) katana (equipped_2)

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

Support

Forums