Jump to content
Sign in to follow this  
Bladesfist

Questions about scripting in Arma 3

Recommended Posts

Hello everyone.

With the release of the Arma 3 Alpha I have decided that I want to start making missions for the game. I have done a little playing around with the editor and have found it to be pretty easy to use however I want to start making some more advanced things. I am coming from a scripting / game development background with C# / Java (would prefer to use C#) and have a few questions about how things work in regards to Arma. So my first question is what language does Arma 3 use. I have searched around a bit however all the results seem to predate the launch of Arma 3 and so I am not sure if they are accurate. Second Question: What do I need to do to get a script I write to execute. What kind of execution order there may be and how much freedom do we have with the API.

Share this post


Link to post
Share on other sites

The Real Virtuality Engine uses SQF which is RV exclusive. The only thing you need to know are general statements (if, while, switch, for) and some things like foreach and waitUntil.

Helpful link:

http://seit.unsw.adfa.edu.au/coursework/ZEIT2305/Resources/SQF_Tutorial/basic_sqf.HTML

SQF is pretty easy to learn I'd say.

About execution order, you can execute scripts at any time during the game with the following:

nul = [array of things you want to pass to the script] execVM "script.sqf";

If you want to execute things on mission start there's a file called init.sqf, which you put into your mission folder. This file gets executed on Mission Start (during loading screen). Be aware that you shouldn't add sleeps or waitUntils (NEVERRR WAITUNTILS) in this as it will BLOCK the mission.

So for example if I put this in my init.sqf:

waitUntil {player == player};

it's not going to load the mission because the player does not spawn before mission start, and at the same time the init.sqf needs to be completely done before the mission can start.

Execution order within the init.sqf is from top to bottom, so pretty simple.

But remember sqf has little to do with other languages except statements and for the most part it's just ingame commands (which you can find on the BIKI). I wouldn't even call it a language on it's own.

Share this post


Link to post
Share on other sites

Welcome to the world of ArmA scripting. In addition to the very good advice above from tryteyker, I highly recommend opening other people's scripts so you become familiar with the variety of commands and their functions. This is how I first started getting into scripting. One of the best BIKI pages for more info of those commands is Scripting Commands by Functionality which as you can tell by the title groups the commands by their particular functions.

Edited by Loyalguard

Share this post


Link to post
Share on other sites

I thought I read that Java was an option somewhere. Is that no longer the case as I would much prefer to use a proper OOP language.

Share this post


Link to post
Share on other sites
I thought I read that Java was an option somewhere. Is that no longer the case as I would much prefer to use a proper OOP language.

That is something that BIS is looking into but not yet implemented. There are several threads on the topic if you search to see the latest status.

Share this post


Link to post
Share on other sites
That is something that BIS is looking into but not yet implemented. There are several threads on the topic if you search to see the latest status.

Ah I see, the thread I was reading was in the Take on Helicopters section, I am glad to hear it is something they are working on. I guess I will give SQF a go for now. Thank you both for the information.

Share this post


Link to post
Share on other sites
Be aware that you shouldn't add sleeps or waitUntils (NEVERRR WAITUNTILS) in this as it will BLOCK the mission.

I use waituntil in init.sqf all the time with no issues - usually waiting for functions module to initialise

//wait till functions module has initialised 
waituntil {!(isnil "bis_fnc_init")}; 

Share this post


Link to post
Share on other sites

Well after playing around with SQF for a while I really want Java support. Do we have any information on what the support will be like. Will we just have the same API that SQF uses and have to do silly things like player getPosition instead of Player.position. For lack of a better term will the Java support be more "Object Orientated". If anyone has played with Take on Helicopters could you tell me what the implementation is like in that?

Share this post


Link to post
Share on other sites

After reading that I am unsure if support has been cancelled. It would also be nice if we could make extensions for the editor (I'm not sure if this is possible already). It would be nice to make windows that allow you to add gear to objects in the editor ect. On that note it could probably be added to the modules tool, allowing us to create our own modules with there own interfaces.

Edited by Bladesfist

Share this post


Link to post
Share on other sites
I use waituntil in init.sqf all the time with no issues - usually waiting for functions module to initialise

//wait till functions module has initialised 
waituntil {!(isnil "bis_fnc_init")}; 

because that mission might also include a jip.sqf

Share this post


Link to post
Share on other sites

BI have put sleeps and waitUntils in init.sqfs in their own missions. Also

if (!(isServer)) then {
waitUntil {!(isNull player)};
}; 

or whatever is always used in init.sqfs to wait for jip players to be synced.

Share this post


Link to post
Share on other sites

i wouldnt keep high hopes for java just yet looks like it might be supported as an extension which is not too bad but core will still be sqf.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×