Home   Help Search Login Register  

Author Topic: Error zero divisor?  (Read 544 times)

0 Members and 1 Guest are viewing this topic.

SheepOnMintSauce

  • Guest
Error zero divisor?
« on: 23 Aug 2003, 13:17:17 »
When I test my script I get the error '_spotter = _this select 1|#|': Error Zero Divisor.

I'm stumped.  :-\

I tried using '_spotter = this select 1', but then I get another error, '_spotter = this select 1|#|': Error select : Type Object, expected Array.

The first part of my script goes like this :

Code: [Select]
_sniper = _this select 0
_spotter = _this select 1

;Check to see if the spotter has an M16 and a Pair of Binoculars.
#weapon
? _spotter hasweapon "binocular" : goto "m16"
_spotter addWeapon "binocular"
#m16
? _spotter hasweapon "M16" : goto "start"
_spotter addMagazine "M16"
_spotter addMagazine "M16"
_spotter addweapon "M16"
;All tooled up and ready to go.
#start
_actionstart = _sniper addaction ["Start Spotting", "start.sqs"]

If anyone has a solution to it, thanks in advance.  :)

Offline KTottE

  • Former Staff
  • ****
Re:Error zero divisor?
« Reply #1 on: 23 Aug 2003, 14:06:09 »
How are you calling your script?
"Life is not a journey to the grave with the intention of arriving safely in a pretty and well preserved body, but rather to skid in broadside, thoroughly used up, totally worn out, and loudly proclaiming 'WOW What a Ride!'"

SheepOnMintSauce

  • Guest
Re:Error zero divisor?
« Reply #2 on: 23 Aug 2003, 14:23:12 »
From the 'init' field of the sniper

Code: [Select]
[sniper,spotter] exec "spotter.sqs"
Incidently spotter.sqs is the name of the script, I want the 'Start spotting' action to appear in the action menu in-game. It does, but when I select it that is when the problem occurs.

Although using '_spotter = this select 1' without the underscroll on the 'this', the error "_spotter = this select 1|#|': Error select : Type Object, expected Array" comes up as soon as I preview it.

Offline KTottE

  • Former Staff
  • ****
Re:Error zero divisor?
« Reply #3 on: 23 Aug 2003, 14:37:53 »
Okay, will test this on my machine.
But you should remove the _ from the action-name, otherwise you won't be able to reference it later.

Execute with:
[sniper,spotter] exec "spotter.sqs"

spotter.sqs:
Code: [Select]
_sniper = _this select 0
_spotter = _this select 1

;Check to see if the spotter has an M16 and a Pair of Binoculars.
#weapon
? _spotter hasweapon "binocular" : goto "m16"
_spotter addWeapon "binocular"
#m16
? _spotter hasweapon "M16" : goto "start"
_spotter addMagazine "M16"
_spotter addMagazine "M16"
_spotter addweapon "M16"
;All tooled up and ready to go.
#start
actionstart = _sniper addaction ["Start Spotting", "start.sqs"]

That should work.

edit
Just tested it,  and this is the result. It works fine here.
« Last Edit: 23 Aug 2003, 14:46:14 by KTottE »
"Life is not a journey to the grave with the intention of arriving safely in a pretty and well preserved body, but rather to skid in broadside, thoroughly used up, totally worn out, and loudly proclaiming 'WOW What a Ride!'"

deaddog

  • Guest
Re:Error zero divisor?
« Reply #4 on: 23 Aug 2003, 14:49:50 »
You probably shouldn't call the script from the init line of a unit.  Chances are good that the "spotter" unit is not initialized yet.  Try executing the script from the init.sqs file instead.

SheepOnMintSauce

  • Guest
Re:Error zero divisor?
« Reply #5 on: 23 Aug 2003, 15:44:53 »
Ok, I've sort of managed to get it working now. I just need to sort out my other problem and hopefully I'll have no more problems...  :-\

Anyway, thanks for your advice guys.  ;D