Home   Help Search Login Register  

Author Topic: To sqs or sqf, that is the question...  (Read 12863 times)

0 Members and 2 Guests are viewing this topic.

Offline Dajan

  • Members
  • *
To sqs or sqf, that is the question...
« on: 16 Jan 2010, 19:38:25 »
In OFP I didn't script anything - it was a complex world I didn't think I'd every want to touch;

In Arma I learnt to write very basic scripts for the thing I needed the most - custom loadouts. Back then I kept several dozen of my most used loadouts in .sqs format in a .pbo in my addons folder, updated regularly when I found new mods or wanted to create a rag-tag army of misfits.

In Amra II I'm told my L33T scripting skills are now obsolete and the .sqf is in town to beat on me...

So the question:-

As loadouts are likely to stay my most used scripts do I need to learn to use .sqf files or can I stick to the aging, fragile beast that is the .sqs?
If the New-Shiny-FormatĀ© is the way then could anybody see their way to maybe providing me with a commented example of how, with instructions on how to implement it?

TIA

Offline i0n0s

  • Moderator
  • *****
Re: To sqs or sqf, that is the question...
« Reply #1 on: 17 Jan 2010, 01:01:57 »
Which question?
You're don't code for the original OFP, so you use SQF.

For implementation you simple use execVM instead exec and you should take a look at this guide:
http://community.bistudio.com/wiki/SQS_to_SQF_conversion

Offline Dajan

  • Members
  • *
Re: To sqs or sqf, that is the question...
« Reply #2 on: 17 Jan 2010, 15:27:41 »
Ah, right.. Sounds like it's back to school for me  :confused:
 Thanks i0n0s, will have a read

:edit:

okay.. busily getting my head round that..
when I was using the old .sqs method I would create a script like:-
Code: [Select]
;alter loadout

_who = _this
removeallweapons _who
;unit is now empty

_who addmagazine "magazine_name"
_who addmagazine "magazine_name"
_who addmagazine "magazine_name"
_who addmagazine "magazine_name"
_who addmagazine "magazine_name"
_who addmagazine "magazine_name"
_who addmagazine "magazine_name"
_who addmagazine "magazine_name"
_who addmagazine "magazine_name"
_who addmagazine "magazine_name"
_who addmagazine "magazine_name"
_who addmagazine "magazine_name"
;primary/secondary weapon 12 slots (use throw for magazine_names)

_who addmagazine "pistol_magazine_name"
_who addmagazine "pistol_magazine_name"
_who addmagazine "pistol_magazine_name"
_who addmagazine "pistol_magazine_name"
_who addmagazine "pistol_magazine_name"
_who addmagazine "pistol_magazine_name"
_who addmagazine "pistol_magazine_name"
_who addmagazine "pistol_magazine_name"
;pistol 8 slots

_who addweapon "binocular"
_who addweapon "nvgoggles"
;misc 2 slots

_who addweapon "secondary_weapon_name
_who addweapon "pistol_name"
_who addweapon "throw_for_grenades"
_who addweapon "primary_weapon_name"
;Weapon slots slots

_who selectweapon "primary_weapon_or_muzzle_name"

exit
Do I need to alter this over much? I can't see anything that makes it look like I do except changing how bits are commented out..?
« Last Edit: 17 Jan 2010, 16:08:26 by Dajan »

Offline i0n0s

  • Moderator
  • *****
Re: To sqs or sqf, that is the question...
« Reply #3 on: 17 Jan 2010, 16:22:22 »
The comment-style and the EOL parenthesis:
http://pastebin.jonasscholz.de/pastebin.php?diff=493

Offline Dajan

  • Members
  • *
Re: To sqs or sqf, that is the question...
« Reply #4 on: 17 Jan 2010, 17:23:53 »
Thanks!
Does it not need exit on the end anymore?
Implementing at mission start is:
Code: [Select]
nul0 = [unitname] execVM "myscripts\scriptname.sqf"in the init of each soldier I want to rearm yes?
Sorry for the barrage of probably frequently-asked and newb-level questions, it's just any documentation is written by those who understand for those who understand a little less rather than those who really, honestly don't have much of a clue  :-[

Offline i0n0s

  • Moderator
  • *****
Re: To sqs or sqf, that is the question...
« Reply #5 on: 17 Jan 2010, 17:51:08 »
Exit is not needed any more.

And you need to use:
Code: [Select]
nul0 = unitname execVM "myscripts\scriptname.sqf"

Offline Dajan

  • Members
  • *
Re: To sqs or sqf, that is the question...
« Reply #6 on: 17 Jan 2010, 17:56:20 »
Ta i0n0s

Offline Gielovic

  • Contributing Member
  • **
Re: To sqs or sqf, that is the question...
« Reply #7 on: 19 Jan 2010, 21:24:33 »
I see the solution is already presented.

One small remark for you in the feature on your last question.

Sometime you scripts getting executed (called) like this:
Code: [Select]
variable = nameofsomeunit execVM "script.sqf"and sometimes you see
Code: [Select]
variable = [nameofsomeunit] execVM "script.sqf
This is due to the way the _this variable in the script is used.
In your case you use in the first line of (real) code :
Code: [Select]
_who = _thiswhich means you give the value of the phrase before 'execVM' to the variable _who. In this case, this will be some unit.

You could also pass a list of values to the script, a so called 'array'. An array is denoted by the square brackets with comma seperated values in between.
if your first line of code would be
Code: [Select]
_who = _this select 0 you should have passed  an array to the script ([nameofsomeunit]), and the first element (with index 0), would be assigned to the variable _who.
More on the select statement can be found in the Biki

This way you can make scripts to which you can pass multiple units, or other elements like static objects, tanks, groups of units, etc...

A nice tutorial

Offline Dajan

  • Members
  • *
Re: To sqs or sqf, that is the question...
« Reply #8 on: 20 Jan 2010, 01:18:33 »
I could just do this in a trigger to run for multiple units?! Wow! Maybe I should have learned this stuff before  :)
Unfortunately that tutorial wasn't available when I tried just now, but thank you - really - for the help. I'll see if I can get it all into my head  :clap:

Offline Planck

  • Honoured
  • Former Staff
  • ****
  • I'm never wrong ....I'm just not always right !
Re: To sqs or sqf, that is the question...
« Reply #9 on: 20 Jan 2010, 01:41:57 »
The tutorial above has been available since 2007, how could you miss it?


Planck
I know a little about a lot, and a lot about a little.

Offline Dajan

  • Members
  • *
Re: To sqs or sqf, that is the question...
« Reply #10 on: 20 Jan 2010, 11:53:02 »
As I only started trying to script a year ago and never tried .sqf until everyone started saying .sqs was obsolete for Arma II. Some of us panic when trying to learn a new language without a teacher there to hold our hands you see.. :confused:

Offline Zipper5

  • BIS Team
  • ****
Re: To sqs or sqf, that is the question...
« Reply #11 on: 20 Jan 2010, 14:58:22 »
I wouldn't say there are amazing benefits to using SQF over SQS besides better, cleaner formatting and marginally faster processing. However, performance in ArmA II is a major issue for many people, so I took it upon myself to learn how to write clean SQF scripts for my ArmA II missions. I found it as hard as you did at first, since I knew much more about SQS, but now, I'm just as good with SQF as I was with SQS. Just takes practice.

I'd say use whichever you're most comfortable with using. Rarely do people unpbo missions and look at them themselves, and when they do, they rarely go "ZOMFG SQS SCRIPTING!!111one", lol. I wouldn't say the benefits of SQF scripting are enough to make SQS obsolete.

Offline h-

  • OFPEC Site
  • Administrator
  • *****
  • Formerly HateR_Kint
    • OFPEC
Re: To sqs or sqf, that is the question...
« Reply #12 on: 20 Jan 2010, 15:53:41 »
Quote
marginally faster processing
IMHO it's much more than marginally faster.
In my experience sqf beats sqs in performance 100-0, but of course it depends on what you script. With some simple things you won't see the difference.

I had coded mind boggling amounts of sqs code in OFP and when I initially started "Armatizing" them especially scripts with heavy looping caused significantly lower FPS hit when converted to sqf.
Where sqs would cause huge, even eye detectable FPS drop the same thing in sqf wouldn't cause any, not even when measuring with Fraps..
« Last Edit: 20 Jan 2010, 15:55:48 by h- »
Project MCAR   ---   Northern Fronts   ---   Emitter 3Ditor
INFORMATIVE THREAD TITLES PLEASE. "PLEASE HELP" IS NOT ONE..
Chuck Norris can divide by zero.

Offline DeanosBeano

  • Addons Depot Staff
  • *****
  • SirDeanosbeano bstowed on me by sui ;)
    • Fraghaus
Re: To sqs or sqf, that is the question...
« Reply #13 on: 20 Jan 2010, 16:41:03 »

 for me its a simple equation :).
 
if my script runs once and has no loops or ifs ands or maybe and it works straight from ofp-arma then i leave it.
 I have hundreds if not thousands of scripts from ofp and to be honest if it aint broke there is little point fixing it

 The pros of using SQF are speed and consistency and   that you will require it at some point and so why not learn it.

 The pros of sqs are , if you have one that works and isnt causing lag and it fires even during periods of bad FPS , then slap it in there why waste time :.

Sqs will never die, it will merely be converted by others and called there own.
I love ofp

Offline Dajan

  • Members
  • *
Re: To sqs or sqf, that is the question...
« Reply #14 on: 20 Jan 2010, 19:46:15 »
Thanks for the reassurance guys, I love you all  ;)