Trouble with Message Actuators

Sorry, a lot of text…

I seem to be having a little complications with the message actuators/sensors in my game. First, off, I understand that the message logicbricks don’t work all that great anymore, and I’m just getting a be a little python savy, so I’m not afraid to use it.

This is what I want to happen in my game: The player walks up to a character in the game, who the player can talk to. When a near sensor, mouse over and mouse left click go through an AND Controller, they’re supposed to trigger a message, which is broadcast to a plane parented to the camera. When this plane receives this message, it sets in integer property (ex. Display) to 1. This in turn goes through an OR controller and triggers a visibilty actuator and sets another interger (ex. Enter) to 1. When this Enter is set to 1 and the player presses the space bar, it makes the current message invisible, sets both the Enter and Dislpay properties back to zero, and then sends another message to another plane, and through a similar process the next part of the message is displayed.

Now, the planes containing the text are set to invisible by default. When Display is set to 0, the plane is invisible. I’ve tested my game while keeping track of the properties of the planes. I walk up to the character, put my mouse pointer over him, left click…and no matter what I do, the Display property will not switch to 1, and the text will not become visible.

I’ve tried using a python script instead of a logic brick to see if I could fix this problem, by following the python suggestions for the message actuator in The Blender Gamekit. But I’m not sure I’m getting the excat syntax right. Anyone wanna lend a hand? Thanks.

You could use if statements and global variables instead of the message actuator in python.

Whoa…thanks blenderage, but…that was a little over my head ( : Just how would I do that?

Global varialbe is as follows, do it during the start-up of the game(initializing):
GameLogic.HP = 100 #Defines global variable HP to thisvalue

Okay, let me make sure I understand:

A global variable is a varible written as a script in the text window and triggered by a…python(?) logic brick during the initialization of the game. If I wanted to Display that message I want, instead of using a message actuator, I just call on that variable, and that, in turn acts as a supliment for a message actuator. I can sort of see how to use that example Azazel, but could I please have one that would look like it might be used in a hypothetical game…just so I know where all the spaces and captitals and stuff go in that script?

Also, do I need a separate global varible for each “message” I want to use in my game?

I can make a simple blend if that is what you are looking for, but I need to know what you are trying to do. If not, if you make the owner value = to the global value then you do not need the message value. It sounds odd, but that is the best way that I can explain it. The amount of global values depends on he messages that need to be sent. Global values can replace message when using python.
On the plane add (the text plane) add an always sensor to python
if GameLogic.Text ==“Type” # or whatever
o.setVisible(1) #show text
o.Text = “blah blah blah” #text you want to show
else:
o.setvisible(0) #hide text
GameLogic.Text = " " Defined dring startup

Hope that helps

Yes, Azazel. A simple .blend would be very nice. Thank you!

In the meantime I’ll play around with the script and see what I can get. Thanks again!

Oh, and here’s what I want it to do:

The player walks up to the character, and when the player is close enough and moves the mouse over the character and Left-clicks, a message is displayed on the text plane. This is only the first part of the message. After the player reads the text, the player can hit the spacebar key, and then the second part of the text will be displayed on the text plane. This process is repeated until there is no more text for the character to say. For example, if I made this character talk and he says so much that I decide to split the text into 3 parts : Player Left-clicks on the character, first part of text displayed, player reads it and hits spacebar, then the second part of the text is display, then spacebar again, and the third part of the text is displayed. Spacebar one more time, and that’s it, you move on with the game…or talk some more if you’d like ( :.

SelfStudent,
Here is a blend for what you are trying to do. I have it set up that when you collide with the object the message is displayed. When you hit space, it shows the next message after an amout of time. You can do it 3 times. When you walk away from the object the message disappers and resets. Other then the use of the mouse that you wanted, it should do the trick. I can do it with the mouse if you want.
http://www.box.net/shared/p1xhqfjdoj

Azazel

Yes, Azazel, a .blend with the mouse would be very nice, if its not too much trouble. Thank you.

Hey Self,

I noticed with Azazel’s excellent demo .blend that the character sometimes bounces back after touching the cube, so the message disappears and the timer resets. If you want the message to display when the player is within a certain distance, you could use a near sensor or make a larger bounding box around the character set to ghost and invisible that would activate the messages (I’d go with the ghost invisible thing, personally).

Just for info:

 
sMessage = Cont.getSensor("sMessage") # Name your message sensor sMessage
msg = sMessage.<b>getSubjects</b>()
if msg[0] == "Stop":
   #whatever you want
 
#alternative:
if sMessage.<b>isPositive</b>():
 msg = sMessage.<b>getBodies</b>()
 if msg[0] == "Stop":
    #whatever you want 

I hope it helps
Monster

Self,
Here is the file with the mouseover sensor and collision sensor to get the message to display. Also I have added an invisible collision box like blendenzo suggested.
http://www.box.net/shared/sdftofc41z
Hope it hleps.

Sorry, Azazel, but when I try the .blend, for some reason I can’t split the screen and I can’t see what the script is…

SelfStudent,
Sorry, Use Ctrl +Up… I maximized the 3d view port. If that does not work I can repost.

Okay, I’ve set up the scripts, logic bricks, objects and their properties, and textures just like you’ve done in your example .blend, Azazel. Here’s what’s happening.

I’ve set up an invisible cube as a Ghost actor, with collision turned on, around the character that I want to talk to. When the player walks up to this character and is in collision with the cube and mouses over the cube, I still can’t get the message to display. I checked the Message, Show, and StartUp scripts many times, and I’m quite convinced that the problem isn’t with them. But for somereason, the two square like planes that are supposed to make up the letters of the message weren’t showing up, even though they had an Always sensor connected to the python cotroller with the Show script. When I deleted the python Show script cotroller for both the letter-planes that I set up like you did in the example blend, and ran the game to see if they were forming the message. But when I walked up to the character, collided with where the box was and moused over the box, I also noticed that the letter-planes weren’t forming the message. They just remained as they were, two small square planes with the @ symbol on them.

I’ve copied the UV texture of the Arial font you used in your example blend and implemented it into my game. Is their something special I have to do with this texture along with the letter-planes so that they form to make a message? I couldn’t find anything in your example blend that seemed to do this, it just seemed to work like magic.

I’m really appreciating this help, Azazel.:slight_smile:

If you wouldn’t mind posting the blend I, or someone, can have a look at it. What it might be is the face properties are not set to TEX, on the Plane.

Okay, I’ve never posted a .blend before. How do you do it?

http://www.box.net/files
Is a good free site to upload. Just remember to make it a public link. Aslo I sent you a PM.

Thanks Azazel. Here’s the Link. It’s a bit of a hefty file, I’m afraid.

http://www.box.net/shared/loxjjxdj6h

SelfStudent,
I figured out most of the problem. One problem is in the Message script. The main problem is with the Ghost box around the character. If you scale it a bit larger, say make it 1.5 times bigger then it works, also in the Face Select of the Texure Face, you need to Select the Text(beside shadow).
Edit: Other Problem
Also, in the StartUp script, the line that says if hasattr(g,“Intit”) == 0:, needs to say if hasattr(g,“Init”) == 0:
You will just have to fix the errors in the message script. They are as follows:
One problem is on Line #22, replace the if g.Message = 3 to g.Message = 3, and indent once more…
One is on line #24 -> indent the g.Message once more…
and the other is on line #49, you need to add an = sign for the message(g.Meassage = “message”).
There is one more bug, and that is that the text overlaps. I am working a fix for that right now. But this should get you up and going. I will let you know when I figure out the overlap of the text.