|
Development Forum |
 |
|
 Mad Scientist
clohse
 

|
7/30/2013 | |
subr normal
*get a little hungrier
subv ov02 10
**ov10 = -1 left +1 = right
doif ov10 = -1
*take a random number of steps left
reps rand 1 10
doif fall = 0
over
base ov30
anim [0 1 2 3 4 5 6 7]
setv velx -10
setv vely -2
else
over
pose 0
endi
repe
else
*take a random number of steps right
reps rand 1 10
doif fall = 0
over
base ov31
anim [0 1 2 3 4 5 6 7]
setv velx 10
setv vely -2
else
over
pose 0
wait 10
endi
repe
endi
*reset our direction
setv ov10 rand 0 1
doif ov10 eq 0
setv ov10 -1
endi
retn
|
Can anyone tell me why I am getting the following error?
"Invalid TARG
... xt retn subr normal {@}subv ov02 10 doif ov10 = -1 re ... "
Thanks
CLohse's Norns at the Creatures Repository |

Malkin
     Manager

|
7/30/2013 | |
Per the example of this thread, maybe the code only knows that it errors when it gets to that point, it can't definitively tell you that that exact line is the culprit.
What's happening before the subroutine? Can you follow along with what the agent is TARGing?
My TCR Norns |
 Mad Scientist
clohse
 

|
7/30/2013 | |
This is for a critter and the error occurs after it has eaten food and is going back to wandering around. During the eat subroutine it TARG's the food, moves over to it, kills it and increases energy.
My feeling is that I am forgetting what happens when the agent that is TARG'ed is killed. Is the TARG automatically set back to ownr or do I need to put it in there. I tried both ways and it didn't matter.
CLohse's Norns at the Creatures Repository |

Malkin
     Manager

|
7/30/2013 | |
Are you following along from Ghosthande's Hungry Critter Tutorial? Have you tried instead getting the critter to trigger the food's eat script?
My TCR Norns |
 Mad Scientist
clohse
 

|
7/30/2013 | |
yes, I was and no I haven't. I will give that a try tonight after I tuck in my own baby norn.
Thanks for the ideas.
EDIT:
I made the change in the eat from kill to mesg writ. It seems to run a little smoother while eating, but the same error still pops up. Here is the entire timer script. Ideas or observations?
scrp 2 15 16110 9
*being carried? - just hang out a bit
doif carr <> null
over
pose 0
wait 10
else
*not going to include mating, so check hunger
doif ov02 le 0
gsub die
elif ov02 le 30
gsub food
else
gsub normal
endi
endi
*subroutines
subr die
*just disappears for awhile and recharges the hunger
over
base ov36
anim [0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15]
wait 15
*recharge hunger
addv ov01 125
setv ov10 rand 0 1
doif ov10 eq 0
setv ov10 -1
endi
doif ov10 eq -1
base ov34
else
base ov35
endi
anim [ 0 0 1 2 3 4 5 6 7 8]
*pop up and get ready to move
retn
subr food
rnge 1000
seta ov99 null
inst
esee 2 11 0
*look for food to eat
doif targ ne null
setv va02 posx
seta va99 targ
*when you find food, save its position
targ ownr
setv va02 va02
seta ov99 va99
loop
*begin moving towards the food until you touch
doif posx gt va02
over
base ov30
anim [0 1 2 3 4 5 6 7]
velo -5 -5
wait 5
elif posx lt va02
over
base ov31
anim [0 1 2 3 4 5 6 7]
velo 5 -5
wait 5
endi
untl touc ownr ov99 eq 1 or ov99 eq null
*if food is still there - eat it
doif ov99 ne null
sndc "chwp"
mesg writ ov99 12
addv ov02 30
else
*if the food is gone - wander around some more
gsub normal
endi
gsub normal
else
gsub normal
endi
next
retn
subr normal
**ov10 = -1 left +1 = right
doif ov10 = -1
*take a random number of steps left
reps rand 1 10
doif fall = 0
over
base ov30
anim [0 1 2 3 4 5 6 7]
setv velx -10
setv vely -2
else
over
pose 0
endi
repe
else
*take a random number of steps right
reps rand 1 10
doif fall = 0
over
base ov31
anim [0 1 2 3 4 5 6 7]
setv velx 10
setv vely -2
else
over
pose 0
wait 10
endi
repe
endi
*reset our direction
setv ov10 rand 0 1
doif ov10 eq 0
setv ov10 -1
endi
*get a little hungrier
subv ov02 10
retn
endm
|
CLohse's Norns at the Creatures Repository |

Malkin
     Manager

|
7/31/2013 | |
Is it going to be a ground-based critter? The snotrock cos file, which Ghosthande based her tutorial hunt script on, after the ESEE, checks the RELY (relative height) of the target foodstuff, then checks the RELX of the target foodstuff, then, if it's 'within reach', sets va02 as targ. The snotrock has ov16 as its' 'food target'.
Maybe after the target agent (the food) is killed, the TARG becomes null, which freaks the critter out?
* search for food close by
rnge 200
setv va00 10000
seta va02 null
inst
esee 2 11 8
* only check tuba that can be eaten
doif ov05 eq 1
* only check food roughly on the same height
setv va01 rely ownr targ
doif va01 lt 0
negv va01
endi
doif va01 lt 100
setv va01 relx ownr targ
doif va01 lt 0
negv va01
endi
doif va01 lt va00
setv va00 va01
seta va02 targ
endi
endi
endi
next
* if found some change mission to approach food
doif va02 ne null
seta ov16 va02
setv ov00 3
* otherwise walk in a straight line searching
else
gsub walk
endi
endi
*approaching food
doif ov00 eq 3
inst
targ ov16
doif targ ne null
setv va00 posx
else
targ ownr
setv ov00 2
endi
targ ownr
slow
* if you're facing the wrong way turn around
doif posx gt va00 and ov10 gt 0
call 1000 0 0
elif posx lt va00 and ov10 lt 0
call 1000 0 0
endi
gsub walk
inst
doif ov16 ne null
doif touc ownr ov16 eq 1
gsub eat
endi
else
setv ov00 2
endi
slow
endi |
My TCR Norns |
 Mad Scientist
clohse
 

|
7/31/2013 | |
yay! Thanks for your help! He has finally quit autokilling!
CLohse's Norns at the Creatures Repository |

Malkin
     Manager

|
7/31/2013 | |
Fantastic! What did you change?
My TCR Norns |
 Mad Scientist
clohse
 

|
7/31/2013 | 1 |
I had too many gsub normal statements. I just took them out.
CLohse's Norns at the Creatures Repository |