Message scripting

Hi! I’m working on a rock, paper, scissors game and just need help with the scripting a bit. My dilemma is that I do not know how to script an object receiving a message. I want to write it like this:

mychoice == ‘rock’ if object receives message from rockbutton

any ideas???

I will post up both the script and the blend, but I did not pack the textures, since they are not needed.

Compchoice - Mychoice - Scenarios & Points - ADV

import GameLogic

import random

cont = GameLogic.getCurrentController

mychoice = paper if

mychoice = rock if

mychoice = scissors if

compchoice = random.randint(1,3)

if compchoice == 1 and mychoice == paper

I hope you guys can help!!!

The blend:

Attachments

paprscissors.blend (741 KB)

I would also like to know why the mouseover actuator stopped working in my blend… did i press something?

Never mind about the above post about not having the mouseover actuator work- i figured that part out… but what about the script???:confused:

DUH! I’m an idiot! All that you have to do is check if the sensor is positive! DUH!

Is there a new way to access properties in 2.49b API?

Cause this one won’t work.

Compchoice - Mychoice - Scenarios & Points - ADV

#import statements

import GameLogic

import random

#Defining the variables

cont = GameLogic.getCurrentController()

me = cont.owner

me.Compchoice = random.randint(1,3)

#comp - 1=rock, 2=paper, 3=scissors

actList = cont.actuators

senList = cont.sensors

PapMes = senList[“Paper”]

RocMes = senList[“Rock”]

ScisMes = senList[“Scissors”]

addscore = actList[“act1”]

mychoice = o

ga = 0

while ga == 0:

if ScisMes.positive == True:

  mychoice = Scissors

if PapMes == True:

  mychoice = Paper

if RocMes == True:

  mychoice = Rock

if compchoice == 1 and mychoice == Paper:

  addscore.activate

Property access is done by going:

object[“property”]

Oh!

So could I do this???

me = cont.owner

me[“speed”] = me[“speed”] + 0.1

Yup! Perfect.

Alright!!!
I updated my script, but every time I run it, I get an error saying that the message actuator does not have the attribute .activate.

I thought .activate was the way you trigger a positive pulse on actuators via the new python API!!

…so confusing…

Syntax always kills 'ya.

Its controller.activate(“actuator”)
Also, it is easier to use object.sendMessage(subject,body="",to="")