|
Development Forum |
 |
|

Malkin
     Manager

|
12/12/2013 | |
So what I'm trying to do with this script is randomly vend either a seed or a fruit (both with an expiry date) on a timed basis.
The error I get is Script 12 4 10859 9 Failed to close block at token " ... tick 8750 endi endi @ ]
So I'm thinking that the problem is either this script below, or the one just before it. Have I missed anything with this script? When does the 'failed to close block' error get triggered?
scrp 2 4 10859 9
*Check I'm not being carried
doif carr = null
*lock script
lock
*set range
rnge 100
*population check
esee 2 3 10854
addv va00 1
next
esee 2 8 10855
addv va00 1
next
*if combined population is 5 or fewer
doif va00 < 6
*instantly
inst
*get location
setv va00 posl
setv va01 post
*choose random number
setv va02 rand 1 2
*if random number is 1
doif va02 eq 1
*make a seed
new: simp 2 3 10854 "peav" 1 2 1000
attr 195
bhvr 48
perm 100
elas 30
fric 50
accg 10
mvto va00 va01
velo rand -10 10 rand -15 -20
emit 7 .5
tick 8750
*if the random number is anything else
else
*instantly make a fruit
inst
new: simp 2 8 10855 "peav" 1 2 1000
attr 195
bhvr 48
perm 100
elas 30
fric 50
accg 10
mvto va00 va01
velo rand -10 10 rand -15 -20
emit 6 .5
tick 8750
*close random number doif
endi
*close population check doif
endi
*close being carried doif
endi
*end the script
endm
|
My TCR Norns |

Moe
  

|
12/12/2013 | |
I've never seen that error I don't think, but if I were to guess it means the script manager tried to end a block of code, whether a doif, loop, or a script, but was unable to for some reason.
Try adding "TARG OWNR" after each "NEXT" when you finish an ESEE. The ESEE command will leave the target at the last "seen" agent. So anything after that like your "setv va00 posl" is actually getting coordinates from the last "seen" agent. This may be what is upsetting your code's flow and throwing the block error.
Edit: Also try adding the UNLK command after those two endi's, to let the engine know it's safe to "release". |
 Peppery One
Papriko
    
|
12/12/2013 | |
"Failed to close block" usually means that your block beginnings (loop, reps, doif, enum and so on...) and your block endings (untl, repe, endi, next and all that) are unbalanced.
But somehow I can't really spot anything which could trigger that kinda error. Seems to be all fine...
Not related to your issure, just a little note:setv va02 rand 1 2
doif va02 eq 1 | can be sustituted with the slightly shorterin a similar fashion as you do it in your velo commands. Nothing important or special, sadly nothing related to your error either, just so btw.
Lets play plants! Photosynthesis... Photosynthesis... Photosynthesis... |

Moe
  

|
12/12/2013 | |
Oddly enough, I tried to implement the code myself... Didn't have any problems executing it as is. Would you like to send me the full COS file and Sprite to see if it's something tangentially related? |

Malkin
     Manager

|
12/12/2013 | |
The full code is:
inst
new: simp 2 4 10859 "peav" 2 0 500
attr 199
bhvr 11
perm 100
elas 0
fric 100
accg 30
doif tmvt 2573 738 eq 1
mvto 2573 738
else
mvsf rand 748 1550 9547
tick 3600
endi
scrp 2 4 10859 1
stim writ from 84 1
anim [0 1 1 1 1 0]
base 0
setv va00 posl
setv va01 post
setv va02 rand 1 2
doif va02 eq 1
inst
new: simp 2 3 10854 "peav" 1 2 1000
attr 195
bhvr 48
perm 100
elas 30
fric 50
accg 10
mvto va00 va01
velo rand -10 10 rand -15 -20
emit 7 .5
tick 8750
else
inst
new: simp 2 8 10855 "peav" 1 2 1000
attr 195
bhvr 48
perm 100
elas 30
fric 50
accg 10
mvto va00 va01
velo rand -10 10 rand -15 -20
emit 6 .5
tick 8750
endi
endm
scrp 2 4 10859 2
stim writ from 84 1
anim [0 1 1 1 1 0]
base 0
setv va00 posl
setv va01 post
setv va02 rand 1 2
doif va02 eq 1
inst
new: simp 2 3 10854 "peav" 1 2 1000
attr 195
bhvr 48
perm 100
elas 30
fric 50
accg 10
mvto va00 va01
velo rand -10 10 rand -15 -20
emit 7 .5
tick 8750
else
inst
new: simp 2 8 10855 "peav" 1 2 1000
attr 195
bhvr 48
perm 100
elas 30
fric 50
accg 10
mvto va00 va01
velo rand -10 10 rand -15 -20
emit 6 .5
tick 8750
endi
endm
scrp 2 4 10859 9
*Check I'm not being carried
doif carr = null
*lock script
lock
*set range
rnge 100
*population check
esee 2 3 10854
addv va00 1
next
targ ownr
esee 2 8 10855
addv va00 1
next
targ ownr
*if combined population is 5 or fewer
doif va00 < 6
*instantly
inst
*get location
setv va00 posl
setv va01 post
*choose random number
setv va02 rand 1 2
*if random number is 1
doif va02 eq 1
*make a seed
new: simp 2 3 10854 "peav" 1 2 1000
attr 195
bhvr 48
perm 100
elas 30
fric 50
accg 10
mvto va00 va01
velo rand -10 10 rand -15 -20
emit 7 .5
tick 8750
*if the random number is anything else
else
*instantly make a fruit
inst
new: simp 2 8 10855 "peav" 1 2 1000
attr 195
bhvr 48
perm 100
elas 30
fric 50
accg 10
mvto va00 va01
velo rand -10 10 rand -15 -20
emit 6 .5
tick 8750
*close random number doif
endi
*close population check doif
endi
*close being carried doif
endi
*end the script
endm
scrp 2 4 10859 303
mesg writ ownr 1
endm
scrp 2 3 10854 9
lock
kill targ
endm
scrp 2 8 10855 9
lock
kill targ
endm
scrp 2 3 10854 12
lock
sndc "chwp"
stim writ from 77 1
*Prostaglandin to aid in healing from injuries.
doif from ne null
targ from
chem 94 .35
endi
kill ownr
endm
scrp 2 8 10855 12
lock
sndc "chwp"
stim writ from 78 1
*Vitamin C to keep bones healthy and aid in healing from injuries. Water to support respiratory function in the presence of Vitamin C.
doif from ne null
targ from
chem 99 .35
chem 33 .5
endi
kill ownr
endm
rscr
enum 2 4 10859
kill targ
next
enum 2 3 10854
kill targ
next
enum 2 8 10855
kill targ
next
scrx 2 4 10859 1
scrx 2 4 10859 2
scrx 2 4 10859 303
scrx 2 3 10854 9
scrx 2 8 10855 9
scrx 2 3 10854 12
scrx 2 8 10855 12 |
It seemed to work until I added the expiry dates...
My TCR Norns |

Moe
  

|
12/12/2013 | |
Tried implementing the whole code. I found no error. I'm at a loss now as to why you received that error. Was there something else involved? Was something eating the vended foodstuffs nearby? Anything? |

Malkin
     Manager

|
12/12/2013 | |
It gives me that error on injection..
The code for the last iteration was:
inst
new: simp 2 4 10859 "peav" 2 0 500
attr 199
bhvr 11
perm 100
elas 0
fric 100
accg 30
doif tmvt 2573 738 eq 1
mvto 2573 738
else
mvsf rand 748 1550 9547
tick 16
endi
scrp 2 4 10859 1
stim writ from 84 1
anim [0 1 1 1 1 0]
base 0
setv va00 posl
setv va01 post
setv va02 rand 1 2
doif va02 eq 1
inst
new: simp 2 3 10854 "peav" 1 2 1000
attr 195
bhvr 48
perm 100
elas 30
fric 50
accg 10
mvto va00 va01
velo rand -10 10 rand -15 -20
emit 7 .5
tick 8
else
inst
new: simp 2 8 10855 "peav" 1 2 1000
attr 195
bhvr 48
perm 100
elas 30
fric 50
accg 10
mvto va00 va01
velo rand -10 10 rand -15 -20
emit 6 .5
tick 8
endi
endm
scrp 2 4 10859 2
stim writ from 84 1
anim [0 1 1 1 1 0]
base 0
setv va00 posl
setv va01 post
setv va02 rand 1 2
doif va02 eq 1
inst
new: simp 2 3 10854 "peav" 1 2 1000
attr 195
bhvr 48
perm 100
elas 30
fric 50
accg 10
mvto va00 va01
velo rand -10 10 rand -15 -20
emit 7 .5
tick 8
else
inst
new: simp 2 8 10855 "peav" 1 2 1000
attr 195
bhvr 48
perm 100
elas 30
fric 50
accg 10
mvto va00 va01
velo rand -10 10 rand -15 -20
emit 6 .5
tick 8
endi
endm
scrp 2 4 10859 9
doif carr = null
lock
rnge 100
esee 2 3 10854
addv va00 1
next
esee 2 8 10855
addv va00 1
next
doif va00 < 6
inst
setv va00 posl
setv va01 post
setv va02 rand 1 2
doif va02 eq 1
new: simp 2 3 10854 "peav" 1 2 1000
attr 195
bhvr 48
perm 100
elas 30
fric 50
accg 10
mvto va00 va01
velo rand -10 10 rand -15 -20
emit 7 .5
tick 8
else
inst
new: simp 2 8 10855 "peav" 1 2 1000
attr 195
bhvr 48
perm 100
elas 30
fric 50
accg 10
mvto va00 va01
velo rand -10 10 rand -15 -20
emit 6 .5
tick 8
endi
endi
endm
scrp 2 4 10859 303
mesg writ ownr 1
endm
scrp 2 3 10854 12
lock
sndc "chwp"
stim writ from 77 1
*Prostaglandin to aid in healing from injuries.
doif from ne null
targ from
chem 94 .35
endi
kill ownr
endm
scrp 2 8 10855 12
lock
sndc "chwp"
stim writ from 78 1
*Vitamin C to keep bones healthy and aid in healing from injuries. Water to support respiratory function in the presence of Vitamin C.
doif from ne null
targ from
chem 99 .35
chem 33 .5
endi
kill ownr
endm
rscr
enum 2 4 10859
kill targ
next
enum 2 3 10854
kill targ
next
enum 2 8 10855
kill targ
next
scrx 2 4 10859 1
scrx 2 4 10859 2
scrx 2 4 10859 303
scrx 2 3 10854 12
scrx 2 8 10855 12 |
If that helps..
My TCR Norns |

Moe
  

|
12/12/2013 | |
Add one more "ENDI" to the timer script, right before the ENDM. |

Malkin
     Manager

|
12/12/2013 | |
That seems to crash my entire game! ![[nlaugh] [nlaugh]](/images/smilies/emot_laugh.gif)
My TCR Norns |

Moe
  

|
12/12/2013 | |
That fixed it in my game. I'm afraid I've got nothing else for ya. |

Malkin
     Manager

|
12/12/2013 | |
Thanks. 
My TCR Norns |
 Prodigal Sock
Ghosthande
    

|
12/13/2013 | |
I can't see how adding an ENDI would crash your entire game. At worst it should just throw an error. Could it have been a coincidence? 
 |

Malkin
     Manager

|
12/13/2013 | |
My theory is that the scripts are somehow not being removed properly, clashing, and causing the crash. As the Kutoka edition has a tendency to crash rather than do anything so civilised as 'throw errors', it's probably time for a reinstall. 
My TCR Norns |