Home   Help Search Login Register  

Author Topic: Script "Scalar Bool" Error  (Read 736 times)

0 Members and 1 Guest are viewing this topic.

tehhunter

  • Guest
Script "Scalar Bool" Error
« on: 03 Jul 2005, 00:17:05 »
I'm currently trying to make a small script for some camCreated artillery. I am an experienced programer, yet I can't figure out exactly why I keep getting the error "Scalar Bool Array String 0xfcffffcef".

Also, I made a small script (included) that picks a random vehicle ammo to use for the explosion, so more variety is included. However, it will only return "Shell73" or the aforementioned error as the variable _uwp (which is the weapon to be used).

_vwp# variables are the vehicle ammos to choose from.

So, if anyone has any ideas, I would be most delighted to hear them. Thanks.

   
Code: [Select]
_center = getPos gl1

;* Insert your diameter here:
   
   _di = 150;

;* Insert the total amount of rounds to shoot here:

   _total = 20
   
;* Edit these if you know what you are doing:
   _count = 0

   _vwp0 = "Shell125"
   _vwp1 = "Heat125"
   _vwp2 = "Heat73"
   _vwp3 = "Shell73"

#leapback

   _ri = random 4
   ?(_ri < 0):_uwp = _vwp0
   ?(_ri < 1):_uwp = _vwp1
   ?(_ri < 2):_uwp = _vwp2
   ?(_ri < 3):_uwp = _vwp3

   mk sideChat Format["%1 chosen by %2",_uwp,_ri]
   hint format ["%1", _uwp]
   _rx = random _di
   _ry = random _di

   _cx = _rx + _center select 0
   _cy = _ry + _center select 1
   _cz = 300   
   _pos set [0,_cx]
   _pos set [1,_cy]
   _pos set [2,_cz]

   mk sideChat Format["%1 AND %2",_pos,_uwp]

   _uwp camCreate _pos

   _count = _count + 1   

~3

?(_count < _total):goto leapback
?!(_count < _total):exit

Offline THobson

  • OFPEC Patron
  • Former Staff
  • ****
Re:Script "Scalar Bool" Error
« Reply #1 on: 03 Jul 2005, 00:42:52 »
Several problems lie here:
Quote
?(_ri < 0):_uwp = _vwp0
   ?(_ri < 1):_uwp = _vwp1
   ?(_ri < 2):_uwp = _vwp2
   ?(_ri < 3):_uwp = _vwp3

Think about it.  What is _uwp if _ri is say 0.5?  

Answer: _vwp3.  Well first it is set to _vwp1 because it is less than 1; then it is set to _vwp2 because it is less than 2 .... but it will end up at _vwp3

And how on earth can _ri be less than 0?

and what happens if _ri >= 3 but < 4?  _uwp is undefined and that gives you your scalar thing.


Try:

_shells = ["Shell125","Heat125","Heat73","Shell73"]
_thisone = random (count _shells)
_thisone = _thisone - (_thisone % 1)
_shell = _shells select _thisone





« Last Edit: 03 Jul 2005, 00:57:40 by THobson »

Offline Planck

  • Honoured
  • Former Staff
  • ****
  • I'm never wrong ....I'm just not always right !
Re:Script "Scalar Bool" Error
« Reply #2 on: 03 Jul 2005, 00:43:03 »
I think the problem might be here.

Code: [Select]
_ri = random 4
   ?(_ri < 0):_uwp = _vwp0
   ?(_ri < 1):_uwp = _vwp1
   ?(_ri < 2):_uwp = _vwp2
   ?(_ri < 3):_uwp = _vwp3

If we presume that random 4 comes up with something like 0.55.......then all 3 of the last checks will be true, but the last one will be the effective one:

Shell73

On another note......I think random 4 will generate a number between 0 and 4, I can't see it ever generating a number less than 0, so the first check is a little redundant.

Try something like this:

Code: [Select]
_ri = random 4
   ?(_ri >= 0) && (_ri < 1) :_uwp = _vwp0
   ?(_ri >= 1) && (_ri < 2) :_uwp = _vwp1
   ?(_ri >= 2) && (_ri < 3) :_uwp = _vwp2
   ?(_ri >= 3) && (_ri <= 4) :_uwp = _vwp3

Something like that anyway........it's late   ::)


Planck
« Last Edit: 03 Jul 2005, 00:46:55 by Planck »
I know a little about a lot, and a lot about a little.

Offline bedges

  • Administrator
  • *****
    • OFPEC The Editing Center
Re:Script "Scalar Bool" Error
« Reply #3 on: 03 Jul 2005, 00:48:05 »
alternatively, utilise the mod command to round your random numbers...

see? 'mods' are very handy to have around ;)

Offline THobson

  • OFPEC Patron
  • Former Staff
  • ****
Re:Script "Scalar Bool" Error
« Reply #4 on: 03 Jul 2005, 00:49:43 »
You guys are getting slow in your old age ;D

Offline Planck

  • Honoured
  • Former Staff
  • ****
  • I'm never wrong ....I'm just not always right !
Re:Script "Scalar Bool" Error
« Reply #5 on: 03 Jul 2005, 00:57:04 »
11 seconds wasn't too bad.


Planck
I know a little about a lot, and a lot about a little.

Offline THobson

  • OFPEC Patron
  • Former Staff
  • ****
Re:Script "Scalar Bool" Error
« Reply #6 on: 03 Jul 2005, 00:58:36 »
There are the quick and there are the dead ;D

tehhunter

  • Guest
Re:Script "Scalar Bool" Error
« Reply #7 on: 03 Jul 2005, 01:21:09 »
I think the problem might be here.

Code: [Select]
_ri = random 4
   ?(_ri < 0):_uwp = _vwp0
   ?(_ri < 1):_uwp = _vwp1
   ?(_ri < 2):_uwp = _vwp2
   ?(_ri < 3):_uwp = _vwp3

If we presume that random 4 comes up with something like 0.55.......then all 3 of the last checks will be true, but the last one will be the effective one:

Shell73

On another note......I think random 4 will generate a number between 0 and 4, I can't see it ever generating a number less than 0, so the first check is a little redundant.

Try something like this:

Code: [Select]
_ri = random 4
   ?(_ri >= 0) && (_ri < 1) :_uwp = _vwp0
   ?(_ri >= 1) && (_ri < 2) :_uwp = _vwp1
   ?(_ri >= 2) && (_ri < 3) :_uwp = _vwp2
   ?(_ri >= 3) && (_ri <= 4) :_uwp = _vwp3

Something like that anyway........it's late   ::)


Planck

Thanks, that worked well. I forgot to check which way the signs were pointing. Always something small like that when I can't fix something.

Anyways, I only have one more error and that is the _pos variable.

Its supposed to be the position of the gamelogic +/- a random number between 140 and 0 for both X and Y, to create a circular bombardment effect. However, I can't set the arrays properly.

From what I understand, you set arrays by
Code: [Select]
_array = [0,0,0]
_array set [0,_X]
_array set [1,_Y]
_array set [2,_Z]

However, this returns the 'scalar bool' error when I try to use it along with camcreate in the above script. Is there some other way to set an array with  3 variables?

Offline Planck

  • Honoured
  • Former Staff
  • ****
  • I'm never wrong ....I'm just not always right !
Re:Script "Scalar Bool" Error
« Reply #8 on: 03 Jul 2005, 01:30:09 »
Try defining _pos as an array at the beginning of the script.

_pos = []

I think that s right, as I said before .....it's late, I really should go to bed.



Planck
I know a little about a lot, and a lot about a little.

Offline THobson

  • OFPEC Patron
  • Former Staff
  • ****
Re:Script "Scalar Bool" Error
« Reply #9 on: 03 Jul 2005, 08:55:23 »
Well Planck it looks like being first and being right is not enough, and even when I give the guy some code that will work with any number of shells without creating a whole new set of variables he just ignores it! >:(