Home   Help Search Login Register  

Author Topic: My Scripting Thread  (Read 3220 times)

0 Members and 1 Guest are viewing this topic.

Javito

  • Guest
My Scripting Thread
« on: 13 Aug 2006, 09:15:50 »
I'm having trouble actually having the units do commands in a script. I can do this stuff using triggers easily enough but for some reason I'm having more difficulty while writing a script. Right now a character, Molders, is driving the player to a specifided dropoff point (a game logic in this case). What I want is for Molders to stop the motorcycle and disembark on the condition that  the bike is 10 meters away from the dropoff. So I have this...

?(bike distance dropoff < 10) : [Molders] ordergetin false

Now I'm sure this is -completely- wrong but go easy on me, I just started studying this stuff two hours ago. Also, I'd like to know where the line between script and in game triggers ends. I know that a script ingame will begin with [] exec "script.sqs", but what about when the script ends? Like, what if I want a unit to go somewhere or say something just after a script ends? What would you put in the condition field? Or is this irrelevant because whatever action i could possibly want to achieve could just as well be accomplished with a script?


ps. Appreciate the reply to my earlier question, I actually was able to get that problem to work. For some reason it was just not accepting my commands, yet when I copied and pasted them from a different source it worked even though they didn't change at all. Quite strange. Anyway, the question I've edited the post with is the one that's giving me the real trouble right now.
« Last Edit: 13 Aug 2006, 10:13:28 by Javito1986 »

Offline THobson

  • OFPEC Patron
  • Former Staff
  • ****
Re: My Scripting Thread
« Reply #1 on: 13 Aug 2006, 10:08:52 »
Try assigning Molders as the driver of the bike before orderGetIn true

Molders assignAsDriver bikename
[Molders] OrderGetIn true

See: http://community.bistudio.com/wiki/assignAsDriver

Offline XCess

  • Former Staff
  • ****
Re: My Scripting Thread
« Reply #2 on: 13 Aug 2006, 10:47:36 »
Also, the IF command, also shown as ?, will only run everytime the script goes past that line, the script will NOT wait at that line until the conditions are met. You have a choice here, you could use a @ to make the script wait until the condition is met, or a short loop. e.g.

@(bike distance dropoff < 10)
[Molders] orderGetIn false

or

#loop
?(bike distance dropoff < 10) : [Molders] orderGetIn false
~0.1
goto"loop"

Offline bedges

  • Administrator
  • *****
    • OFPEC The Editing Center
Re: My Scripting Thread
« Reply #3 on: 13 Aug 2006, 10:48:25 »
alternatively see assignasdriver in our very own COMREF.
« Last Edit: 13 Aug 2006, 15:12:28 by bedges »

Offline THobson

  • OFPEC Patron
  • Former Staff
  • ****
Re: My Scripting Thread
« Reply #4 on: 13 Aug 2006, 15:06:21 »
Did I misread it or did you edit the question after I answered it?  I thought you had
[Molders] ordergetin true

Anyway I now see you have him on the bike and you want him to get out.  To do this use the instruction

unassignVehicle Molders

See (our very own): http://www.ofpec.com/COMREF/index.php?action=list&letter=t#unassignVehicle

If you use this method of getting the orignal crew of a vehicle to disembark then you will also need to use the allowGetIn false  instruction to prevent them getting back in:
http://www.ofpec.com/COMREF/index.php?action=list&letter=a#allowGetIn

Javito

  • Guest
Re: My Scripting Thread
« Reply #5 on: 13 Aug 2006, 17:37:12 »
That worked, thanks guys. Can't say enough how much help you all have been since I got into mission editing last week.

Got a question about this loop.

#loop
?(bike distance dropoff < 10) : [Molders] orderGetIn false
~0.1
goto"loop"



I can get it to work fine, I'm just curious how I can get the script to continue after that loop has been completed? I tried adding some cuttext after that line and I'm afraid nothing happened.

Offline myke13021

  • Contributing Member
  • **
  • Myke
Re: My Scripting Thread
« Reply #6 on: 13 Aug 2006, 17:54:04 »
well, there's no exit point for that loop. better work with this if u insist to use a loop:

Code: [Select]
#loop
?(bike distance dropoff < 10: goto "continue"
~0.1
goto "loop"

#continue
[Molders] ordergetin false
...
..
.

Javito

  • Guest
Re: My Scripting Thread
« Reply #7 on: 13 Aug 2006, 21:41:58 »
Okay, thanks all. Been making some good progress on all this. I have two new questions, both probably very basic. One, when you're writing cuttext what's the key to make it start a new line in game so that the text doesn't run off screen? I remember there was one, but since the last time I used it was three years ago... well, you know.

Secondly, I've taken a cue from other scripts and tried combining two of mine. I have one titled "Init.sqs" and another titled "Briefing.sqs". So at the end of Init I put in ["Init"] exec "Briefing.sqs" and at the beginning of briefing.sqs I have #Init. Only that didn't seem to work very well, and by that I mean it didn't work at all. Am I doing it wrong?

Offline Seven

  • Members
  • *
  • Am I a llama?
Re: My Scripting Thread
« Reply #8 on: 14 Aug 2006, 02:47:21 »
1) 1stline\n2ndline
would result in:
Code: [Select]
1stline
2ndline

So for example:
hint "Go and kill them all Rambo\nLet none survive"

Result:
Code: [Select]
Go and kill them all Rambo
Let none survive

I've never seen a briefing.sqs; what does it do?
Usually this is reserverd for an .htm(l) file which pops up before the mission begins in MP or when you press ? or m in SP

Javito

  • Guest
Re: My Scripting Thread
« Reply #9 on: 14 Aug 2006, 02:50:50 »
Briefing.sqs isn't anything special, it's just the name for a script I created because the "briefing" in the mission in question actually occurs in-mission.

Offline bedges

  • Administrator
  • *****
    • OFPEC The Editing Center
Re: My Scripting Thread
« Reply #10 on: 14 Aug 2006, 09:03:32 »
when you run a script you can pass variables and parameters to it. so for example, when you type

Code: [Select]
["Init"] exec "Briefing.sqs"
the script Briefing.sqs is able to pick up the string variable "Init". the way that you get at this variable is typing

Code: [Select]
_variable_name = _this select 0
at the top of the script. if you wanted to pass multiple parameters to the script, you'd call it thus

Code: [Select]
["init", 1, 2, "three", unit_name] exec "briefing.sqs"
and pick up the paramaters using

Code: [Select]
_variable_name1 = _this select 0
_variable_name2 = _this select 1
_variable_name3 = _this select 2
_variable_name4 = _this select 3
_variable_name5 = _this select 4

note that the parameters are passed to the script in an array, so the first element id is 0, then 1, 2, 3 etc.

so. putting #init in the script will not do anything, other than create a loop marker. if in your script you were to type

Code: [Select]
goto "init"
the script would jump the the #init marker and begin processing the commands from that point.

if you want this to happen, at the top of your script type

Code: [Select]
_jump_marker = _this select 0
goto _jump_marker

call the script using your ["init"] exec "briefing.sqs" with the #init marker still in place and see what happens.

Javito

  • Guest
Re: My Scripting Thread
« Reply #11 on: 14 Aug 2006, 09:14:38 »
Ah ha. Well that explains a lot Bedges. Thank you.

Got a question about a different scripting problem (sorry for so many, but that's why I created my own thread  :) ). Here's the situation, without revealing any spoilers since I intend to publicize this sometime. Essentially, bomb goes off and I want there to be an open ended result. A character may die, a character may be wounded, they may both survive, etc. So what I've done is this... ( not representative of actual in-game dialogue  ;) )

cuttext ["Butthead: Look out Beavis she's packing heat!" , "PLAIN DOWN"]
~1
name = "heat73" camcreate getpos CrazyLady
~4
cuttext ["Ahh it tastes like burning" , "PLAY DOWN"]
~7
? (not(alive r5)) : cuttext ["Oh my god they killed r5!" , "PLAY DOWN"]
? (alive r5) : cuttext ["R5 is hurt!" , "PLAY DOWN"]
? (not(alive r5)) and (not(alive Beavis)) : cuttext ["R5 and Beavis are dead!" , "PLAY DOWN"]



Only for some reason it didn't work and -none- of the variables resulted.

« Last Edit: 14 Aug 2006, 09:16:17 by Javito1986 »

Offline macguba

  • Former Staff
  • ****
    • macguba's operation flashpoint page
Re: My Scripting Thread
« Reply #12 on: 14 Aug 2006, 09:18:12 »
Check that you have named the characters correctly.

When something doesn't work its often a good idea to create a test missionette with just the relevant bits.   Then its very easy to see what's going on.  Or not going on, as the case may be.  ;D
Plenty of reviewed ArmA missions for you to play

Offline bedges

  • Administrator
  • *****
    • OFPEC The Editing Center
Re: My Scripting Thread
« Reply #13 on: 14 Aug 2006, 09:20:53 »
if that's copy pasted from your script, the reason it doesn't work is because "play down" isn't a recognised command.

it's "plain down". ;)

Javito

  • Guest
Re: My Scripting Thread
« Reply #14 on: 14 Aug 2006, 10:30:33 »
Oh jeez, you're right of course. Wow, now I feel silly. When you spend such a long time typing these scripts up eventually your mind gets fuzzy. Now I gotta go back and look at all my scripts, make sure there's no "playmove 'orderGetin'" or other silly screw ups. No wonder it didn't work. :-)