OFPEC Forum
Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: Javito 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.
-
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
-
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"
-
alternatively see assignasdriver (http://www.ofpec.com/COMREF/index.php?action=list&letter=a#assignAsDriver) in our very own COMREF.
-
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
-
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.
-
well, there's no exit point for that loop. better work with this if u insist to use a loop:
#loop
?(bike distance dropoff < 10: goto "continue"
~0.1
goto "loop"
#continue
[Molders] ordergetin false
...
..
.
-
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?
-
1) 1stline\n2ndline
would result in:
1stline
2ndline
So for example:
hint "Go and kill them all Rambo\nLet none survive"
Result:
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
-
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.
-
when you run a script you can pass variables and parameters to it. so for example, when you type
["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
_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
["init", 1, 2, "three", unit_name] exec "briefing.sqs"
and pick up the paramaters using
_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
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
_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.
-
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.
-
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
-
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". ;)
-
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. :-)
-
Look out for Chris's OFP Script editor. It checks most syntax for you (but doesn't check if your combinations created are valid ;-) ). You should find it here on ofpec.com somewhere.
-
There's also a very useful program called eVolved, a text editor that can learn to recognize all sorts of code, and hence show you if you are using existing commands or making up erroneous ones by accident. It doesn't teach you how to script, but it's very useful for proof reading scripts that you are making or downloading.
It's for free and you will find it here (http://home.no/evolved/).
You have to teach eVolved to recognize ofp commands, but thats easy. There's a folder in eVolved that's called keywords. Put the files from my attached zip inside the keyword folder of eVolved, once you have downloaded and installed the eVolved program itself and OFP scripting will be much easier.
EDIT: Corrected my infamous english grammar/spelling a little :-X
-
Okay, I'll tell you all about the wall I've run into. I have a sequence of groups moving around to preset waypoints. In the midst of that sequence I'm trying to include a loop which will be activated when a soldier gets close enough to a certain object. And this loop can activate at -any- time during said sequence.
Now the problem is that I have something like this
leader group1 move getPos Barn
leader group2 move getPos May
#loop
? (Bee distance Joe < 5) : goto "Continue"
~.01
goto "loop"
leader group2 move getpos james
#continue
hint "Oh crap!"
The problem is that I want the loop to be able to activate at -any- time while the groups are in motion, and from what I've seen it instead stops at the #loop and forever continues testing that variable until it becomes true, then goes to continue like I have written. And I don't know how to make it so that #continue can activate at -any- time... before group1 reaches its waypoint, after, before or after group2 reaches its waypoint, etc... and if it is -not- activated then I want the groups to continue their movements without any interference. In this case "continue" may never be active, but if it -is- I want it to happen at any time. And I'm just unsure how to accomplish that. :banghead:
-
Two points:
1. This is a different question so I suggest you use a new thread (in future) :)
2. From a quick read it sounds like you might need to use a switch trigger. Have a look at this thread:
http://www.ofpec.com/forum/index.php?topic=27843.0
Must rush
-
D'OH. I've gotten so used to scripting since I started last Saturday that I've forgotten all about doing things the old fashioned way with triggers.