Home   Help Search Login Register  

Author Topic: Passing variables to scripts, variable types  (Read 552 times)

0 Members and 1 Guest are viewing this topic.

Sundog

  • Guest
Passing variables to scripts, variable types
« on: 01 Aug 2003, 01:41:58 »
Hi:

Another Noob question


I understand that I pass variables to my scipts using the call in the on activation box of a trigger

I understand that the call should be in the format:

[var1,var2,var3,...] exec "scriptname.sqs"

I'm just having a little trouble figuring out how to assign those values to variables within the script.  I this it's done like this

scriptvar1 = this select 0 ; for var1
scriptvar2 = this select 1 ; for var 2

I understand that I can make the variable global or local by using the _ before the name.

I'm having some trouble with variable types.

The script:

;THis script tells a unit to go to one of four compass points when given a radio command
;the call for this script should read "[unit,wpname] exec wp.sys

;these two lines seed data from the call statement into the variables that the script uses

_unit=_this select 0
_wpname=_this select 1


_unit commandmove getmarkerpos _wpname

#end


Which I was using to try and move a unit to a gamelogic field called wpn keeps returning the error:

'unit commandmove getmarkerpos _wpname |#|':Error getmarkerpos: type Object,expected string

help

Offline macguba

  • Former Staff
  • ****
    • macguba's operation flashpoint page
Re:Passing variables to scripts, variable types
« Reply #1 on: 01 Aug 2003, 02:06:01 »
getMarkerPos returns the position of a marker.     You must put the name of the marker in quotes like this " ".    Sometimes you can use curly brackets { } instead of quotes.

In your line of code the game is expecting a markername in quotes after the command getMarkerPos.   However, it knows it isn't getting that and suspects it is being given an object.  Consequently it doesn't know what to do and gives up.   Even if _wpname is returning a marker name (and it doesn't look like it) it should still be in quotes.

I suspect you want getPos or getWPPos instead of getMarkerPos.   Check the syntax in the official command reference, preferably the online  version available in the Ed Depot.
Plenty of reviewed ArmA missions for you to play

Sundog

  • Guest
Re:Passing variables to scripts, variable types
« Reply #2 on: 01 Aug 2003, 02:19:41 »
if I am seeding the varibles right... and I'm not sure that I am,

[unit,wpn] exec "wp.sqs"

wpn is the name of a gamelogic object unit

unit is the name of a unit (soldier)

do I need to getmarkerpos to move the unit or can I just move it to the marker name?

Offline macguba

  • Former Staff
  • ****
    • macguba's operation flashpoint page
Re:Passing variables to scripts, variable types
« Reply #3 on: 01 Aug 2003, 02:34:13 »
I'm not a scripting guru but on the face of it you are passing the variables correctly.    However, gamelogics and markers are two different species.    

It seems to me that you are tryig to order the unit to move to the position of the gamelogic.   Try:

_unit commandMove (or doMove) getPos _wpname

If _wpname was a marker instead of a GL it would be

_unit commandMove getMarkerPos "_wpname"

If you're worried about passing the variables make the script work with actual unit names:-

loon1 doMove getPos gameLogic_1

and once you know the body of the script is OK add back the variable passing part.    

Plenty of reviewed ArmA missions for you to play

Sundog

  • Guest
Re:Passing variables to scripts, variable types
« Reply #4 on: 01 Aug 2003, 03:16:32 »
YYEESSS!!

Now a new question ... the whole point of this script is to allow me to direct a metered response to a designated listening post if the enemy is detected.  Since I have only one response squad and thre lp's I had to be able to send the squad to the lp the detection occured at.  Will I be able to use If Then structures in scripting?  This would allow me to have the squad patrol the area for a designated amount of cycles before returning to the base?

david

Offline macguba

  • Former Staff
  • ****
    • macguba's operation flashpoint page
Re:Passing variables to scripts, variable types
« Reply #5 on: 01 Aug 2003, 13:52:24 »
 :)

Yes you can use if-then structures in scripting.     There is now an if command, which is relatively new, but the conventional way of doing it in a script is this:

? condition: command

if the condition is true the command is executed.  If it is false the script moves onto the next line.   See "Scripting topics" in the command reference for more info.

You may also be able to achieve what you want by using waypoints and switch triggers.   If you're not familiar with switch triggers - which are one of the most useful, simple and powerful tools in mission editing - checkout the specific tute in the Ed Depot.   They are also covered in the good general tutes and there's plenty of posts in the forums too.
Plenty of reviewed ArmA missions for you to play