String concatenation only can assign first element.

TheDiabolicalMr4DeeTheDiabolicalMr4Dee Member Posts: 15
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>

Comments

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

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

    myText = game.char1..game.char2..game.char3
  • TheDiabolicalMr4DeeTheDiabolicalMr4Dee Member Posts: 15
    i tried putting the concatenation in quotes but it returned gobblygook:

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

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

    game.myName = game.char1..game.char2..game.char3

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

    mytext=game.char1..game.char2..

    mine are local:

    mytext=self.char1..self.char2.....self.char12

    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

    myName=game.nameLetter1..game.nameletter2..game.nameletter3
    mySchool=game.schoolLetter1..game.schooLetter2..gameschoolLetter3
  • TheDiabolicalMr4DeeTheDiabolicalMr4Dee Member Posts: 15
    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 Member Posts: 144
    I just tried it and it works great.
  • TheDiabolicalMr4DeeTheDiabolicalMr4Dee Member Posts: 15
    yeah. looks like global is more reliable than local scope so this:

    mytext=self.char1..self.char2.....self.char12

    is not as predictable as:

    myName=game.nameLetter1..game.nameletter2..game.nameletter3
    mySchool=game.schoolLetter1..game.schooLetter2..gameschoolLetter3

    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 Member Posts: 144
    Yes. You have a great point there. Going global is actually the best choice if you are not sure what to do.
Sign In or Register to comment.