Home   Help Search Login Register  

Author Topic: Tutorial: Basics of SQF (ACCEPTED)  (Read 16069 times)

0 Members and 2 Guests are viewing this topic.

Offline Cheetah

  • Former Staff
  • ****
Tutorial: Basics of SQF (ACCEPTED)
« on: 09 Feb 2007, 16:05:39 »
General information (v1.01 - 17th of March):

The goal of this tutorial is to show the potential and basics of SQF. I'll start by describing how to execute SQF scripts, explaining the basic structures and loops used in SQF syntax before proceeding to converting SQS to SQF. Don't expect a thorough tutorial on SQF scripts, if you already master making functions this tutorial may not be written for you. If you already master (to some extend) SQS and want to learn how to use SQF syntax this may be the ideal tutorial to take a step in the good direction.


I'm looking for feedback on this resource, is it any good? What can be improved? More demo material needed in a tutorial?
« Last Edit: 18 Sep 2007, 22:07:02 by Mandoble »
Like missions? Help with Beta Testing! or take a look at the OFPEC Missions Depot for reviewed missions!

Offline Duke

  • Members
  • *
    • Lifesupporters.com
Re: Tutorial: Basics of SQF
« Reply #1 on: 10 Feb 2007, 13:19:46 »
It seems like a good tut but my issue is that I'm new to .SQS but not new enough to require a basics tutorial. What would help me is a slightly more advanced .SQS tutorial and a decent list of how to properly use commands.

Offline Cheetah

  • Former Staff
  • ****
Re: Tutorial: Basics of SQF
« Reply #2 on: 10 Feb 2007, 13:31:54 »
Thanks for the feedback.

You're talking about SQS, I don't know if you mean SQF but there will be more tutorials coming in the next few weeks, I'm sure of that. My intention was to get people new to ArmA and scripting in general to understand SQF. If I get positive feedback, I'll do more tutorials, but first I'll be waiting for more feedback.

I think one major feedback point is the tutorial is too basic for many.
Like missions? Help with Beta Testing! or take a look at the OFPEC Missions Depot for reviewed missions!

Offline IGWedge

  • Members
  • *
  • Internal Coordinator @ www.ic-arma.com
    • International Conflict Armed Assault
Re: Tutorial: Basics of SQF
« Reply #3 on: 11 Feb 2007, 12:35:38 »
Hi Cheetah

Just to explain about myself quickly.

I have been playing ofp for the last 5 or so years. My strengths come in the form of moddeling and texture work,I also done alot orf terrain editing in OFP.
Scripting or configs were never my forté :(

I am absolutly desperate to learn, to even grasp just the basics, so on seeing your tutorial i though that would be a good place to start.

Here is my input.

Your tutorial was well written and explains itself well, What it has done for me is explain the basic layout of the SQF files to the point where i could look at a basic script and break it down to understand the way it is structured. This is a great start.BUT.... i am still unsure of where to start looking for commands
I know we have the awesome ComRef but its still a job to know what commands do what and how to implement them correctly and if their function in the script will work as you want it to. There is sooo much to learn about. :D

I understand you plan to write more and i cant wait to see them.

The bit that i started to lose it was around the implementation of the script into the game. im sure this would be a whole other tutorial hehe.
For instance it would have been good to maybe see some examples that could be directly implemented into the game to show what your talking about. I did try but nothing worked so maybe it wasnt clear enough how you implement it, who to call what etc..


I am going to try my hand at some kind of timer script later when i get home. I want to have a countdown shown on the screen maybe from 60 mins down to 0. Il see what i can do then maybe post to see if you can give any advice on where ive gone completely wrong!! :D

overall a really great start keep it up mate. Us scripting noobs need you guys. :good:

All the best

Wedge

« Last Edit: 20 Feb 2007, 12:34:56 by bedges »

Offline bardosy

  • Honoured Contributor
  • ***
  • campaign designer
    • CartooDiv
Re: Tutorial: Basics of SQF
« Reply #4 on: 20 Feb 2007, 12:26:40 »
Great job, cheetah! Thank you!
Fix bayonet!

Offline hoz

  • OFPEC Site
  • Administrator
  • *****
Re: Tutorial: Basics of SQF
« Reply #5 on: 27 Feb 2007, 05:25:09 »
One thing you should mention about the debugging of sqf files is the RPT log file. Its a life saver if you have multiple scripts causing errors all over the place. As many can atest sometimes those errors don't stay around long enough to read it all.
Nice job  :good:
Xbox Rocks

Offline h-

  • OFPEC Site
  • Administrator
  • *****
  • Formerly HateR_Kint
    • OFPEC
Re: Tutorial: Basics of SQF
« Reply #6 on: 03 Mar 2007, 10:45:57 »
Another thing worth mentioning is the fact that you can't execute sqf scripts from triggers, waypoint or init fields with just [stuff] execVM "script.sqf", you need to use either a dummy global variable or call (which I think ye know already :) )..

Code: [Select]
foo=[stuff] execVM "script.sqf"
Code: [Select]
call {[stuff] execVM "script.sqf"}I myself prefer the latter, no useless variables floating around..

If you mention that already: me sorry, just didn't spot that..
Project MCAR   ---   Northern Fronts   ---   Emitter 3Ditor
INFORMATIVE THREAD TITLES PLEASE. "PLEASE HELP" IS NOT ONE..
Chuck Norris can divide by zero.

Offline Cheetah

  • Former Staff
  • ****
Re: Tutorial: Basics of SQF
« Reply #7 on: 03 Mar 2007, 11:30:05 »
Thanks h-, that will be a worthy addition. Knew that you had to use call, but didn't know before you posted it in one of the other topics that you can use call { }. Will update soon.
Like missions? Help with Beta Testing! or take a look at the OFPEC Missions Depot for reviewed missions!

Offline Blanco

  • Former Staff
  • ****
Re: Tutorial: Basics of SQF
« Reply #8 on: 03 Mar 2007, 22:06:54 »
Finally bought the game  :)


Thx, cheetah. Much apreciated  :good:
I understand the sqs format pretty well (but I lost some skils  :confused: ) but the sqf is a great mystery to me.
I badly needed this one and I'm looking forward for more. thx.

Search or search or search before you ask.

Offline h-

  • OFPEC Site
  • Administrator
  • *****
  • Formerly HateR_Kint
    • OFPEC
Re: Tutorial: Basics of SQF
« Reply #9 on: 04 Mar 2007, 18:18:24 »
Found more 'faults'.. 

In each of the example scripts you have exit; at the end..
Two things:
- even in OFP scripts (sqs) you did not need the exit at the end, it's only needed when the script is supposed to be terminated in a certain point ('in the middle') when the script is running.
- exit is ignored in (ArmA) sqf scripts thus making it completely useless clutter there, and this can 'infect' any new scripters reading this tutorial into using it and that is a big no no  :no: .. In ArmA scripts are exited either with terminate or exitWith

One minor things is the use of the command comment..
execVM supports the use of the 'real' comments // and /**/
I myself find those much pleasant to use..
Project MCAR   ---   Northern Fronts   ---   Emitter 3Ditor
INFORMATIVE THREAD TITLES PLEASE. "PLEASE HELP" IS NOT ONE..
Chuck Norris can divide by zero.

Offline Cheetah

  • Former Staff
  • ****
Re: Tutorial: Basics of SQF
« Reply #10 on: 04 Mar 2007, 19:15:30 »
Thanks for the comments h-, noticed that about the comment and //, I use the // in my scripts too but don't know why I used comment in the tutorial.

Will implement the other stuff in the upcoming 1.01, always thought that you had to terminate a script (with exit):).
Like missions? Help with Beta Testing! or take a look at the OFPEC Missions Depot for reviewed missions!

Offline geezerjo

  • Members
  • *
Re: Tutorial: Basics of SQF
« Reply #11 on: 15 Mar 2007, 16:15:30 »
Many thanks for the hard work. Very instructive. Now is probably the worst time for a guy to learn Arma scripting since everything you find on the net is for SQS. (I'm one of these guys) You finally adress the problem straight on with your SQF tutorial!

Please keep it comming and do know that your work is appreciated. 

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: Tutorial: Basics of SQF
« Reply #12 on: 15 Mar 2007, 18:09:55 »
Consider also that SQF works perfectly in ArmA. If you want something more "fine" performance wise, go for sqf, else you may keep with SQS. For example, if you want something to be checked every 30 seconds, you will have no gain at all with SQF, if you want something being executed every 0.001 seconds, go with SQF. If you find yourself confortable with SQF programming flow structure, go with SQF forever. There is at least one exception: scripts to be executed every # seconds and at the end of a dropped particle (particle array), still should be SQS.

Offline Cheetah

  • Former Staff
  • ****
Re: Tutorial: Basics of SQF
« Reply #13 on: 17 Mar 2007, 14:04:15 »
Updated the resource, version 1.01.

- Added information on how to execute SQF scripts
- Added RPT log file information
- Fixed usage of exit

Any comments are still welcome, as well as fixes / improvements.
Like missions? Help with Beta Testing! or take a look at the OFPEC Missions Depot for reviewed missions!

Offline geezerjo

  • Members
  • *
Re: Tutorial: Basics of SQF
« Reply #14 on: 17 Mar 2007, 18:49:29 »
(Cheetah) I have a little question regarding the last example you use in chapter 8, the one destroying MG if their respective Mgunners are dead. Isn't the�  while { enemy_cleared != 1 } do loop endless? You never modify the enemy_cleared value, will it not continue on forever? Shouldnt you add something like this to the loop

if (_gunarray [ 0] != alive && _gunarray [1] != alive) then
{
enemy_cleared=1;
};


I might be wrong .... im just wondering