Loading table values to Display Text

Hi,

I try to load table values as the following syntax in display text but it's not working... Do I have to copy the table values to the attribute first or there is other way I can load values directly to display text with text in front. Thanks.

"x:  tableCellValue(game.Weapons.TBL,1,3)"

Newbie

Comments

  • LiquidGameworksLiquidGameworks Anchorage, AKMember, Sous Chef Posts: 956
    On the display text behavior, you open the expression editor (the little e), and insert tableCellValue(game.Weapons.TBL,1,3)
  • spidey906spidey906 Member Posts: 52
    Thanks for the reply. Do you know if it is possible to put text before it? For example: Weapon Name: Gun. with the name gun loading from a table. Thanks.
  • LiquidGameworksLiquidGameworks Anchorage, AKMember, Sous Chef Posts: 956
    Yes, it'd look like "Gun"..tableCellValue(game.Weapons.TBL,1,3)

    The .. indicates a space. You can also do something like "Gun"..tableCellValue(game.Weapons.TBL,1,3).."is loaded!"
  • spidey906spidey906 Member Posts: 52
    edited December 2012
    I got it. thanks.
  • spidey906spidey906 Member Posts: 52
    Oh. I got it. Thanks.
  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    edited December 2012

    @kentcheung2000@yahoo.com

    Hi, I'm sure @LiquidGameworks won't mind me correcting something: the two dots (..) don't indicate a space, they indicate concatenation (just a programming word for joining together).

    One way to get your space is to add it after and before the words in your example, like this:

    "Gun "..tableCellValue(game.Weapons.TBL,1,3).." is loaded!"

    ""You are in a maze of twisty passages, all alike." - Zork        temp domain http://spidergriffin.wix.com/alphaghostapps

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    And spaces in the expression editor are entered using option+space.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,881
    For spaces you could also use the .."\32".. escape sequence. It would look like this:

    "Gun".."\32"..tableCellValue(game.Weapons.TBL,1,3).."\32".."is loaded!"

    Just for fun, you could use all the ASCI escape codes:
    "\71".."\117".."\110".."\32"..tableCellValue( game.TBL ,1,3).."\32".."\105".."\115".."\32".."\108".."\111".."\97".."\100".."\101".."\100".."\33"
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    It's optional to enclose those codes in separate quotes if they are concatenated with text:

    "Gun\32"..tableCellValue(game.Weapons.TBL,1,3).."\32isloaded!"

    Same as "first\nsecond\nthird" returns

    first
    second
    third

    But if you like your code clean, you might want to keep the quotes.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,881
    @tatiang -- Dude! That's cool! I just tested it and this also works:
    "\71\117\110\32"..tableCellValue( game.TBL ,1,3).."\32\105\115\32\108\111\97\100\101\100\33"

    I just love learning something new about GameSalad. (But for practical purposes, it is of course easier just to type the letters rather that than the ASCI codes.)
Sign In or Register to comment.