Home   Help Search Login Register  

Author Topic: ExclusiveOr script not working, Why?  (Read 1132 times)

0 Members and 1 Guest are viewing this topic.

Greybelly

  • Guest
ExclusiveOr script not working, Why?
« on: 09 Dec 2002, 15:42:05 »
Hi All,

I'm new at scripting, but I jumped right in.  It didn't work though.  Does anyone know why?  Any help would be appriciated.

; ***************************************
; Operation Flashpoint Script "ExclusiveOR"
; Example script call
; [Flag1,10,Flag2,10,Flag3,20,Flag4,15,Flag5,5] exec "ExclusiveOR.sqs"
; This means :
; Flag1 has a 10% chance of being set.  
; Flag2 has a 10% chance of being set.
; Flag3 has a 20% chance of being set.  
; Flag4 has a 15% chance of being set.  
; Flag5 has a  5% chance of being set.  
; There is a  40% chance of nothing being set
; ***************************************
; Read in parameters
; ***************************************
_Flag01 = _this select 0
_Prob01 = _this select 1
_Flag02 = _this select 2
_Prob02 = _this select 3
_Flag03 = _this select 4
_Prob03 = _this select 5
_Flag04 = _this select 6
_Prob04 = _this select 7
_Flag05 = _this select 8
_Prob05 = _this select 9
; ***************************************
; Initialise flags and variables
; ***************************************
_Flag01 = false
_Flag02 = false
_Flag03 = false
_Flag04 = false
_Flag05 = false
_TotProb = _Prob01
; ***************************************
; Roll the die and set THE flag
; ***************************************
_Die = Random 100
? _Die < _TotProb : _Flag01 = true; exit
_TotProb = _TotProb + _Prob02
? _Die < _TotProb : _Flag02 = true; exit
_TotProb = _TotProb + _Prob03
? _Die < _TotProb : _Flag03 = true; exit
_TotProb = _TotProb + _Prob04
? _Die < _TotProb : _Flag04 = true; exit
_TotProb = _TotProb + _Prob05
? _Die < _TotProb : _Flag05 = true; exit
; ***************************************




Bye for now.

Offline Ottie

  • Members
  • *
  • And you think this is personal
Re:ExclusiveOr script not working, Why?
« Reply #1 on: 09 Dec 2002, 18:25:15 »
What is the meaning of the script ???

First you initialise _Flag01 with the object Flag1 and later you set _Flag01 to FALSE, and if it met the condition you set it to TRUE, so why do you initialise it with Flag1 in the beginning of the script.

Please explain.
If you can't beat them, buy them

Greybelly

  • Guest
Re:ExclusiveOr script not working, Why?
« Reply #2 on: 10 Dec 2002, 15:47:23 »
Hi,

I'm trying to set the variables that are passed in as parameters to the script.  Is "this select 0" the only way of referencing the first parameter?  I  tried the following and it didn't work either.

; ***************************************
; Operation Flashpoint Script "ExclusiveOR"
; Example script call
; [Flag1,10,Flag2,10,Flag3,20,Flag4,15,Flag5,5] exec "ExclusiveOR.sqs"
; This means :
; Flag1 has a 10% chance of being set.  
; Flag2 has a 10% chance of being set.
; Flag3 has a 20% chance of being set.  
; Flag4 has a 15% chance of being set.  
; Flag5 has a  5% chance of being set.  
; There is a  40% chance of nothing being set
; ***************************************
; Initialise flags and variables
; ***************************************
_this select 0 = false
_this select 2 = false
_this select 4 = false
_this select 6 = false
_this select 8 = false
; ***************************************
; Roll the die and set THE flag
; ***************************************
_Die = Random 100
_TotProb = (_this select 1)
? (_Die < _TotProb) : (_this select 0) = true; exit
_TotProb = _TotProb + (_this select 3)
? (_Die < _TotProb) : (_this select 2) = true; exit
_TotProb = _TotProb + (_this select 5)
? (_Die < _TotProb) : (_this select 4) = true; exit
_TotProb = _TotProb + (_this select 7)
? (_Die < _TotProb) : (_this select 6) = true; exit
_TotProb = _TotProb + (_this select 9)
? (_Die < _TotProb) : (_this select 8) = true; exit




Bye for now.
« Last Edit: 10 Dec 2002, 15:58:34 by Greybelly »

Greybelly

  • Guest
Re:ExclusiveOr script not working, Why?
« Reply #3 on: 10 Dec 2002, 16:00:17 »
No, I don't know why eight followed by right hand curved bracket turns into a cool smilie!

8)
« Last Edit: 10 Dec 2002, 16:01:15 by Greybelly »

Offline Ottie

  • Members
  • *
  • And you think this is personal
Re:ExclusiveOr script not working, Why?
« Reply #4 on: 10 Dec 2002, 16:28:08 »
Í think I know what you want to do:

; ***************************************
; Operation Flashpoint Script "ExclusiveOR"
; Example script call
; [Flag1,10,Flag2,10,Flag3,20,Flag4,15,Flag5,5] exec "ExclusiveOR.sqs"
; This means :
; Flag1 has a 10% chance of being set.  
; Flag2 has a 10% chance of being set.
; Flag3 has a 20% chance of being set.  
; Flag4 has a 15% chance of being set.  
; Flag5 has a  5% chance of being set.  
; There is a  40% chance of nothing being set
; ***************************************
; Initialise flags and variables
; ***************************************
; ***************************************
; Roll the die and set THE flag
; ***************************************
_Die = Random 100
_TotProb = (_this select 1)
? (_Die < _TotProb) : Flag1 = true; exit
_TotProb = _TotProb + (_this select 3)
? (_Die < _TotProb) : Flag2 = true; exit
_TotProb = _TotProb + (_this select 5)
? (_Die < _TotProb) : Flag3 = true; exit
_TotProb = _TotProb + (_this select 7)
? (_Die < _TotProb) : Flag4 = true; exit
_TotProb = _TotProb + (_this select 9)
? (_Die < _TotProb) : Flag5  = true; exit
If you can't beat them, buy them

Greybelly

  • Guest
Re:ExclusiveOr script not working, Why?
« Reply #5 on: 10 Dec 2002, 16:57:29 »
No, I don't want a hard coded reference to Flag1, Flag2 . . . etc.  The script might be executed differently the next time it's used. For example

[Boolean1,20,Boolean2,15,Boolean3,25,Boolean4,5,Boolean5,5] exec "ExclusiveOR.sqs"

Your suggestion would ignore Boolean1, Boolean2, Boolean3, Boolean4 and Boolean5.  It may also reset Flag1 thru Flag5, when you didn't want them changed.  In your example how does Flag1 thru Flag5 get initialised to False?

Bye for now.

Offline Ottie

  • Members
  • *
  • And you think this is personal
Re:ExclusiveOr script not working, Why?
« Reply #6 on: 10 Dec 2002, 18:09:04 »
Your solution is also not working, you can't refer to a global variable through a local variable and use it in the global data space, its not working like pointers (I think that is what you want to do).

May there is a solution with the new commands and using the preprocess functions, but I haven't looked to that yet.

You can initialise your flag values via a init.sqs file.

If you can't beat them, buy them