Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

String concatenation only can assign first element.

TheDiabolicalMr4DeeTheDiabolicalMr4Dee Posts: 15Member
edited November -1 in Working with GS (Mac)
I created and attribute game.myName yet when I try to assign a concatenated string to it <char1>..<char2>..<char3> it only displays the first character. thus doing a displayText of game.myName I get <char1>


  • firemaplegamesfiremaplegames Posts: 3,206Member
    I just tried it and it works fine.

    Make sure you are choosing your attributes from the drop-down menu,i.e:

    myText =
  • i tried putting the concatenation in quotes but it returned gobblygook:

    vars['self.attributes.id572726']..vars['self.attributes.909518']. . . .
  • firemaplegamesfiremaplegames Posts: 3,206Member
    What exactly are you trying to concatenate?

    game.char1 = A
    game.char2 = B
    game.char3 = C

    game.myName =

    Display Text: game.myName will display ABC
  • hmmm. the only difference is that my strings were not on the game level. whereas your string is:

    mine are local:


    basically I reimplemented your keyboard example for multiple text items so I made char1...char12 local to each actor consisting of a dislayText behavior, where the actors are named displayNameText, displaySchoolText . . etc. maybe i should try just making multiple sets of global attributes
  • I just need to have the player type in their name and school. the keyboard works but I can't get the 12character max string to display anymore than the first character after user types it in.
  • jessicaleahyjessicaleahy Posts: 144Member
    I just tried it and it works great.
  • yeah. looks like global is more reliable than local scope so this:


    is not as predictable as:

    Also I dont think the actor that contained the attribute was the prototype. It was an instance of the rototype in a scene. so I just deleted it and started fresh. hope this helps anyone having wierd scoping problems. My advice . . . when in doubt, go global :0)
  • jessicaleahyjessicaleahy Posts: 144Member
    Yes. You have a great point there. Going global is actually the best choice if you are not sure what to do.
This discussion has been closed.