Home   Help Search Login Register  

Author Topic: Help fixing bugs in my script (3 probs)  (Read 1188 times)

0 Members and 1 Guest are viewing this topic.

Offline Arctic

  • Members
  • *
  • In Utero
Help fixing bugs in my script (3 probs)
« on: 30 Nov 2002, 15:33:48 »
All right... these are sort of easy :'Error Generic' and 'Error expected Object' problems. They are just annoying my like crazy because I can't figure out how to get rid of them.

tgtX = (Random 2)
I have a # mark on the 'tgtX =(# 2)'

?(_tgtX distance Airplane =< 15):Airplane sidechat "10 seconds until release"; goto "Release"
the # mark is in between the < and the 15 and it says it is expecting an object. Why this doesnt work, i have no clue. I practically copied the code format from the Script Commands pages!  >:( >:( >:( >:(

"SHELL120" CamCreate [_tX - 1.5, _tY, _tZ - (random 5)]
the # is: "SHELL120" CamCreate [_tX - 1.5, _tY, _tZ - (random 5)]# Error generic error in expression

Help!!

Bremmer

  • Guest
Re:Help fixing bugs in my script (3 probs)
« Reply #1 on: 01 Dec 2002, 00:02:16 »
Can you post the full script text Arctic?
Problems like these often arise not in the line that generates the error, but elsewhere (eg if you have defined a variable as a local variable, then tried to use it as a global one, missing out the _). Copy and paste directly into the thread if possible to aviod introducing any changes from your script.

The second error certainly looks like a simple mistake - you have used =< instead of <= (say it out loud to get the hang of it 'less than or equal too' not 'equal too or less than).

For the third error try giving the camcreated shell a name. eg
_bomb = "SHELL120" CamCreate [_tX - 1.5, _tY, _tZ - (random 5)]

Cheers

Offline Arctic

  • Members
  • *
  • In Utero
Re:Help fixing bugs in my script (3 probs)
« Reply #2 on: 01 Dec 2002, 06:06:25 »
Code: [Select]
;Riverbomb,sqs
;Drops bombs on a target

_Airplane = _this select 0
_Tgt1 = _this select 1
_Tgt2 = _this select 2
_tgt3 = _this select 3

;##NOTE##
;Target cannot be an array

#WinchesterLoop
_Winchester = 3
goto "Target"

#Target
tgtX = (Random 2)
?(tgtX = 0): Airplane domove getpos Tgt1
?(tgtX = 1): Airplane domove getpos Tgt2
?(tgtX = 2): Airplane domove getpos Tgt3

~1
Airplane sidechat "Target in sight. In hot."

~0.8
goto "Distance"

#Distance
?(_tgtX distance Airplane =< 15):Airplane sidechat "10 seconds until release"; goto "Release"
?(_tgtX distance Airplane > 15):goto "Distance"

#Release
_tX = getpos Target select 0
_tY = getpos Target select 1
_tZ = getpos Airplane select 2

~9.5
"SHELL120" CamCreate [_tX - 1.5, _tY, _tZ - (random 5)]
"SHELL120" CamCreate [_tX + 1.5, _tY, _tZ - (random 5)]
~0.05
"SHELL120"  CamCreate [(_tX - 1.5), _tY + ((random 15) - (random 15)),_tZ - (random 5)];
"SHELL120" CamCreate [(_tX + 1.5), _tY + ((random 15) - (random 15)),_tZ - (random 5)];

~2.5
Airplane sidechat "Shack!"

~0.05
_Winchester = _Winchester - 1
goto "Relocate"

#Relocate
Airplane domove getpos _bPoint
~3

?(Winchester = 0):Airplane sidechat "Flight is Winchester. I'm is heading home."; exit
goto "Target"

That's my script. Its a little chunky, but that is because I am still a beginning scripter.



Offline toadlife

  • OFPEC Old Skool
  • Former Staff
  • ****
  • Official OFP Editing Center Toad
    • toadlife.net
Re:Help fixing bugs in my script (3 probs)
« Reply #3 on: 01 Dec 2002, 12:30:23 »
Code: [Select]
#Target
tgtX = (Random 2)
?(tgtX = 0): Airplane domove getpos Tgt1
?(tgtX = 1): Airplane domove getpos Tgt2
?(tgtX = 2): Airplane domove getpos Tgt3

1) Random doesnt create whole numbers, so the chance of the number being 0 1 or 2 are like 1 in 10000.

2) There is some bad syntax there "=" should be "=="

3) "airplane" is defined as "_airplane" at the top of the script.

4) "Tgt1", "Tgt2" and "Tgt3" are defined as "_Tgt1","_Tgt2","_Tgt3" at the top of the script.

Here is how to make this section correct syntax-wise.

Code: [Select]
#Target
tgtX = (Random 2)
?(tgtX < 1): _Airplane domove getpos _Tgt1;goto "continue"
?(tgtX < 2 && tgtX > 1): _Airplane domove getpos _Tgt2;goto "continue"
 _Airplane domove getpos _Tgt3

#continue

Code: [Select]
#Distance
?(_tgtX distance Airplane =< 15):Airplane sidechat "10 seconds until release"; goto "Release"
?(_tgtX distance Airplane > 15):goto "Distance"

Right here is where things really get muckered up. "_tgtX" is a number, not any object. You can't measure the distance between a number and an object - only two objects.

Code: [Select]
#Release
_tX = getpos Target select 0
_tY = getpos Target select 1
_tZ = getpos Airplane select 2

I dont see "Target" defined anywhere is the script. This would cause an error too. You need to define what "target" is.


As it is this script almost needs to be rewritten completly. You seem to be on the right track. I have to sleep now. Please post back and we will try and help you along tomorrow. :)
« Last Edit: 01 Dec 2002, 12:33:32 by toadlife »
"Whenever you want information on the 'net, don't ask a question; just post a wrong answer." -- Cancer Omega.

Offline Arctic

  • Members
  • *
  • In Utero
Re:Help fixing bugs in my script (3 probs)
« Reply #4 on: 01 Dec 2002, 17:17:38 »
All right. I've tried cleaning up the script some. And, now the aircraft actually travels to the random target. I get two errors this time the CamCreate error and something about the _tgtM.

Code: [Select]
;Bombing.sqs

_Airplane = _this select 0
_tgt1 = _this select 1
_tgt2 = _this select 2
_tgt3 = _this select 3
_Winchester = 3

#Target
tgtX = (Random 2)
?(tgtX < 1): _Airplane domove getpos _Tgt1;goto "continue"
?(tgtX < 2 && tgtX > 1): _Airplane domove getpos _Tgt2;goto "continue"
_Airplane domove getpos _Tgt3

#continue
~1
_Airplane sidechat "Target in sight. In hot."
goto "Distance"

#Distance
_tgtM getpos setpos tgtX

~0.5
_tX = getpos tgtM select 0
_tY = getpos tgtM select 1
_tZ = getpos Airplane select 2

~9.5
"SHELL120" CamCreate [_tX - 1.5, _tY, _tZ - (random 5)]
"SHELL120" CamCreate [_tX + 1.5, _tY, _tZ - (random 5)]
~0.05
"SHELL120"  CamCreate [(_tX - 1.5), _tY + ((random 15) - (random 15)),_tZ - (random 5)]
"SHELL120" CamCreate [(_tX + 1.5), _tY + ((random 15) - (random 15)),_tZ - (random 5)]

~2.5
Airplane sidechat "Shack!"

~0.05
_Winchester = _Winchester - 1
goto "Relocate"

#Relocate
Airplane domove getpos _bPoint
~3

?(Winchester <= 0):Airplane sidechat "Flight is Winchester. I'm is heading home."; exit
goto "Target"


Errors recieved:

1.) _tgtM getpos setpos tgtX: Error expected object
Would it work if I took out the setpos?

2.)"SHELL120" CamCreate [_tX - 1.5, _tY, _tZ - (random 5)]#
That one is an error generic error problem.

And 1 minor question: How do I keep the aircraft saying "Target in sight. In hot." only once and not multiple times?

Thanks!

Offline Arctic

  • Members
  • *
  • In Utero
Re:Help fixing bugs in my script (3 probs)
« Reply #5 on: 02 Dec 2002, 00:21:49 »
All right! I feel like I actually did something right! I got the _tgtX number error to go away! I also got the CamCreate thing to work go error-free, but the shells aren't appearing. I have a feeling it is because the x and y coords are off.

I need some help figuring out this CamCreate "Shell120" thing.
This is my goal for the this command. I want to shells to be dropped off into coloumns/lines over the target.
It'd sort of be like this:

||
||

Here's the updated script:
Code: [Select]
;Bombing.sqs

_Airplane = _this select 0
_tgt1 = _this select 1
_tgt2 = _this select 2
_tgt3 = _this select 3
_Winchester = 3

#Target
tgtX = (Random 2)
?(tgtX < 1): _Airplane domove getpos _Tgt1; _tgt1 = _tgtM; goto "continue"
?(tgtX < 2 && tgtX > 1): _Airplane domove getpos _Tgt2; _tgt2 = _tgtM; goto "continue"
_Airplane domove getpos _Tgt3; _tgt3 = _tgtM;

#continue
_Airplane flyinheight 35

~1
_Airplane Speedmode "normal"

_Airplane sidechat "Target in sight. In hot."
goto "Distance"

#Distance
?(_Airplane distance _tgtM <= 15): goto "Release"
goto "Distance"

#Release"
~0.5
_tX = getpos _tgtM select 0
_tY = getpos _tgtM select 1
_tZ = getpos Airplane select 2

_Airplane Speedmode "LIMITED"

~9.5
"SHELL120" CamCreate [_tX - 1.5, _tY + 0, _tZ - (random 5)]
"SHELL120" CamCreate [_tX + 1.5, _tY + 0, _tZ - (random 5)]
~0.05
"SHELL120"  CamCreate [(_tX - 1.5), _tY + ((random 15) - (random 15)),_tZ - (random 5)]
"SHELL120" CamCreate [(_tX + 1.5), _tY + ((random 15) - (random 15)),_tZ - (random 5)]

~2.5
Airplane sidechat "Shack!"

~0.05
_Winchester = _Winchester - 1
goto "Relocate"

#Relocate
Airplane domove getpos _bPoint
~3

?(Winchester <= 0):Airplane sidechat "Flight is Winchester. I'm is heading home."; exit
goto "Target"


Offline MI_Fred

  • Members
  • *
  • AA
    • OFP Team Finlanders
Re:Help fixing bugs in my script (3 probs)
« Reply #6 on: 02 Dec 2002, 02:07:56 »
2.)"SHELL120" CamCreate [_tX - 1.5, _tY, _tZ - (random 5)]#
That one is an error generic error problem.

And 1 minor question: How do I keep the aircraft saying "Target in sight. In hot." only once and not multiple times?

Thanks!
As Toadie said above you need to give a camCreated object a name. Any name, or a doodle of letters  ;)
diorrhea = "SHELL120" CamCreate [_tX - 1.5, _tY, _tZ - (random 5)]
I'd like to know what your using that you pass into the script as _tgt1, _tgt2 and _tgt3. Can't see any prob with them showing up immediately.

The reason why that radio message repeats is because it's inside a loop. If you can't put it before the #target then use a variable to determine if it has been radioed. as in defining a variable at the top of the script:
_seentgt = false

then the line in the script would be :
? (! _seentgt) : _Airplane sidechat "Target in sight. In hot."; _seentgt = true

So it will be radioed as long as _seentgt is false, which is not true after it has been once radioed. Doesn't look logical, not seen target blaa blaa blaa ( ;D) but trust me it oughta work.
« Last Edit: 02 Dec 2002, 02:14:26 by MI_Fred »
There's gooks over there, there's mines over there, and watch out those goddamn monkeys talk, I'll bite ya.

Offline Arctic

  • Members
  • *
  • In Utero
Re:Help fixing bugs in my script (3 probs)
« Reply #7 on: 02 Dec 2002, 03:46:17 »
The mission is below. BTW, the script I am using for the bomb is called Bomb.sqs Riverday
« Last Edit: 02 Dec 2002, 03:58:50 by Arctic »

Bremmer

  • Guest
Re:Help fixing bugs in my script (3 probs)
« Reply #8 on: 02 Dec 2002, 11:00:37 »
I think your main problem is that you haven't defined the target properly - look at this script fragment (you have the same problem in the two following lines as well):

_tgt1 = _tgtM

This redefines _tgt1 as _tgtM (which at the time is undefined), when what you want to do is the opposite:

_tgtM = _tgt1

As MI-Fred (an myself) mentioned above, you must name camcreated objects. You also appear to be using another undefined variable (_bPoint)

Cheers

Offline Arctic

  • Members
  • *
  • In Utero
Re:Help fixing bugs in my script (3 probs)
« Reply #9 on: 02 Dec 2002, 22:19:41 »
Ok... I think I get it now.

Should I say that _tgtM or _tgtX = the CamCreated shell?

so it'd be either:

_tgtM = "SHELL120" CamCreate [0,0,0]

-or-

_tgtX = "SHELL120" CamCreate [0,0,0]

right? but if it worked, it wouldn't work for all of the shells. Right?
---

Also, I used _bPoint as the point where the bomber (_Airplane) would go after the target was bombed. All it is is a gamelogic. Should I put it up as:

_bPoint = _this select 4

?

 

Offline Arctic

  • Members
  • *
  • In Utero
Re:Help fixing bugs in my script (3 probs)
« Reply #10 on: 02 Dec 2002, 23:28:59 »
Doesn't work  >:(

Updated Script:
Code: [Select]
;Bombing.sqs

_Airplane = _this select 0
_tgt1 = _this select 1
_tgt2 = _this select 2
_tgt3 = _this select 3
_Winchester = 3

#Target
tgtX = (Random 2)
?(tgtX < 1): _Airplane domove getpos _Tgt1; _tgt1 = _tgtM; goto "continue"
?(tgtX < 2 && tgtX > 1): _Airplane domove getpos _Tgt2; _tgt2 = _tgtM; goto "continue"
_Airplane domove getpos _Tgt3; _tgt3 = _tgtM;

#continue
_Airplane flyinheight 35

~1
_Airplane setspeedmode "normal"

_Airplane sidechat "Target in sight. In hot."
goto "Distance"

#Distance
?(_Airplane distance _tgtM <= 15): goto "Release"
goto "Distance"

#Release"
~0.5
_bomb = getpos _tgtX select 0
_tX = getpos _bomb select 0
_tY = getpos _bomb select 1
_tZ = getpos _Airplane select 2

_Airplane setspeedmode "LIMITED"

~9.5

_bomb = "SHELL120" CamCreate [_tX - 1.5,_tY,_tZ - (random 5)]
_bomb = "SHELL120" CamCreate [_tX + 1.5,_tY,_tZ - (random 5)]
~0.05
_bomb = "SHELL120"  CamCreate [(_tX - 1.5),_tY + ((random 15) - (random 15)),_tZ - (random 5)]
_bomb = "SHELL120" CamCreate [(_tX + 1.5),_tY + ((random 15) - (random 15)),_tZ - (random 5)]

~2.5
_Airplane sidechat "Shack!"

~0.05
_Winchester = _Winchester - 1
goto "Relocate"

#Relocate
_Airplane domove getpos _bPoint
~3

?(Winchester <= 0):_Airplane sidechat "Flight is Winchester. I'm is heading home."; exit
goto "Target"

Maybe after this script gets completed successfully, I can begin making cleaner scripts  ::) . Arg... this script is going to take forever to finish.

Bremmer

  • Guest
Re:Help fixing bugs in my script (3 probs)
« Reply #11 on: 02 Dec 2002, 23:41:03 »
We're trying to help, but you need to read the advise we're giving you:

Quote
I think your main problem is that you haven't defined the target properly - look at this script fragment (you have the same problem in the two following lines as well):

_tgt1 = _tgtM

This redefines _tgt1 as _tgtM (which at the time is undefined), when what you want to do is the opposite:

_tgtM = _tgt1

Also add this at the top of your script, and pass the gamelogic name to the script in the execution array:

_logic = _this select 4
_bpoint = getpos _logic

NB. the execution line should look like :

[planename,target1name,target2name,target3name,logicname] exec "yourscript.sqs"

Your sooooo close  ;)

Offline MI_Fred

  • Members
  • *
  • AA
    • OFP Team Finlanders
Re:Help fixing bugs in my script (3 probs)
« Reply #12 on: 03 Dec 2002, 00:38:33 »
We're trying to help, but you need to read the advise we're giving you:

O  :o Bremmer oh, or then he just needs to be spoiled rotten.  ;D

I found some typos, 1 glitch, 1 irrationality... nothing that'll stop you from learning. There's notes of them in the script. If you haven't changed anything in the editor, it'll work. It worked for me, looks nice  :)
There's gooks over there, there's mines over there, and watch out those goddamn monkeys talk, I'll bite ya.

Offline Arctic

  • Members
  • *
  • In Utero
Re:Help fixing bugs in my script (3 probs)
« Reply #13 on: 03 Dec 2002, 01:18:38 »
Thanks! The notes helped explain a whole lot of stuff!  :D

I have to do homework now, but i will try out your attached script by tomorrow.