#arma3_scripting
1 messages ยท Page 279 of 1
They could completely do away with if (condition) then {}
amd replace it with if (condition) { }
they cant, thats not how sqf works
but then you don't have exitWith {}
Ahhh right.
and again:
"Does it matter?"
Of course it does, because JS and PHP and shitty
Only the syntax of select matters, other than that no.
It's its own language, sooo.
๐ฅ
๐คณ
Screwy ass name.
and?
I still don't get, where the point of that Convo is^^
scratching head and b*********
It was in relation to the verbosity of _array select _something
who uses select anymore? param ftw
and the speed reduction it probably introduces
@still forum Why using param when you know whats in there?
Or if you want the first entry
cuz... I wanna be anti?
okayyyyyyyyy
Atleast we got slices sort of
_myArray select [beginingindex,endingindex];
And I guess we should be grateful for SQF
rather than SQS (Status Quo Script)
Which results in some seriously bad spaghetti code
You shouldn't be questioning why we don't have array[index], more why something like select has so much overhead
I already answered this. Input validation. And it twice as bad for select since it's a binary command.
How much overhead does it have... ?
Not much more than any other binary command
hmmm
I thought try catch and throw was best for input validation?
I mean params can provide valid types.
But it can't break out of the code if an "illegal" expression is found.
Ironically try catch and throw got updated
To now accept parameters
e.g
I already answered this. Input validation. And it twice as bad for select since it's a binary command.
Yeh, but like I said yesterday or whenever, that is to a much larger extent than needed
I thought try catch and throw was best for input validation?
In SQF ๐ ?
player try {
if (player != (vehicle player)) then {
throw "Not a vehicle"
};
} catch {
if (_exception isEqualTo "Not a vehicle") then {
//do some exception stuff //
};
};
Doesn't help with anything internal though
It's just some sugar over what we all do anyway
If you like
And allows you to catch the error immediately without running all the exitWiths?
Hmmm wonder how many exitWiths it takes to make the same overhead as the try catch and throw
You're still running through more code than needed
If you wanted to exit with a hint for example
So why implement try catch and throw at all?
if (something) exitWith {hint something};
Instead you're throwing that, then checking what the error is, then hinting
I guess it could be handy
eg?
Certainly neater when you're quite far nested in scopes
Hmmm
Because exitWith won't exit the parent scope. Then again, breakOut is there
I've never tried nesting try catch in SQF, but if it works as you'd expect it to, then it could help
not before so it doesn't result in a goto like expression.
You could start trying to replicate an exception type system you'd expect of a normal language
scopeName "main";
...
......
......... many scopes in, breakOut "main";
Yeah I normally put the scope name after the breakout.
Or below it.
So it follows some normal order of execution.
Why?
{
if (_x isEqualTo condition) then { breakOut "main" };
}
forEach _listOfItems;
scopeName "main";
Does that even work?
I don't think it does
I think it'll exit the forEach
Then continue execution, as your scope isn't defined
{
if (_x isEqualTo condition) then { breakOut "main" };
}
forEach _listOfItems;
systemChat "I'm executing!";
scopeName "main";
etc
Why?
May as well replace BreakOut with goto
How does it know what to breakOut?
Pretty sure scopeName needs to be executed before breakTo/Out
breakOut is like a retarded return
xD
But a handy one
Sure, but this style of code is pure spagethi
Well using purely breakOut as a mean to return, isn't spaghetti
It's as you'd expect a normal return to work
breakTo isn't exactly goto either
Indeed, because it jumps forward in execution
But it's the nearest you're getting ๐
You only can skip between scopes and not random points in the code like with goto
goto only exists in SQS
But that is good
The lack of goto? Sure.
Because I've never really seen a proper use case for goto, where something more elegant couldn't be used
There are probably some...
No one can agree to what proper SQF looks like in the first place
No point in thinking about hypothetical new commands
It depends on what the language offers you though. I see many people use goto in C#, because it doesn't implement switch fall through very well
Okay found 8 entries in BI functions to scopeName
fn_findSafePos uses it
Interesting
Instead of a lot of exitWiths
breakTo is pretty shitty, but I can see use in breakOut's new return value supporting syntax as a pseudo return
I probably even used that once or twice already in this discord.
Breaking out the most parent scope, like a return, is really handy if you're nested in some loops or logic
I use it for quite a few things
Ironic that BIS stores all their location data in configs
Instead of SQF scanning them all
_pos = _this select 0;
_minDist = _this select 1;
_maxDist = _this select 2;
_objDist = _this select 3;
_waterMode = _this select 4;
_maxGradient = _this select 5;
_shoreMode = _this select 6;
hehe
It's not something you need when you're new to SQF. It's really niche. A tad bit more useful than try-throw-catch which is just a bad joke.
yeah I know
It would be really easy to change
I've had to do this to a few BIS functions
over-write them with params builtin
(Bit off topic, sorry.) Anyone here have experience with the OO implementation in BIS?
aaaaaah
I'm doubtful anyone here has played with the functions, and from what I hear, it was a somewhat disaster, may be wrong though.
Shoot. Was hoping they'd finally made a proper implementation
commy has a deep bond with SQF, might be worth asking him ๐
I don't have a deep bond with what a proper OO implementation would look like though.
Not a bunch of BIS functions ๐
This is the only one I've seen
Was reading some old posts by DnA. Apparently there is some overhead since it's handled with scripting
Indeed, yeh
I think, the C# thing that was posted on here before, might get you a step closer
But I can't remember its name
Or really what it did
Thats the only OOP system I've seen
Hm... I mean, their internal functions make total sense, just haven't tested what performance impact there would be
I'd be more worried about what you might over-write
//Automatically call parameter validation whenever a method is called
private ["_compileString"];
_compileString = _methodVar + " = compile ('";
_compileString = _compileString + "if (!([""" + _className + """, """ + _methodName + """, _this] call BIS_fnc_validateParametersOO)) exitWith {" + _returnValue + "}; ";
_compileString = _compileString + (preprocessFileLineNumbers _methodScript);
_compileString = _compileString + "')";
call (compile _compileString);
this part
I have to puke
Not very secure yeah.
That looks like that format thing I sent you ages ago
needs format.
๐
Oh god
cfgOOP
(Sorry, takes a second for me to read through on my phone.)
I need to find this config
Looks like a side project ๐
The idea is nice, if it was an actual 'language' implementation
Because you make it
^
It's a special config
If you want real OOP
Just defined in desc
I found someone who made a neat macros library
Oh?
have fun reloading the game with every change ๐
neat macros library
OOP? ๐คฃ
Reloading the game?
oh a naught creation, here we go
Thats the only one I know of.
Hm... I'll have to see more on my laptop
And something you can easily achieve w/o
^
Agreed
ALiVE uses a semi OO style-ish code based around modules and/or CBA hashes
ALiVE is no offense a performance hog.
been meaning to tear apart ALiVE
Oh crap. Forgot they had one
performance isn't too bad to be honest
If you use the default 144 groups
for what it does
It will kill everyones FPS
no it doesn't
Depends if theyre doing it right
you'll never run in to 144 active groups
^
yes, if you're spreading around the map like crazy than sure
Even when the HC offloader was active.
Exactly Marceldev89
This was a noob mission makers mission
I brought the problem up with him several times.
Now the community I used to be apart of.
uses MCC...
facedesk ** -,..,- **
My unpopular opinion: I don't need OO in SQF.
^
Reason?
(Just curious. If there was a proper implementation)
since when is OO something about performance?
No. I don't need it. I can do everything without it and I would see no point in using it.
Not looking for perf improvement
SQF is even a bytecode translated language
nor compiled
most of those OO languages use some kind of bytecode or compiled code.
Excluding. Lua.
Python, C++, C, Java bytecode. or compiled.
Ah, I am forgetting about this backend. Sorry, I come from a background of C,C++,Java,.NET on embedded systems
Yeah no SQF is C, PHP, JavaScript had a baby and it was ugly.
Oh god it is
SQF makes me want to stab things
And yet I keep working with it ๐
Especially when you get errors that make no sense.
For example I tried to use a C implementation for looping through a multidimensioal array
using nested for loops
NOPE
SQF doesn't like that one bit.
That's just your bad script though.
My face when I found out switch statements were slower than ifs ๐ค
: P
This isn't C though
Their logic handling it beyond me as well
ASk @still forum if you want to know more specifics.
But he said SQF's script executer is Single-threaded
Unlike C# or C++'s compiler being multi-threaded along with supporting multi-threaded libraries by default.
I can certainly see the challenges with multi threading that
I'd love to see some more "knobs" and functions I could use to maybe implement my own version
That'll never happen though lol
Best you can do is use an external extension
Only issue is the calls to the extensions are single-threaded as well
callExtension etc.
Been looking into that for a little while now. And the issue of only string transfer
Has its own set of crappy problems with its implementation
Why because you need a parser to interpret the data coming from the string?
The problem is that you worked with C++ and now you want to have a games scripting language work the same way.
Eh, I go back and forth on the string thing tbh. I see both sides of the argument on it
callExtensions also unscheduled. It is limited in how many loops it can do. 10,000 iterations I think it was, before the extension will be stopped
Very true @little eagle . I need to keep things in perspective
Just forget about everything and start over fresh.
And keep in mind that, at least I consider it to be, 90% of the code snippets you find out there are shitcode.
I mean, I've been learning the SQF backwards methodology for 3 years now. It's not foreign lol
3 years ago I didn't know anything about any language that is not Java if you count one semester working with it knowing it.
Never figured it would be. Just a fun hobby
VBS uses a different library.
It's still SQF
It's so much different from Arma now.
All of it.
But VBS has a whole bunch of tools
like an external debug console
That complains about bad scripts
and is intelligent enough to say this is a crappy script
fix it.
You can even change the way the scheduler handles the scripts
telling it to complete in a single frame or etc.
Why? No one uses it.
Just cruious
It's probably all broken and shitty.
Its not "the yellow from the egg"
People get too excited by features described on wiki articles, video demonstrations and pretty screenshots.
Very true
@little eagle playing the other side of the coin and keeping it grounded
Based on a set of conditions.
Hah
Too bad no one ever listens. So many tragedies could've been avoided.
What is there to elaborate? It's a joke.
@tough abyss ALiVE is a tool, of course your fps is going to tank if you have too many AI clusterfucked in a small area. Just don't abuse it and your performance will be fine.
I know
People abuse it.
Often.
Just like Zeus
I said in my community DONT spam AI
what did they do?
Spammed AI...
-,...,-
seems like you need to find better people ๐
was a MEU
I protested against MCC
They took the advice of an asshole that had run Life communities, and effectively gave him the keys to the kingdom even though I had been there for 2 - 3 months, I'm glad I didn't deploy my mission framework.
What did you think of the biotopes @little eagle
looks like they just spawn a bunch of trees and rocks alongside the road or on the ground
ยฏ_(ใ)_/ยฏ
You could do that with SQF too
Then why doesn't BI just give us the ability to use a blank map
to proceedurally generate trees on?
facedesk
Yeah, really nice, take Takistan change it, take Chernarus change it.
But I'd rather be able to manipulate the attachments of weapons inside ammo boxes already.
we're not playing minecraft ^^
to the biomes
Then stop supporting life servers dies
how are they "supporting" life servers?
"Monotization"
tried it
lock doesn't work...
Not sure how I could remove the interaction item.
without using removeAllActions.
Which removes everything.
Just stop people opening them?
You can't...
Of course you can
How?
Oh.
Right.
Forgot about the Container open handler
I just wanted a simple system to lock and unlock the container...
if (container getVariable ["locked", false]) exitWith {true};
Okay it's that easy?
exitWith might not work in the eventhandlers main scope
It doesn't work in handleDamage
EH's don't have any scope to exit do they?
as in it's at the top of the "call stack", kind of
everything encapsulated with curly brackets is a scope
player addEventHandler ["InventoryOpened", {<this is a scope>}];
mhm but is there a scope above the current scope once it fires?
I'd imagine that exitWith doesn't work in init.sqf either in that case
Define work
If you call exitWith in the main scope of init.sqf
nothing below the exitWith will be executed
There is no return value that is expected by init.sqf
unlike InventoryOpened
so I really don't see the similarities.
they both don't have a parent scope to exit to?
that's why I could imagine it not working in init.sqf as it doesn't with the HandleDamage EH as you pointed out
Neither have a parent scope to exit to
init(or any other).sqf:
abc = true;
if(abc)exitWith{};
systemchat str abc
Systemchat won't be executed.
As easy as it is oO There is no witchcraft in exitWith
then why does it not work with HandleDamage EH for example?
player addEventHandler ["handleDamage", {
if (true) exitWith {0};
}];
^ this does not work
because -> Arma
wait, init.sqf is scheduled, isn't it? That probably explains the difference
Nah, because the main scope of handleDamage expects a return value, but you leave the scope with exitWith
iirc its for each and every EH.
I mean sure Arma, but that is how it works with everything
Except waitUntil for god knows why ....
Literally everything that is not waitUntil
afaik init.sqf is the same as every other *.sqf file. It just gets loaded by the engine automaticly. Marcel
Yeah.
And it has nothing to do with scheduled either. My while loop was scheduled to avoid the 10k iteration limit
It's just waitUntil being weird
waitUntil is like a Loop on its own, in its own NameSpace. No chance for ExitWith (iirc)
@jade abyss I get that but exitWith not working for EH's is just weirding me out I guess. Always assumed that exitWith kind of meant return _var
It's handled specially due to the rate at which it executes IIRC, it's brought out of context
prolly
But can you breakTo to a deeper scope?
I mean... lets see it the logical way:
A script that has waitUntil in it gets executed once, then reaching waitUntil Part, then checking constantly each whatever* s, looping its {XYZ} part
@little eagle what about this?
player addEventHandler ["handleDamage", {
0;
if (true) exitWith {};
}];
not that it makes sense due to the condition
Prolly the mainscript gets "cached"/removed from the mainSchedule and only the waitUntil Part is still loaded.
@halcyon crypt Try this: add diag_log "blaaaa" to the EH or define a globalVar in it.
0 spawn {
scopeName "main";
call {
waitUntil {
breakTo "main";
false
};
};
systemChat "is this ever reached or not?";
};
logically, it should
Well, exitWith didn't reach it
Since you say to that darn thing -> Exit here at this point (breakTo)
So waitUntil should be done
i get headache
Yup
maybe worse headache, cause i haven't touched that stuff for > 6 Months ^^
back to Tentacle Pr... movie... less headache
my guess would be that the engine implementation of waitUntil prevents breakTo or anything else to work guess not ๐
Or its just a bug/broken.
don't know, it seems somewhat logical to me but my logic seems a bit off judging by the stuff above ๐
it does print and end the script
Does NOT print? Okay
it does
Its too late, my bad
now testing:
0 spawn {
scopeName "main";
waitUntil {
breakTo "main";
false
};
systemChat "is this ever reached or not?";
};
wait, you tested what before?
kk
Try this:
0 spawn {
scopeName "main";
waitUntil {
systemChat "1";
breakTo "main";
systemChat "2";
false;
systemChat "3";
};
systemChat "is this ever reached or not?";
};```
I'll be testing this first:
0 spawn {
waitUntil {
scopeName "main";
false breakOut "main";
false
};
systemChat "is this ever reached or not?";
};
This is basically exitWith
right?
Can you test that one from me? Don't wanna search A3 in my SteamLibrary ๐
hmmm, okay
At least, it exits. But without result sending over.
screw it, i move my rotten body to the couch.
My best explanation is that the code block of waitUntil is being called inside another virtual code block and the return value of the virtual code block is used
waitUntil {<blah>};
is basically
waitUnit {call {<blah>}};
e.g.:
_Time = (diag_TickTime + 40);
waitUntil {sleep 1; diag_TickTime >= _Time};```
So yeah, seems to be your last example
No stop, not call
why not?
waitUntil spawn{<blah>} <-- ?? ^^
You can suspend in call if the call was executed in scheduled environment
Yeah, waitUntil has to be
It suspends for a frame
that is it's sole gimmick
And it has only one code block so it's not as much of a drag compared to while performance wise
+you can still use (ui)sleep to suspend it
Depends on what you wait
I mostly used it Changes of Areas
waitUntil{sleep 10; SomethingNotSoImportantButStillNeeded};
I meant instead of waitUntil
while {sleepFrame 1; checksomething} do {}
of course also patch while so you don't need a do block
And i meant: Not checking every frame/second. Just check it every X Seconds.
Also possible with it.
Was while able to use suspend? like
while{sleep 3; Var}do
can't remember
but still... nah, that makes no sense to let a while{true}do doing that
You can use suspension everywhere in scheduled environment
^
Except isNil CODE, because that is no longer scheduled environment for god knows why
My best explanation is that the code block of waitUntil is being called inside another virtual code block and the return value of the virtual code block is used
or the string-code block in configClasses and configPropeties
Can you exitWith {breakOut ""};?
thought something similar @dusk sage
0 spawn {
waitUntil {
if (true) exitWith {
scopeName "main";
false breakOut "main";
};
false
};
systemChat "is this ever reached or not?";
};
this, right?
nono just breakOut ""
0 spawn {
waitUntil {
if (true) exitWith {
breakOut "";
};
false
};
systemChat "is this ever reached or not?";
};```
โ ?
I'll test mine first
equivalent I think
mine loops forever
breakOut "";
is just another breakTo, it will work
wait
uhm no
it loops forever
Idk man
ยฏ_(ใ)_/ยฏ
i guess: Since no targetscope :/
Chances are its taken totally out of context
^ this doesn't work
"" doesn't work guys
0 spawn {
waitUntil {
if (true) exitWith {
breakOut "undefined";
};
false
};
systemChat "is this ever reached or not?";
};
"" is just ignored by the command
Yup
With "undefined" it prints the chat message
btw.:
Why is exitWith in waitUntil even needed?
It's not, but you can use it as return
It's a really confusing syntax as I said
Because it works nowhere else
Never use this
@tough abyss
callExtensions also unscheduled. It is limited in how many loops it can do. 10,000 iterations I think it was, before the extension will be stopped
What? No!... Arma doesn't care about what happens inside the extension and it can't stop it either. there is a limit on loops yeah.. but totally nothing todo with Extensions
I can't sleep right now so... back to that thingy about _array[index] and if (true) {do this}
SQF is a very easy language. It has variables, arrays, code blocks and 3 types of commands. Commands without arguments.. Commands with one argument and commands with 2 arguments.. Thats It. Thats all of SQF.
_a = 1 Is this a variable assignment? NO! It's a function call. It's calling the function = with the arguments _a and 1.
Same for if.... then stuff... if is a command taking one argument and returning an intermediary "condition object". then and exitWith are commands that take 2 arguments. One "condition object" and a codeblock.
SQF's core principle is that everything is a function call.
So by doing if (true) {code}, which looks like CONDITION CODE to the engine, You are trying to violate the core principle of SQF.. Well actually.. They could just make a whitespace function that takes a "condition object" and a code block... But thats Nuts...
Same for _array[index] how should it know that ARRAY ARRAY should do anything? ARRAY FUNCTION ARRAY is very obvious what it should do.. It's a function call taking 2 arguments. You just can't change the core principle of the language. So all these Ideas about making the language nicer will stay exactly that.. Ideas.
I hope i can sleep now instead of thinking about this the whole time
_a = 1 Is this a variable assignment? NO! It's a function call. It's calling the function = with the arguments _a and 1.
uhm ... nope
it is a variable assignment
= is a special case in SQF
So by doing if (true) {code}, which looks like CONDITION CODE to the engine also false
for the engine it is ( IF(BOOL) )THEN( CODE )
important difference is the IF(BOOL) as the bool after the if gets flagged specially somehow
then REQUIRES an if
even though ... IF does not require then (and just returns the bool itself)
--> _cond = if(true); _cond then {1} else {0} is valid
true then {1} else {0} is not
@still forum SQF is a very easy language. Sorry, I would have to disagree, because I'm fluent in at least 6 differrent true programing and scripting languages (C#, C++, Javascript, XML/XSL, VB, PERL, LISP, Forth, assembly), conversant in quite a few others.... and the syntax of SQF only very, very loosely matches the syntax of any that I've seen which makes it hard for someone who already knows one of those other languages, because the change up in syntax is pretty extreme.
However, it is the one we are stuck with for ARMA 3 so that's why I'm trying to learn it.
in my opinion it matches C based languages making it fairly easy
SQF reminds of me the scripting language at work, grown and patched on to over 15 years into a frankenstein's monster of quirky behaviour and edgecases
@woeful void When you consider that everything is 'well' documented on the wiki, SQF really isn't a hard 'language' at all
and probably with 15 years of content that uses it that no-one wants to change in order to overhaul it
Gotta love the backward compatibility though hehe
anyhoo, my arma3server keeps crashing when I start it up...anyone ever get this error?
arma3server.exe - Bad Image
F:\Games\Arma3\A3Master\BattlEye\BEServer.dll is either not designed to run on Windows or it contains an error. Try installing the program again using the original installation media or contact your system administrator or the software vendor for support.
I find sqf to be pretty easy to understand and learn though. Especially in 2016/17
I killed the server process while it was booting to fix a script and it hasn't worked since
it just fails init'ing BE
my bad, sorry
didn't work, but I'll figure it out tomorrow, this is definitely not a 2am probably I want to have
cheers
Hey fellas, any clue as to whether there is a getCargoIndex but for commander seats? Thanks.
I don't think so but there's a lot of workarounds for whatever it is you re trying to achieve
Hm, basically I want an animation to happen if someone switches into a particular commander seat.
Basically need a custom eventhandler on entering a specific turret position.
Specific vehicle? or any vehicle commander position?
GetIn or GetInMan EH
seatSwitched or seatSwitchedMan
then commander vehicle player isEqualTo player
or assignedCommander vehicle player isEqualTo player
@X39#2180 important difference is the IF(BOOL) as the bool after the if gets flagged specially somehow IF is both a command and a type in sqf. typename if (true) is of type 'IF' which is expected for the left hand operator of 'then'. supportInfo "*:if" ["t:IF"] a type. supportInfo "*:if*"["u:if BOOL"] a command. supportInfo "*:then*" ["b:IF then CODE","b:IF then ARRAY"]
@dusk sage The reason I call it hard is because it flys in the face of all the other programming habits one picks up when they do programming professionally. What I am pointing out is that knowing other languages can make SQF harder, not easier to understand.
I would argue despite the awkwardness of SQF, knowing other languages has made learning SQF simpler. But when I refer to difficulty, it takes little to no time to become 'proficient' in SQF
Would you be a casual or a professional programmer? Just trying to get an idea as to skill level here, no offense intended.
Actually.. that question isn't relevant to the channel as a whole so I'll withdraw it. Nevermind me.
I program in my degree, and have jobs lined up as a programmer post grad @woeful void
Is there a way to restrict the contents of a 'RscEdit' to numerical characters?
@woeful void Not only that. There is quirks of the language that... are related to stupid things.
E.g unscheduled code in, EH's show 0 errors
How would I delete every element AFTER a certain one in an array? deleteAt will delete the one I want but not all after it.... I could write an algorithm but there may be a command anyway
Just select from 0 to the one you want and copy them. _array = _array select [0,_index+1]
It can vary where it will occur... It could be select 3, 4, 5, 6, etc. That's why I just wanted to see if there was a command for it
You only want to remove element from the end I understand? I forgot about resize which even modifies the original like deleteAt
Simply resize to the index of the last element you want to keep + 1
@indigo snow It's slightly different to that, I just wrote an algorithm for it though, thanks for the help though. I kindof wish they had a command for that but w/e xD.
@tough abyss
if(isNil "oef_block") then {
oef_block = addMissionEventHandler ["EachFrame", {
whatever;
removeMissionEventHandler ["EachFrame", oef_block];
oef_block = nil;
}];
};
I meant SQF is very easy from the engine programmers perspective. everything is made up of function calls that makes the backend relativly easy to program.
and @queen cargo i don't understand anything about what you are saying about the if then stuff besides the last 2 lines.
What I am pointing out is that knowing other languages can make SQF harder, not easier to understand.
I would argue despite the awkwardness of SQF, knowing other languages has made learning SQF simpler.
Opinions. ยฏ_(ใ)_/ยฏ
But when I refer to difficulty, it takes little to no time to become 'proficient' in SQF
Yes, but how long does it take to master SQF?
@tough abyss
@meager granite
addMissionEventHandler ["EachFrame", {
// do magic
removeMissionEventHandler ["EachFrame", _thisEventHandler];
}];
Since Arma 3 v.1.63.137807 the EH handle is also stored in _thisEventHandler variable and is available during EH code execution.
if (so) then {sweet};
ERROR Generic error in expression
(entities [[], [], true, true]) returns duplicates of units in vehicles when called at postInit
You had one job, BI
You know what?
I'm not even surprised.
Oh _thisEventHandler is already implemented, forgot about its existence
Though he still needs outside handle if I got his question right
Yes, but how long does it take to master SQF?
Depends how far you're willing to sell your soul
๐คฃ
The SQF god is not kind
He will destroy everything you believe in
Then what is it empowering us to write the most abusive and dirty code? ๐
Okay. I need help. Anyone game this morning? Here's what I need:
I need a script that either can make autoturrets fire blanks, a script that will make autoturrets fire at assigned targets based on a trigger, or I need an invisible wall that will stop bullets.
Anyone know of any of these??
HAha, okay, but how do I do that? I am TERRIBLE.
I'm always in over my head. Will it work on autoturrets?
Idk, why not? Probably, try it
Will try it if I can get the syntax right!
What do you have atm?
Diving in now. I'll report back soon.
Nothing. I have nothing yet, because I didn't know which way I would go about it. I thought invisible walls would be easiest, but that didn't work at all.
Do you think this would be best placed in the turret's init?
Is this for a mission?
params ["_unit", "_weapon", "_muzzle", "_mode", "_ammo", "_magazine", "_projectile"];
Sorta. It's for a training environment. I want autoturrets to fire at people when they are visible, so that they will get to cover.
But I don't want to kill the people, because on our server, death is a pretty big deal.
I posted everything you need. Just 3 legos you have to put together
Thanks a ton!
If it's for a mission, then I'd use the init box
Init box of the turret?
Yeah
Thanks a ton! I'll let you know if I get it working.
Remember to use a local check, because the fired eh triggers everywhere and deleting a projectile is global and at machine gun speed, you don't want to do unneeded network traffic and red chain the server
A local check?
local _unit
I don't understand the context, unfortunately..
Oh. Okay! The MG will be on a dedicated server, if that matters.
No, it doesn't. Ideally you make your scripts work regardless of who owns the object or who is the server, but that is not the trend these days.
Haha, okay, roger.
and yes i even tag private vars
madness
it would be a sad little number forever
it would be a sad little number forever
And adding new ehs starts over at index 0
which is the worst part
Just make the event handler self removing
it's OEF, so set a last frame no
And add a new one if that diverges to far
if you're worried about cheaters removing it
Okay, what else do I need to know?
this addEventHandler ["Fired", deleteVehicle _projectile];```
I get expected nothing.
Invalid number in expression.
I'm trying to fake blank firing autoturrets for a training environment.
Or just make them fire high.
When I pasted your script into the turrets, I get invalid number in expression error. Not sure of exact context.
Worked perfectly locally! Now I just need to test it on dedicated. Thanks so much!
@tough abyss and @little eagle, thanks a ton! Script is working locally. Will test on dedicated soon. If this works, the applications for my group will be expansive!
What are the pros and cons to having 1 while loop that runs every second that I add different functions and checks to or having a seperate loop for every function and check? Does the engine handle this on it's own? Would the end result being the same in both cases?
Enjoying is different than having good performance ๐
Squeeze performance out of EVERYTHING
I don't think the quality of life can decrease any further. Would having a loop for caching groups of units rather than spawn a script for every group separately be worth it?
Can't figure out anything better to do...
Don't custom events run on every frame?
aah
Oops
I used {}, 5 ] call CBA_fnc_addPerFrameHandler;
Does the 5 still cause performance loss?
Better to use while { } do {}
?
No lol
Well, I don't want it to constantly run. Just every 5 seconds
depends on the condition that you're testing but while { true } do {} probably could use a sleep ๐
And in theory, the last run must be complete before a new one is started
^ this is scheduled?
It'll not run a new one before the last one is done
So using PFH in a situation like this http://i.imgur.com/a9rBDTR.jpg is completely wrong
What does sleep actually do?
And scripting in the scheduler has overhead for every command used
they check runtime after each command to manage the scheduler
you're still making up in the end
Isn't the myth that using sleep in scripts lags out the engine true?
Idk what that means
sleep ends the execution of the current pseudo thread and puts it on the end of the stack of all the other pseudo threads
For some reason, whenever I use sleep in a script. I feel like it's taking something away. And the more of those I use, the more I feel like something is taken from me.
So the scheduler can continue with the next item
The real problem here is, that you broadcast a variable every 5 seconds
Idk, but that doesn't sound very optimal
Doesn't the thread get cluttered with throwing the pseudo threads into the end all the time?
Only 1 variable is broadcasted along the net
The more threads you have, the longer it will take for them all to complete
Thanks. That actually makes it a lot easier to read.
Well having less threads is what I'm trying to achieve here
And if you're machine is busy and the stack is huge, e.g. from spawning fish, then a sleep 5 can take 15 seconds to resume
It's put on the stack with a timer and the game checks every frame if the time has passed
each thread has a timestamp which when it's expected to resume
So. Having sleep sounds so bad, because it's checked every frame
Dunno if the scheduler sets times by itself when it thinks a script is slow or if it's reserved for sleep/uisleep
Of course it is checked every frame. The difference is that it's done in C++ land, but the PFH logic that does this similarly is pretty lightweight
I'm just telling the truth.
You do that.
You're the red one, I'm the blue one
Perfect antagonsts
We make a show for the others to enjoy.
He's just presenting knowledge based on information he's got on the subject. No one is really never wrong or correct. Just misinformed.
Dunno why people think a sleep command isn't checked every frame either. I mean, it's not magic, someone has to poll it.
So 2?
Idk how to read this
[spawn-ed, execVM-ed, exec-ed, execFSM-ed]
as if the first two make any difference
flares
?
There are some hard coded ones
I mean, the game intro for example is made with SQS
Ok, a small thought. I don't want my script to run FAST. I want it to cause less stress on the machine running the script in total. Wouldn't running as many things as possible using spawn instead of everything running in one loop be better?
~1
1 cutRsc ["SplashBohemia", "PLAIN"];
0 cutRsc ["SplashNoise","PLAIN"];
~4
if (isClass (configfile >> "CfgPatches" >> "A3_Map_Tanoabuka")) then {1 cutRsc ["SplashArma3Apex", "PLAIN"];} else {1 cutRsc ["SplashArma3", "PLAIN"];};
~4
1 cutRsc ["SplashCopyright", "PLAIN"];
~3
titleText ["", "PLAIN"];
exit
startupScript.sqs
Dunno what you mean by "fast". Fast means less stress.
I don't want the script in hand to be executed in the span of 5 seconds. If it would cause less strees, I wouldn't mind running it on 6 seconds instead
He doesn't want it all in one frame, but using fast commands means exactly the same as less stress
Yes. The least stressful way is what I am in search of
In theory. If I run everything As Fast As Possible, it's gonna cause a small hickup. This does not currently happen (atleast with [hashtag]montior 0.1).
Measure it, nigel.
If you can't tell the difference, then it doesn't matter evidently.
But I don't understand the concept of measuring script performance. I tried a few times. Never managed to get it to work
You put your code into the debug console and press the code performance button. You have to use unscheduled environment for that though
I want to build on this and add more functionality. Currently it does not have a huge problem even with 144 groups. But I need to add more features and ideas keep popping up.
Yeah, don't do too much in one frame
The PFH thing is not a replacement for huge loops.
For huge loops use _____ .
๐ฆ
The PFH would ensure that it runs every X seconds
But that frame
where it runs
everything runs
And that could end up being a slow frame
And don't make gigantic loops to begin with.
@little eagle For caching 100 groups of units. Would it be better to have 100 loops or 1 loop ? I think for this gigantic loop is better
Well I'd say use event handlers
Or check one group, then the next time the other
etc. etc.
have a variable that ensures that you check only one group every time
and increment that
if you end at the last group, set it back to 0
And run that on every frame?
That means that your code works the same with 1000 groups as it does with 1
Or every 0.1 seconds idk
depends on what you do and how large your array becomes
That would mean for 100 groups it takes 100 frames.
That's a good idea
Cannot have above 144 groups per side
They liftet it
WHEN
or soon they will
aah, this makes more sense
dev?
Ok. the miricle of 64 bit is surely a great one
Anyway, baers state machine implementation works like that
only check one item of a potentially huge list
Basically your own super simple scheduler
except less retarded already
haha, yes ๐
You also pointed out eventhandelers ?
How often do eventhandelers usually check themselevs?
Never
if you kill a unit, the logic that kills the unit calls all the event functions
otherwise they just rest in memory
You could make your own event handlers that use polling of very simple states
How is this possible?
I mean
The creation of event handlers?
It's easier with an example I think
@peak plover Prepare yourself for a 50 Pages .pdf File.
I'd really love one. My last 50 pages .pdf was DAC documentation. Best book I've read on a computer to date.
DAC?
Dscha, you would read my SQF book too if I wasn't too lazy and the whole thing too unprofitable. Admit it.
Nah, i would watch at my own files and think: "Oh boy, why did i even started learning SQF."
ah, kk
I don't think you're doing it right when you use SQF like how it was intended.
You mean, i should arma it?
I think using a custom simple scheduler with PFH would benefit ai modifications like VCOM a lot.
"fn_animalBehaviour_mainLoop","A3\functions_f\ambient\fn_animalBehaviour.sqf".Tried out the diag_activeSQFScripts.
a few messages per second
light spam
Fix your error. Not only the logging slows down the game, but also the error itself.
Writing to a huge file on hdd will slow down the server
How much? Idk
Depends on the machine I guess
And yeah: .rpt Spam can slowdown your Server.
problems as AI spawn in midmission
Do you have CBA?
wait
solution incoming
Incompatible classes are listed at game start
game
["CAManBase", "init", {
params ["_unit"];
_unit spawn {
_this setSpeaker "NoVoice";
};
}, nil, nil, true] call CBA_fnc_addClassEventHandler;
replace you allUnits loop with this and it will handle spawned in units
setSpeaker does not work in the frame you spawn the unit
What?
pretty much the only way
Who knows.
Hey, is it possible to do a linebreak in the text of an RscButton
try
/n
or
\n
or
<br\>
or however that's supposed to look like
If those don't work, then the answer is "no".
Btw.
I found another reason why select sucks so much.
It does all these needles out of bounds checks too
Like complain if you select +2 out of bounds or minus one
So those are more reasons why it's slower than expected
Not that that changes much.
But it essentially also reads the array size like count does.
Otherwise the error trap wouldn't work obviously.
am I right that SQF positions are [x,y,z] but the sqm positions are [x,z,y] ?
sounds like an easy thing to test
yeah, just confirming
did you confirm it to be true or false?
not yet
there's no way to read a terrain which isn't the current world right? e.g find out every type of building classname on Stratis while worldName = Altis
@little eagle Select is bad? What's a better alternative?
param is the better alternative @peak plover
I'm trying to make an animation happen on the turning out of the commander, for which I put this in the subclass class Eventhandler of my vehicle class.
TurnOut = "if ((_this select 1) == commander (_this select 0;) then {(_this select 0) setdamage 1;};";
You can ignore the setdamage part, it's just for testing. Pretend it runs a script :p
But it doesn't seem to work.
I have a script that on key press skips time back and forth and hints the current mission time and all works fine in MP local host, but I need to move it to a dedicated server. The working script was in initplayerlocal.sqf. Where does it need to be for all players to get the script for keybinds and see the hints?
Does anyone know if there's a way to simultaneously apply a scripted event or state to all instances of an object type? I've made a helo training mission for a few guys in my team & have a pattern of the portable helipad lights marking out LZs they can try & land in. I'd like to make them blink in a pattern rather than just all at once, I was thinking I'd disable simulation on the outer ring of lights then reenable it by script after a half a second from mission start or something. Is there a command vaguely like "enablesimulation false for each {CLASSNAME}" or something along those lines?
@wispy patio You cannot use a semi-colon inside parenthesis. Syntax error.here: (_this select 0;) Check the RPT and use -showScriptErrors
@broken mural initPlayerLocal.sqf ...
@warm lintel It is not, except if you use CBA which then it totally is.
Does anyone have experience on UI element pip camera view? I've got a thermal view of a camera but for some reason when the script initializes white is all bright and fine but in a second or two it dims down to light grey.
@little eagle even this doesn't do anything for me in game http://pastebin.com/00z2WbWb
hmm. We ironie implemented a config based turnOut EH on our Eagle IV today and it totally worked.
Are you using an actual hatch?
Try without the subclass maybe
Already did, doesn't do anything
How do you call it?
I'm using the commander hatch.
And you are sure, that you open up the right hatch?
class EventHandlers: EventHandlers {
init = "if (local (_this select 0)) then {[(_this select 0), """", [], false] call bis_fnc_initVehicle;};";
// Noch nicht in CBA darum hier!
TurnIn = "if((_this select 2) isEqualTo [0] ) then {(_this select 0) animate ['open_hatch', 0]};";
TurnOut = "if((_this select 2) isEqualTo [0] ) then {(_this select 0) animate ['open_hatch', 1]};";
};
Or using the right slot etc
this works for me
I've tried them all as a matter of fact.
okie dokie looks like I'm stuck on a silly problem; trying to skiptime for the entire dedicated server. I got the keydown issue resolved but it's not actually skipping time.
This is what I have;
-1 remoteExec ["skipTime", 2, true]; //back 1 hour
But it should fire on all 'normal ones' right?
"normal ones"?
Kot, remove that JIP param, or you break it for JIP actually
Does it matter I didn't inherit from the base eventhandler class?
@little eagle alright I changed that, but would that cause skiptime not to actually fire for currently connected players?
You should, because you delete the other eventhandlers otherwise
It still would. JIP is just to retroactively execute the command on JIP clients
I never touched event handlers before alright, so bear with me even if I sound very silly. ๐
but they get their start time from the server anyway
So all you'd do is move them another hour into the past
Ah I see.
and that for every execution, because your JIP stack grows each time you use that command
well I dont want that lol
Alright testing again, I may have missed a ; after returning _handled bool
The game should complain about that if you have script errors enabled
who?
plugin for visual code. linting is a tool for languages that gives you feedback on code before you compile and execute.
such as missing a ;
A trained eye, my friend.
Trained by the suffering of having to reload the mission a hundred times.
Tools > trained eye in blocks of 300 lines of code haha
fuck. that.
literally.
lol
I try to not write 300 lines though
true, in all fairness the code should be broken up a lot more
but in var declarations for giant missions :S
alrighty.. trying again.
fullCrew vehicle _unit select {(_x select 0) isEqualTo _unit} param [0, [nil, ""]] select 1
only one liners
What a language. C++ can't compete with this beauty.
/s
Cool, it worked well.
Hmm, I'll have a look at the functions in CBA, thanks @little eagle
wait
^ this one
@wispy patio Maybe it's just borked for commanders. Wouldn't be the first time something new doesn't work in the patch it is introduced.
Hmm I hope not.
You had it working with non-commander slots right?
Is there anything else I need to do except adding the event handler in the config?
Because the turnout event handler should also fire generally when turning out as driver or gunner right?
Thanks @little eagle, you're a champ
Hah, I've just noticed the author credit on that script so I'll assume you definitely know what you're talking about...
I think so. It's a FFV cargo slot in the Eagle actually
Like on those offroaders
Where you can "turn out" and then use the rocket launcher weapons
Those are actually hatches
Well they aren't, but they trigger turn out and that is how we animate the hatch on the Eagle IV
I'd say maybe the hatches on my vehicle are broken, but I wouldn't know how and the animation works.
Because using the logic of the tank would screw up sound attenuation
Yeah, Alias, I've rewritten that shit. The code from A2 times was unbearable.
The diff was hillarious
+1200 lines -4004 lines
And it does more now.
Summer well spend. Now it's cold and I regret it.
http://pastebin.com/r83ePQQh This would be all I'd have to do in order to get a hint every time somebody turns out, right?
Can you show the full thing?
The entire config?
Only the vehicle I guess
We only have one vehicle per config
not counting the retextures or unarmed variants
Some modmakers are a little more organized than others ๐ http://pastebin.com/Q8QmqdQ2
To elaborate my problem https://www.dropbox.com/s/5df186r231yetdc/thermal.jpg?dl=0 On the right when my hud activates and on the left how the white dims after couple of seconds.
This one has the base class http://pastebin.com/JU9QNUYy
oh scratch that.. normal thermals do that too. Must be the VR map.
I don't see the EventHandlers base class anywhere
class EventHandlers: EventHandlers {};
below the physx stuff
that's the 2nd pastebin btw
change that to just
class EventHandlers;
and instead of this:
class EventHandlers: EventHandlers
{
class UK_MBT
{
Turnout = "hint 'EH be working fam'";
};
};
try:
class EventHandlers: EventHandlers
{
Turnout = "hint 'EH be working fam'";
};
I tried that before. I added in the extended one to try and see if that would fix it.
What version are you on?
Latest non-dev branch.
1.66?
cameraOn addEventHandler ["TurnOut", {systemChat str _this}];
use this in the debug console when you're inside the vehicle
that has to work
Doesn't do anything for me, hm.
Does it work for vanilla tanks though?
also
systemChat str (cameraOn addEventHandler ["TurnOut", {systemChat str _this}]);
if you do it like that, what does it print in chat?
It doesn't seem to do anything on vanilla tanks either.
what does the second one print in chat?
systemChat str (cameraOn addEventHandler ["TurnOut", {systemChat str _this}]);
That prints 0.
But it doesn't do anything if you open and close the hatch?
print more in chat
Printed 1 in a vanilla tank.
And nothing if you turn out?
yeah, the code increments by 1 every time
you execute it
but it should print an array without you opening the debug console again
just by turning out
[yourname, yourname, [0]]
or something like that
Yeah, that second little script seems to print one higher each time, whether turned out or not.