Sorry to bug you. : Strings.

Im sorry to keep bugging everyone, I promise im digging for information before I ask. :confused:

I have this…

   def main():

    cont = bge.logic.getCurrentController()
    sens1 = cont.sensors['msgListener']    
    msgBod = sens1.bodies
    msgSubj = sens1.subject
    
    act = cont.actuators["txtProp"]
    
    if sens1.positive:
       if msgSubj == "msgRiding":
          
          myMessage = "You have " + str(msgBod[0]) + " riding here."
          
          
          
          act.value = "Test Message"  #<------------------------------------------
          cont.activate(act)
    
    
main()

But the text object displays like this now…


I dont know what I did. I must have did something, because it was working earlier I thought.
It doesnt matter what I put in for the value, always displays some kind of odd error.
Again… sorry guys.

A simplified .blend that isolates the problem at hand should be a prerequisite for every support post.

Just posting some code and hoping that A) You posted the right section, and B) It’s possible to find/resolve the issue by just looking at that section … that’s a little silly.

There’s nothing wrong with frequent threads (in my opinion), but only if you put some effort into providing relevant info, and proper examples that we can review.

test_simple.blend (686 KB)

I have cut out everything I believe possible to simplify it and still create the error.
Something weird though… if you delete the “table”… You can no longer “mouse over”… odd, because the table doesnt have anything to do with… anything.
Deleting the table in the original file doesnt change anything… Seems like a different issue.

Going to bed. Ive been staring at the same code/logic bricks for a couple hours now, and nothing is popping out.
The bad part is… it worked earlier… IT WORKED! … lol… G’night all.

You forgot to pack the bitmap font. So it is hard to read the display ;).

Some remarks:

  • you send a message on mouse-over AND mouse-move. You can skip mouse move as you need to move the mouse to have it over the plane. I guess you want a mouse click here.
  • you check one message for a subject that is already filtered by the message sensor. This sensor will ONLY trigger on messages with the according subject. So you can remove this check from the controller, the check can never fail.
  • tip: better use module mode with meaningful function names (e.g. “copyMessageToProperty” rather than “main”)

Your problem:

  • you assign a string to a property actuators value attribute.
  • the property actuator expects an expression in this field (e.g. a property name)
  • strings in expressions should be surrounded by ’ ’ or " "
    Solution -> surround your string with ’ ’ or " "

I replaced your Script with a call to the S2A. Just have a look. (BTW you have to left click the plane now :D)

Attachments

test_simple_revised.blend (678 KB)

You forgot to pack the bitmap font. So it is hard to read the display ;).
Its a hidden image with top secret encoded messages. :stuck_out_tongue:

Some remarks:

  • you send a message on mouse-over AND mouse-move. You can skip mouse move as you need to move the mouse to have it over the plane. I guess you want a mouse click here.
  • you check one message for a subject that is already filtered by the message sensor. This sensor will ONLY trigger on messages with the according subject. So you can remove this check from the controller, the check can never fail.
  • tip: better use module mode with meaningful function names (e.g. “copyMessageToProperty” rather than “main”)
    I was in the process of tinkering with those actually, hehe.

Your problem:

  • you assign a string to a property actuators value attribute.
  • the property actuator expects an expression in this field (e.g. a property name)
  • strings in expressions should be surrounded by ’ ’ or " "
    Solution -> surround your string with ’ ’ or " "

Hmm… Im trying to display a string intentionally. It needs to say something like… “you have n amount of dollars riding on this spot” I take the property value, plug it into a string, then output it to the text message controller that puts it into the Text game property to be displayed. I had a test string surrounded with quotes:

act.value = "Test Message"  #<---------

I replaced your Script with a call to the S2A. Just have a look. (BTW you have to left click the plane now :D)
Very nice. :eyebrowlift:. Pretty nice module, and less painful than I was expecting. Good job on that.:cool:
It certainly will be very helpful.