Display text in a box when interacting with an NPC?

thornster19thornster19 Member Posts: 9
edited June 2012 in Working with GS (Mac)
I am trying to figure out what is the best way of displaying a text box when interacting with an NPC. I have tried the display text behaviour, but haven't been able to tweak it the way I want it. I want my text box to work in a similar way to most RPG's, as in, when you interact with an npc, they will speak and you can press the space bar again to move on to the next bit of text.

I have also tried the spawn actor method but I am struggling with it in all honesty. I made it so that, when you interact with an npc, an actor (text box) will spawn and have text in in that you can read through. I couldn't get the text displaying in the box either.

Any help with this would be much appreciated.

Many thanks,

Thornster

Best Answer

  • fadamionfadamion Posts: 309
    Accepted Answer
    Make a global attribute intrager thats called "what image" .
    Then when it collides change attribute "what image" to "what image +1"
    This will make the attribute 1
    next time it is hit 2 then 3 so on
    Then have a rule if attribute "what image" is 1 show image 1
    then a second rule if "what image" is 2 then show image next image
    and so on for as many images as you want if you want it to just go back and forth with 2 images then there is a way to do that also.



Answers

  • IsabelleKIsabelleK Member, Sous Chef Posts: 2,807
    You can just put all dialogue lines as images, and just make an actor, and change image behavior, whenever player touches it.
  • thornster19thornster19 Member Posts: 9
    I am struggling with the spawn actor function and how to get it working with a change image behaviour.

    here is an image of my scene to better explain my point.

    https://dl.dropbox.com/u/15466671/game salad display text box problem.jpg

    When the red diamond touches the white square and the space button is pressed,an actor will spawn above the white square called 'bubble 1' that contains an exclamation mark. I want to make it so that when I collide with the white square again it will change the image in bubble 1 to something else. I have the collision behaviour on the white square so that when it collides with the red square an actor is spawned, and the change image behaviour on the bubble actor. I know I am missing a big piece of the puzzle here but I can't seem to connect the dots. Am I going about this the right way or is there an easy way to do it.

    Many thanks for you patience.




  • IsabelleKIsabelleK Member, Sous Chef Posts: 2,807
    @fadamion has some good idea, but I would change it a little:
    Make a global attribute intrager thats called "what image" .
    Then when it collides change attribute "what image" to "what image +1"
    Put a Timer, and change attribute whatimage to whatimage+1 EVERY half a second, or one second. If you don't do this, the rule will change this attribute over and over, while it's touching the other actor.
  • thornster19thornster19 Member Posts: 9
    Thankyou for the input guys,

    truly appreciated. I have a follow up question though.

    But first let me explain the way I have implemented what you guys have said. As you remember from my picture, when the red actor touches the white actor and the user presses space, it spawns a third actor called 'speech bubble'. On top of this, in the do section of the rule there is also change attribute to +1 so it counts up. In the same actor, I have made a rule so that if whatimage = 2 then spawn a second actor(all these rules aforementioned are on the second actor). The reason I did it this way is because all the actors are separate. My issue now is, when I put the rule 'if whatimage =2' in the first speech bubble actor and then 'destroy' in the do section of the rule, nothing happens. The speech bubble doesn't die. What am i doing wrong?

    Perhaps, there is also an easy way to do all this than the way I am doing it with so many actors. Should i group actors? is there an easier way?

    Many thanks

    Thornster
  • IsabelleKIsabelleK Member, Sous Chef Posts: 2,807
    First of all, don't use spawn and destroy behaviors - this will kill your performance.

    Just change image alpha to 0 (when it has to be inactive), and to 1 (if you want it to display your image).
  • The_Gamesalad_GuruThe_Gamesalad_Guru Member Posts: 9,922
    Why aren't you using your display text in conjunction with a table?
  • thornster19thornster19 Member Posts: 9
    Hey Guys,

    I have decided to go with the image changing using the method you mentioned. I am very new to game salad and programming in general, so all this is new to me.I thank you guys immensely for the support you have given me. I have managed to get my actor to change images when I click space 3 times.(so he changes to 3 different images from the standard white block. However, I then proceeded to make a rule that if the attribute equals 4, i will change the attribute to 0(using a change attribute), thus making it go back to the original white square. However it takes 5 clicks to get it to change and then it goes back to image one and not the default white square. I decided to change this to 3 just to see what it did. It went through all the images but again it reset to image 1 instead of the default white square. Any idea why?

    cheers
  • thornster19thornster19 Member Posts: 9
    Why aren't you using your display text in conjunction with a table?
    As I mentioned mate, I am new to all of this so I am just taking it one step at a time. I will definitely research the method though.

    many thanks
  • IsabelleKIsabelleK Member, Sous Chef Posts: 2,807
    Why aren't you using your display text in conjunction with a table?
    I prefer images - I want to have full control over text, it's design, and other things.
  • MotherHooseMotherHoose Member Posts: 2,456
    @thornster19

    old demo: http://www.mediafire.com/download.php?b82qa73d4qfqfxr

    done with tables … is only a demo of one way to handle dialogue

    image MH
  • thornster19thornster19 Member Posts: 9
    Thanks MotherHoose,

    I tried to have a look but I couldn't open the file. I am using the Beta for Windows so that might be an issue at present.

    If anyone has more info on my latest hurdle, I would much appreciate some direction.
    Hey Guys,

    I have decided to go with the image changing using the method you mentioned. I am very new to game salad and programming in general, so all this is new to me.I thank you guys immensely for the support you have given me. I have managed to get my actor to change images when I click space 3 times.(so he changes to 3 different images from the standard white block. However, I then proceeded to make a rule that if the attribute equals 4, i will change the attribute to 0(using a change attribute), thus making it go back to the original white square. However it takes 5 clicks to get it to change and then it goes back to image one and not the default white square. I decided to change this to 3 just to see what it did. It went through all the images but again it reset to image 1 instead of the default white square. Any idea why?

    cheers
Sign In or Register to comment.