Adding a character to a text attribute every time an actor is spawned

ttrungttrung Member Posts: 6
edited February 2012 in Working with GS (Mac)
Guys. I have a text attribute and I want to add an extra character to it every time a certain object is spawned. However I have had no success in doing this.

For example. Let's say I have a text attribute game.text and every time actor A is spawned, change text attribute to "A" then if B is spawned after that, change it to "AB", then if C is spawned, change it to "ABC" and so on.

At the moment I set up actor A (and B,C...) like this:
Rule -> if attribute --- game.text --- contains --- A -> nothing -> otherwise change game.text -> game.text+A

But it always give me "invalid expression" for my game.text attribute when the object is spawned! I tried to but in the " or getting rid of + but nothing works. Anybody knows if I can add a character like that in my text attribute?

Thanks a lot, folks.

Comments

  • POMPOM Member Posts: 2,599
    edited February 2012
    Unfortunately you can't add (like you did with '+') extra text to a text attribute , you can only change the whole attribute to a new text value .
    If we had the option to add text to a text attribute we basically had some type of 'writable tables' and that would have made our life a lot easier in the past 2.5 years ;)
    BUT , writable tables are suppose to come soon , and i believe its just what you need .. so......

    Roy.
  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    edited February 2012
    Hi @ttrung

    You're getting invalid expression because you are using a mathematical expression with a text attribute (...game.text+A)

    So instead, try this:

    Rule -> if attribute --- game.text --- contains --- A -> nothing -> otherwise change game.text -> game.text.."A"

    Edit: typing while Roy was typing; Roy, you can add text to a text attribute with the double dot syntax; but I'm sure you knew that really... :-)

    ----------------------------------------------------------------------------
    iPad app: End of the Earth –•– http://davidgriffinapps.co.uk/
    ----------------------------------------------------------------------------

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

  • ttrungttrung Member Posts: 6
    Thanks guys! So relieved to hear that! You guys saved my days! Now I can continue my dream of making $100k on the App Store =)) I guess it's tougher than winning American Idol.
  • POMPOM Member Posts: 2,599
    @Gyro
    "you can add text to a text attribute with the double dot syntax; but I'm sure you knew that really.."
    Yeah sure , i was referring that he can't use the '+' to add strings together :D

    Cheers mate
    Roy.
  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    edited February 2012
    Ah, got it, Roy; Mr Too-Tired-To-Read-Posts-Properly strikes again! :-)

    P.S I added 200 strings together the other day.... and made a rope. Ha!

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

  • MotherHooseMotherHoose Member Posts: 2,456
    ah, David … you are jerking our strings!

    =))

    the " .. " is lua's syntax of concatenating strings

    think that might change when we have gone native ???

    @};- MH
  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    edited February 2012
    @MotherHoose wrote: "ah, David … you are jerking our strings!"

    No @MH, just stringing you along! ;-) :-)

    Interesting question re: ".." ; I hope it doesn't change, I've sort of got used to it... but I hope there'll be more text manipulation aspects, we can only hope... (deleting specific words from a large text chunk, for example; not sure that can be done at the moment....?)

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

Sign In or Register to comment.