Having pictures of inventory items appear in a line

J_J

So, I'd like when you enter a room for a small panel of images of the items you've collected to appear underneath the room animation. This works:

picture ("Bedroom_house.2 Scene1.gif")
if (Got(red book) and and Got(blue book) and Got(pencil) and Got(sweater) and Got(torn paper)) {
msg ("{img:TestR.jpg} {img:TestB.jpg} {img:TestPn.jpg} {img:TestSw.jpg} {img:TestTp.jpg}")
}

The problem is that I would then have to manually write out all possible combinations of items you could be carrying at any moment @_@'
It also works to have an if script for each individual item, then if the item is in your inventory the image appears, BUT the images all appear on separate lines in a column.

Is there some way to have the images appear in a horizontal line correlating to your inventory without having to type out hundreds of combinations?


(filler for getting my edited post, updated/posted)
(again, filler for getting my edited post, updated/posted)


string concatenation:


example concepts:


math addition:

5 + 5 = 10
55 + 55 = 110

string concatenation:

"5" + "5" = "55"
"55" + "55" = "5555"
"mama" + "mia" = "mamamia"
"mama" + "3" = "mama3"
"mama" + " " + "3" + " " + "mia" = "mama 3 mia"


string_variable = "Hi"
msg (string_variable)
// output: Hi

string_variable = string_variable + ", my name is HK."
msg (string_variable)
// output: Hi, my name is HK.

string_variable = string_variable + " What is your name?"
msg (string_variable)
// output: Hi, my name is HK. What is your name?


picture ("Bedroom_house.2 Scene1.gif")

string_variable = ""

if (Got (red book)) {
  string_variable = string_variable + "{img:TestR.jpg}"
}

if (Got (blue book)) {
  string_variable = string_variable + "{img:TestB.jpg}"
}

if (Got (pencil)) {
  string_variable = string_variable + "{img:TestPn.jpg}"
}

if (Got (sweater)) {
  string_variable = string_variable + "{img:TestSw.jpg}"
}

if (Got (torn paper)) {
  string_variable = string_variable + "{img:TestTp.jpg}"
}

if (not string_variable = null) {
  msg (string_variable)
}

if you want/need a more scalable (better) design (aka, if you got a lot of items), here it is (using Dictionary Attributes and 'foreach' iteration):

create ("room_X")

picture_object_variable = create ("red book")
picture_object_variable.parent = room_X

picture_object_variable = create ("blue book")
picture_object_variable.parent = room_X

picture_object_variable = create ("pencil")
picture_object_variable.parent = room_X

picture_object_variable = create ("sweater")
picture_object_variable.parent = room_X

picture_object_variable = create ("torn paper")
picture_object_variable.parent = room_X

// ------------------------------------------

create ("picture_data_object")

picture_data_object.picture_stringdictionary_attribute = NewStringDictionary ()

dictionary add (picture_data_object.picture_stringdictionary_attribute, "red book", "{img:TestR.jpg}")

dictionary add (picture_data_object.picture_stringdictionary_attribute, "blue book", "{img:TestB.jpg}")

dictionary add (picture_data_object.picture_stringdictionary_attribute, "pencil", "{img:TestPn.jpg}")

dictionary add (picture_data_object.picture_stringdictionary_attribute, "sweater", "{img:TestSw.jpg}")

dictionary add (picture_data_object.picture_stringdictionary_attribute, "torn paper", "{img:TestTp.jpg}")

// -------------------------------------------

picture ("Bedroom_house.2 Scene1.gif")

concatenation_string_variable = ""

foreach (string_variable, picture_data_object.picture_stringdictionary_attribute) {

  object_variable = GetObject (string_variable)

  if (Got (object_variable)) {

    concatenation_string_variable = concatenation_string_variable + StringDictionaryItem (picture_data_object.picture_stringdictionary_attribut, string_variable)

  }

}

if (not concatenation_string_variable = null) {

  msg (concatenation_string_variable)

}

J_J

Thank you! This works great and looks awesome. I'm so excited. And thank you for explaining the concept first, I'm still noob so it can be confusing just looking at the code : )


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

Support

Forums