|
Development Forum |
 |
| (solved) C3 CAOS - Invalid agent | |
|

Arimar993

|
7/17/2013 | |
I am trying to create a speech bubble above my agent.
My script is below. When I touch the agent with the hand, it throws:
Invalid agent
... va00 targ targ ownr {@}mesg wrt+ va00 126 va41 targ 1 ...
I'm new to C3 CAOS, but not at all new to programming.
inst
new: simp 3 8 33111 "lightmod" 0 1 1000
attr 195
elas 10
accg 2
perm 100
seta va00 targ
vois "MachineVoice"
enum 1 2 11
spas targ va00
doif ov00 = 0 and clac = 0
mesg writ targ 0
endi
next
**Handles Hand Touch
scrp 3 8 33111 92
sets va05 "please"
sezz va05
**target agent speech bubble factory
rtar 1 2 10
seta va00 targ
targ ownr
**message asbubblef mkbubble text agent_speaking dly
mesg wrt+ va00 126 va05 targ 1
endm
**Removal Script
rscr
enum 3 8 33111
kill targ
next
scrx 3 8 33111 92
|
What is incorrect in my code?
Thanks in advance! |
 Peppery One
Papriko
    
|
7/17/2013 | |
rtar 1 2 10
seta va00 targ |
That FIRST targets the speechbubble factory and THEN saves the agent. That's the wrong order. You want to save your own agent, so try to exachange those two lines, so that you getseta va00 targ
rtar 1 2 10 |
Lets play plants! Photosynthesis... Photosynthesis... Photosynthesis... |

Arimar993

|
7/17/2013 | |
Hmm. I'm not getting the invalid agent error, but the speech bubble does not appear. Any help would be appreciated! |
 Peppery One
Papriko
    
|
7/18/2013 | |
Ah, just saw it now.| mesg wrt+ va00 126 va05 targ 1 | In this line, you have twisted the values. VA00 holds the agent that is supposed to make the speech bubble, TARG is the speechbubble factory (due to our RTAR line). Since you wanna send the script message to the speechbubble factory and not to your agent and you want to pass your agent as a value, you must exchange VA00 and TARG. Try this:| mesg wrt+ targ 126 va05 va00 1 |
Lets play plants! Photosynthesis... Photosynthesis... Photosynthesis... |

Arimar993

|
7/18/2013 | 1 |
That worked! Thank you very much! Strange though, because I'm sure I tried something similar using OWNR instead of targ, but that errored too? Oh well, such is programming!
For any future visitors, the part of my CAOS that Handles Hand Touch now looks like this:
**Handles Hand Touch
scrp 3 8 33111 92
sets va05 "please"
sezz va05
**target agent speech bubble factory
targ ownr
seta va00 targ
rtar 1 2 10
**message asbubblef mkbubble text agent_speaking dly
mesg wrt+ targ 126 va05 va00 1
endm
|
|
 Peppery One
Papriko
    
|
7/18/2013 | |
That might work too. OWNR always refers to the agent this script originated from (the "owner" ). Some really complicated scripts might make you TARG across the half world, jumping from agent to agent and what not, but OWNR always brings you back to your starting point.
What you might try too is to remove the lines targ ownr seta va00 targ entirely and change the messaging line like that:| mesg wrt+ targ 126 va05 ownr 1 |
Lets play plants! Photosynthesis... Photosynthesis... Photosynthesis... |

Arimar993

|
7/20/2013 | |
Yes, that worked as well. :-) Thanks again! |