#arma3_scripting
1 messages ยท Page 384 of 1
private _newArray = (_oldArray select 0) apply {[_x, (_oldArray select 1) deleteAt 0]};
Assuming you don't need the old one anymore.
ah, I had thought of a similar approach, but I didn't know how to iterate the second array in parallel
deleting items is a nice way to solve it
btw. why does getMagazineCargo give you a different format that is needed for addMagazineCargo?
Foresight and lack thereof.
๐
X39
Uhm... Wait until sleep should be a script error
Or does sleep actually return something?
commy2
No, and I think it just fails silently and repeats the loop forever (as if it were false).```
iirc you can add it directly in there and it executes as normal
```sqf
waitUntil{systemchat str diag_tickTime; sleep 1;};```
Just like a WhileLoop
Yes, it will keep going forever.
without failing
Well, going forever is what I meant by failing. If you intend it to go forever then that's what you want.
Usually it's supposed to continue at some point.
Some people would expect it to throw an error if the return value is nil. Just like it does when the return value is anything else than nil or a boolean.
ยฏ_(ใ)_/ยฏ
btw, anyone ever done a unit testing framework in arma?
Just make a script with some diaglogs.
hm. I thought I had seen a bit of more structured testing code years ago. anyway, thx
it creates an invisible waypoint
does the AI cancel the this command in some case?
i mean, in case they are in combat, under fire or have contact with enemy
yes, they'll still stay in formation / engage stuff
and if this command is give to a unit he will also cancel this if he is in a group and return to formation?
or he will make the move first and then go back
this just add an invisible waypoint
so the whole group will follow it
for individual units you have to give them a doStop order and then doMove, and since pathing is kinda fucky you also have to enable full path planning for those so they get stuck less
enable full path planning?
use https://community.bistudio.com/wiki/setDestination with "LEADER PLANNED" to force full planning
@simple solstice The scheduler itself. Or scheduled scripts?
the scheduler
What would you want to profile on that?
active scripts can be viewed by diag active scripts
I guess something like whats loading the scheduler
similar view to the diag capture frame
Not easily. My debugger can profile every script that runs in a frame. But it's quite ugly and requires a lot of maintenance
@lone glade i tried using the pixel grid system, but i cannot make it work with safezones
since when did hideObject allow players to move through walls? ๐ค
Dynamic sim/eden?
@winter dune what do you mean you couldn't make it work?
this is a part of my work: https://pastebin.com/urRqcx79
it's eden sp / testing, dunno why dynamic sim would matter
you're missing safezones there
i know that, but i think that I've added them wrong and know is showing my dialog in a random position
Maybe that's when they changed it?
aaaah, you have to understand safezones first ๐
oh, maybe. wtf. then i'll have to scrap this mission
i kinda know about them, used them before, but this is my first time using the grid system + safezones
safezoneX is the leftmost part of the screen,
safezoneX + safezoneW the rightmost
safezoneY the top edge
safezoneH the bottom edge
โ
yep
let's say you want a control perfectly centered of 10 grid height and 160 grid width at the bottom of the screen
x = "safezoneX + safezoneW * 0.50 - 80 * GRID_W";
y = "safeZoneH + safezoneY - 25 * GRID_H";
w = "160 * GRID_W";
h = "10 * GRID_H";
Also grids are not neccesary, but useful /40 for XandW and /25 for YandH are decent
X: safezoneX + half of safezoneW to get in the center of the screen, - half of the width of the control for perfect centering
@peak plover the current dialog that I created works perfectly for Small Interfaces, but I want to make the dialog perfect for all the different interfaces sizes and resolutions
now, question, how many grid up from the bottom of the screen will this control be @winter dune ?
algathes exampe is like always the same amount of screen space, no matter how big the screen is
not unless you use pixelGridNoUIRescale
but tbh pixelGrid UI scaling is either fucked or I missed something
some controls rescale fine, other just shit the bed
the only problem that different interfaces has to do with my dialog, it's with controls based on texts
biggest reason why you should use the pixelGrid system is because it's pixel perfect
and it's a shitton easier to use than safezones and screen percentages*
ok, I'll be trying tonight to make it work, otherwise tomorrow I will be here crying ๐
better examples can be found in the 3DEN config btw
where can I find that?
in ubined data in the P drive, if it's not there you can use the BIS tools to get it
๐
the ONE thing that drives absolutely INSANE with it is that "frame" controls are rendered differently
so there's a single pixel difference between my "panel" control and the bar below it
totally unplayable
Hey, is there a way to create an external camera without losing control of your character?
Like, can I have a camera floating above a player, while they're driving a car?
I'm trying to include an image in my stringtable, but I'm getting an error that it can't be found:
\A3\ui_f\data\GUI\rsc\rscdisplaysinglemission\source\backup\large_64x64\locked_ca.paa
it does indeed exist
Warning Message: Picture \a3\ui_f\data\gui\rsc\rscdisplaysinglemission\source\backup\large_64x64\locked_ca.paa not found
you can't do that
can't do what?
use an image in a stringtable
Sure?
fairly sure it would error out since it wouldn't be able to find the path
thats not the filepath for locked_ca unless you're not on 1.76
That path is longer than what I remember, but I'm not sure. I'd too guess that the path is just wrong, not it being in a stringtable.
\A3\ui_f\data\GUI\rsc\rscdisplaysinglemission\locked_ca.paa
thats what i have it as
you can use images in a stringtable
surprising, what's the point tho?
i guess it would make sense if your image had text on it
use a define for the path, there's no reason to put it in a stringtable
"i guess it would make sense if your image had text on it" < this
its not actually my stringtable
Where does the GUI origin point live?
Top left.
@compact maple ? A string table with parameters ?
I only know localize "keyword" and "$keyword"
I guess he means format[localize "str", params]
Ok makes sense, I took that one for obviously granted
I'm using this SQF params ["_dialog"]; _missionInfo = _dialog displayCtrl 80017; _missionInfo ctrlSetStructuredText parseText format ["<t size = '1' font = 'TahomaB' color='#ffffff' align = 'left'>%1 on %2<br/>Active SQF: %3<br/>Active FSM: %4<br/>Pos: %5<br/>Time %6m<br/>Alive for: 1</t>", missionName, worldName, (diag_activeScripts select 0) + (diag_activeScripts select 1) + (diag_activeScripts select 2), diag_activeScripts select 3, getPos player, floor time]; to change the text in the following class ```CPP
class GVAR(missionInfo): RscText {
idc = 80017;
x = "SafeZoneX + (485 / 1920) * SafeZoneW";
y = "SafeZoneY + (75 / 1080) * SafeZoneH";
w = "(350 / 1920) * SafeZoneW";
h = "(200 / 1920) * SafeZoneW";
type = CT_STRUCTURED_TEXT;
style = ST_MULTI;
size = 1;
colorBackground[] = {0, 0, 0, 0.5};
};
rscText doesn't take structured text as text afaik
What does?
the structured text variant gimme a sec
RscStructuredText
try to use ctrlSetText with some "test" string, also privatize your local var
It's privatized at the start, I didn't bother posting non-faulty code. ```SQF
private ["_overcastSlider", "_lightningSlider", "_fogValueSlider", "_fogDecaySlider", "_fogBaseSlider", "_rainSlider", "_wavesSlider", "_yearBox", "_year", "_monthBox", "_dayBox", "_day", "_hourBox", "_hour", "_minuteBox", "_minute", "_sideList", "_execGlobalButton", "_execServerButton", "_missionInfo"];
AAAAAAAH
I've a feeling that this something on the config side, because doing SQF hint parseText format ["<t size = '1' font = 'TahomaB' color='#ffffff' align = 'left'>%1 on %2<br/>Active SQF: %3<br/>Active FSM: %4<br/>Pos: %5<br/>Time %6m<br/>Alive for: 1</t>", missionName, worldName, (diag_activeScripts select 0) + (diag_activeScripts select 1) + (diag_activeScripts select 2), diag_activeScripts select 3, getPos player, floor time]; works just fine.
try using ( around the parseText format
Rgr, right after the ctrlSetText test.
Ah, I found the problem.
I think...
The text is massive.
I only see the very top of the "test".
hhahahaha
Ok everything works now, I changed the size entry in the config to 0.035.
Thanks @lone glade.
{floor _x} forEach getPos player in debug console's watch field returns 0. {systemChat str (floor _x)} forEach getPos player prints out 3 floored numbers. What gives?
Does {floor _x} forEach getPos player return only the last number of the getPos player array?
because your Z is going to be the lowest number of the getPos
say I had [1,1,0] it'd always return zero
{floor _x} forEach [1, 2, 3] would return 3?
gah ... need to adjust something in sqf-vm ...
None the less ๐
How would I go about flooring an array then?
getPos player apply {floor _x}?
position player apply {floor _x}```
Basically what I wrote ๐
yup
just different alias
Thanks nontheless.
@tough abyss If you would read the wiki page you would know that forEach returns the result of the last run.
Which is probably why it returns 0
Return Value:
Anything - will return the value of last executed statement
``` Oh yeah, must've missed that.
Learning by doing I guess ๐คท
Anyone know how to tell if a specific position is in view of the player?
You mean. In camera direction AND without obstacles inbetween?
My solution would be to math camerapos + view direction + fov and the position.
And if it is then lineIntersects to check for obstacles.
Yeah, I was worried I'd have to do that rather than it already being done
But lineIntersects can also tell you "You don't see him" when there is just a cm thick wooden stick in the way
hmm
I never did that.. Maybe there is a pre-made way.. But I don't know of one
I thought there was
Basically I'm making an improved waypoint, sans distance, and you ccan only see it when it is in view
Thanks for your help
I know there is a command that checks if you can see a specific object. But it's based on AI and isn't super reliable. Can't even find it right now
Yeah, like how the AI can see things or not
you can at least narrow it down with a dot product on the player->pos vector vs view vector
[cursorTarget,0] spawn function;
works
[cursorTarget,0] call function;
doesn't work.
Anyone that might know why? No sleep or anything in the function.
Can you post the contents of that function? Any error message?
Why does spawn work then?
Yeah exactly
Thanks dedmen, weird, doesn't mikero lintcheck?
never used to?
true
Oh fml then I assumed it did. sorry for wasting your time then. Spawn works because it executes untill the missing } then?
the weird thing is the call didn't return any error at all
not even a 'missing something something'
Spawn shouldn't work
I swear it does
Do you call/spawn from unscheduled script?
It might have to do with using infistar console
If the script has an error then it won't compile. And your function variable will be Nil.
In unscheduled that doesn't error
oh, so in the future I could check in this case _return = [] call function and if nil didn't compile?
Because this was tripping me out. aside from the error, spawn worked and call didnt
if _return is nil then your function didn't return anything.
Compile errors are printed to RPT.. Except if you run -noLogs which you shouldn't.
you can check if function is nil.
okay thanks, I have no idea how I could've missed something so obvious
also changed to atom, I'll blame it on that lol
Aww. I wanted to look at it, but >This page is no longer available. It has either expired, been removed by its creator, or removed by one of the Pastebin staff.
A missing } isn't necessarily a compile error. I think if you do it right it fails silently.
It was missing closing the code block before an else
A missing } isn't necessarily a compile error. I think if you do it right it fails silently.
Yep, gave me some headaches sometimes.
Maybe there's a difference between:
[] call {
systemChat str 1;
if (random 2 > 1) then {
systemChat str 2;
else {
systemChat str 3;
};
};
and
[] spawn {
systemChat str 1;
if (random 2 > 1) then {
systemChat str 2;
else {
systemChat str 3;
};
};
i've had it complain about missing } though
True, hence >necessarily
Engine gives back some of the most obscure results when running in non-scheduled particularly when a } is missing.
@cosmic kettle
Exactly what Dscha said.
@little eagle Do you know of any "good" GUI tutorials and should I use the GUI editor in A3?
for GUI?
I never liked tutorials.
Got a good guide?
I am still craving a need for a tactical Heads up display.
Which can use IR grenades, for ID'ing friendlies.
What's the problem?
No idea where to begin.
I did reverse engineer someone elses script
but it still left me with no idea "how the GUI" can be built.
Is this for a mission?
That makes no sense. Why would you first do it for a mission and later port it to an addon. You're doing the work twice. The approach is different for both.
addon
Neither is "better".
Okay first things first I need to know how to make a GUI.
What information do I need to know?
With a config.
@little eagle https://pastebin.com/UuA9S1Z7
Where do the base classes come from?
The pbo file?
@jade abyss yeah I feel you, literally stopped me from progress for a day or two... I just cba to check wth went wrong... I shouldn't code while tired... lol
Is it possible to compile a string to become an object?
I tried the follow without success.
_obj = compile 'myObjName'";
Though it gives me the error Type code, expected Object
without compile it gives the error Type String, expected Object
If I do:
[] call (compile format["obj = "myObjectName"]);
Then it works. What is the proper way of creating an object from an array?
np commy, I know how much u like tinkering ๐
The pbo file?
The PBO file contains the config patch which most of the ui base classes come from.
E.g. RscText or RscPicture.
So for an addon, step one would be to put A3_ui_F in requiredAddons.
Is it possible to compile a string to become an object?
No.
Maybe.
TypeOf
In theory.
if you want to take a "object name"
convert it to a class to be spawn'd?
These can be used to give every OBJECT / GROUP a unique string. str will not work period and there is nothing you can do about it.
And should you use the GUI editor?
Fuck no.
I'm using it with createVehicleLocal
I found his addon was incomplete.
so no netID
Added in a Compass etc.
They still can use those functions, justin.
the objects are 0:0
The first one always is.
What should I use to edit the GUI commy2?
Pen and paper.
Do I need to create a global variable to keep track of every local object created so that I pull the correct object then?
Lmao enter 'back in the days' here
But he's right, I find myself using (pen &) paper very often.
I created some slick stuff using pen and paper.
@tough abyss I use Adobe Illustrator. if you have access
ADC for me
It would help if you explain what you're trying to do, justin.
I still don't know the fundementals of GUI creation.
Where it starts
How to build it from the beginning knowing where anything is.
Step one: create the display/dialog class.
Step 2: suffer, question life and why you started
I'm creating some soldiers on the local client that won't appear across the network. I'm setting their position and clothing after they have been created.
nah, it's quite easy tbh
I had fun with it and didn't suffer.
Where do you find the "display dialog class"?
Oh c'mon one can't have some fun... Yeah it depends on how far you push things, as always.
You could use local variables if you don't like global ones, justin. But I have my doubts creating AI with createVehicleLocal works at all.
The dialog does not need a base class.
@little eagle it does
If you say so.
You can give them animation, gear, and when they die you can access their inventory
http://killzonekid.com/tag/gui/ @tough abyss
The controls should use base classes imo (e.g. RscText).
so they are pretty functional
Soldiers have to be created using createUnit, not createVehicle(Local)
@cosmic kettle Still not detailed enough.
http://killzonekid.com/arma-scripting-tutorials-gui-part-1/ I'm afraid it doesn't get much simpler...
Well maybe they are suppose to be created that way but its working how I got it. I'm just trying to figure out the most efficient way of creating an object from a string. Better than the way I'm doing. (which works just doesn't seem right.)
@tough abyss https://community.bistudio.com/wiki/GUI_Coordinates
NO
creating an object from a string
Like the classname?
@tough abyss Learning the GUI was extremely complicated for me. I still don't fully understand it but you just gotta grind through the steep learning curve. Maybe work off a template to get the hang of the defines and dialog files
@tulip cloud No it's just the information strung across the internet thats the issue.
And an illogical flow wiki.
Welcome
I agree geek it's terribly taught everywhere...that is the grind
And a discord available 24/7 with guys like Commy hanging around all the time ๐
You might not believe it, but I'm trying to help.
I'd say you skip the mission step and do it with addon straight away.
Just copy-paste the example and try it out, that's the only way to learn.
It's way easier if you do it as addon, because you can inherit the base classes and don't worry about the style and type crap-
Okay... guides to making an addon?
requiredAddons A3_UI_F
class RscDisplayEmpty;
class Tag_MyDisplay: RscDisplayEmpty {
};
createDialog "Tag_MyDisplay";
done?
10 bucks he still has a lot of ?????
Honestly all I could do is send you an example
but I literally PM'ed you a dialog editor
As I said I've reverse engineered other peoples work.
But still left a lot of unanswered questions.
do not use the GUI editor FFS, it's terrible
Do you modify the positioning with the editor ever?
nope, I do it all by hand
So how do you determine where everything is?
safezones + pixelGrid
at some point you just end up knowing where everything will be approximately, just restart / use diag_mergeConfig to fine tune
...
basically it's math
you figure out positions by calculating what X and Y value you want.
Could be, I'm used to this. ^^
I thought he's at the "creating the display" step. You'll never reach your goal if you don't do the first step first. Skipping ahead won't get you further.
So you're determined that this should be for a mission?
No not the creating display step. Need to know all the details about how GUIs are built, whats the best practices, how are GUIs implemented, how do you "work out" this math apart from systematically calculating displacement?
By creating a grid and building it based on aspect ratios I have Photoshop yes.
illistrator and InDesign
There is a picture on the wiki that explains the safezone stuff.
Top left corner is:
safeZoneX, safeZoneY
Bottom right corner is
safeZoneW, safeZoneH
You can use either?
You have to use both.
e.g, center of the screen:
safezoneX + 0.5 * safezoneW,
safezoneY + 0.5 * safezoneH,
Hope that makes sense to you.
I PM'ed you the example commy posted earlier, packed in a pbo.
There really isn't anything else that a tutorial could explain about positions that isn't shown in that picture.
Guess you could make a list of techniques on "how to create a control size a,b that is still centered on the screen" etc.
Should look like this:
x = a;
y = b;
w = "safezoneX + 0.5 * safezoneW - a/2";
h = "safezoneY + 0.5 * safezoneH - b/2";
So values in safeZoneX are between negative and 0 ?
So why would you divide a / 2 ?
Because safezoneX + 0.5 * safezoneW is the center of the screen
If you place a control, it's position will be the top left corner of the control.
So the top left edge of the control would be at the center.
But if you want the control to be centered, you have to shift the middle of the control to the center instead
The middle of a control sized a,b is at a/2,b/2
So the SafeZone is simply to prevent drawing things off screen?
Defining the limits to which you can have things placed.
I think it was made for 4:3 bwc.
You can place things everywhere. Even at 1k,1k
But no one will see them.
Every screen will follow:
Top left corner is:
safeZoneX, safeZoneY
Bottom right corner is
safeZoneW, safeZoneH
I don't know.
Absolute (red frame) - based on CWA system. Its always 4:3 and changes together with Interface Size.
I don't think you want your control to be resized by the interface size setting, do you?
GUI editor is still being helpful
Even if it's not to make a GUI
It's showing how the alignment works
I saw what you mean by "0.5 * safezoneW + safezoneX","0.5 * safezoneH + safezoneY",
Left hand corner is placed right in the middle
Yeah.
How come the positions are broken in 4 positions?
["0.479375 * safezoneW + safezoneX",
"0.489 * safezoneH + safezoneY",
"0.216563 * safezoneW",
"0.286 * safezoneH"]
x,y is the positon and w,h is the size.
Did I mix them up before? It this ^ anyway.
Ohhhh.
Right.
That makes a lot more sense.
So when you say for example convert ScreenSpace to world Space
x = "safezoneX + 0.5 * safezoneW - a/2";
y = "safezoneY + 0.5 * safezoneH - b/2";
w = a;
h = b;
Over what object?
So SafeZoneX and SafeZoneY are displacement and SafeZoneW and SafeZoneH is scale
Got it.
adds to notes
That's how I use them at least.
Anyone else having problems with the "while{alive _car}do{" command? Seems to be lagging my server whenever a script is using that command.
and that script has nothing in it besides while{alive _car}do{
๐คฆ
@lone glade What do you reckon?
that you should REALLY read the wiki for the "while do" entry
Sorry, not very proficient in arma scripting
Will take a look at it
Anything I should look at specifically?
it pretty much loops non stop, because that's what it's supposed to do
now, I assume you probably have multiple cars you're watching right? that's a loop for each car
Yes.
well, that's where your issue is
well, no, you'll have to think about what you want to do and find a solution to that
ok.
I'm having trouble understanding addCuratorEditableObjects. My editor's curator name is locked as 'L Zeus:1', but you can't have spaces in the script, and copying the example (curatorModule addCuratorEditableObjects [[car],true ];) doesn't seem to do anything even with multiple cars on the map.
Solved, naming the actual module allowed me to manipulate it, and remembering that 'car' is an object name, not a special class, would help.
Building off this, new problem; is it possible to use addcuratoreditableobjects on the official servers via Admin-scripting? The zeus tokens are supposed to be named bis_curator and bis_curator_1, but the code doesn't work with those in place.
@tough abyss I'll give that a try; I've been running with > {bis_curators addCuratorEditableObjects [[_x],true ]} forEach nearestObjects [PROT, [], 300];
PROT being a spawn protection zone in the script's aircraft base build.
It works in singleplayer and local servers, but official servers. nothing. The spawned vehicles can still be manipulated, bis_curator has a position... but the addcuratorobjects doesn't seem to run.
nested foreach scripts. Whee.
Last try: bis_curator addcuratoreditableobjects [[vehicles],true]
No effect :/
I'll throw in _x foreach allcurators
I thought Vehicles already listed all units >_>
Okay, amalgamation: {_x addcuratoreditableobjects [allmissionobjects โโ,true]} foreach allcurators;
No dice :/
I'll add that I'm currently squatting in an official server testing these >3> I'll bail if anyone comes in, but for right now I can test.
I'll add that.
{_x addcuratoreditableobjects [allmissionobjects โโ,true];} foreach allcurators; >>> No effect
Shoot
remoteexec ["..."]?
Remote scripting is still my major weakness :/
I've had mixed and poor results with the esc screen execution thing :/ Half the time they haven't worked, the other half, only when I try to speed test them.
And it's fine, you're giving me excellent advice.
Yeah, and locality is my worst skill. :/
I should ask Achilles mod team how they managed it.
Yeah, and I keep slamming my head into them t_t AddCurator... is a server command.
@manic sigil You can technically use network programming theory and apply it to A3
I want to ask, and I mean this in as minimally snarky or backbiting way as I humanly can; would that help my current situation or with just my locality scripting in general?
A3 is just another type of Client / Server architecture.
Might help.
Because you if think about things as clients and servers.
Server can do somethings that client can't.
Server for example should be tasked with keeping random stuff randomized
not clients
Some code should never be run on clients either.
Locality is just another way of partitioning the "client server structure"
Yeah, nothing I've tried has worked :/ Even the debug console has been no help.
Most things in locality can be broken down into the following, network propergated / not network propergated. Scope: Side, Object, etc.
But they all derive from core concepts.
init.sqf files "entry points"
initServer.sqf etc.
wouldnโt be the first
can you setObjectTexture on it?
@tough abyss replace with damaged model?
or make animations?
to model itself
are sure changing materials will help? afaik simple objects have limited capabilities of customizaing since there is no config
guess you could use find
@tulip cloud compile returns CODE. ALWAYS. So how do you think would code for some bizarre reason turn into OBJECT?
What you are searching for is how to retrieve the value of a variable.
And the answer is missionNamespace getVariable "myObjName"
Multiple objects just put them into a global array and pass their index around.
to find the damage materia
put them into array and selextRandom
yeah
where is mat[] defined?
that makes things easy then
@still forum thanks, Commy2 helped me witht he problem and taught me the right way.
@tough abyss I'm not config guy but I think count of mat is always multiple of 3 with materials listed in order: undamaged, damaged, destroyed
They're unrelated to setObjectMaterial indexes though
But to get damaged material\texture always get second path out of 3
The logic would be to find hiddenSelectionMaterials in mat array and then apply material with next index, it should be damaged one
You're looking at textures, is there anything in hiddenSelectionsMaterials?
trying to get my first dialog to work. Using a tree view control. Unfortunately it's not showing anything.
my code:
_tree tvAdd [ [],"Parent_A"];
_tree tvAdd [ [0],"Child_A"];
_tree tvAdd [ [0,0],"Grandchild_A"];
_tree tvAdd [ [],"Parent_B"];
_tree tvAdd [ [1],"Child_B"];```
{
idc = 7;
x = 0.26 * safezoneW + safezoneX;
y = 0.3225 * safezoneH + safezoneY;
w = 0.2325 * safezoneW;
h = 0.41 * safezoneH
};```
and this in common.hpp
{
access = 0;
idc = -1;
type = 12;
style = ST_LEFT;
default = 0;
blinkingPeriod = 0; ``` + more usual stuff
Any ideas what is wrong? I look to be getting "a" control, but there's no contents within it
@tough abyss
_str = {toLower(if(_x select [0, 1] == "\") then {_x select [1, 1e6]} else {_x})};
_cfg = configFile >> "CfgVehicles" >> typeOf _this;
_mats = getArray(_cfg >> "damage" >> "mat") apply {_x call _str};
_texs =
{
_index = _mats find (_x call _str);
if(_index % 3 == 0) then {
_this setObjectMaterialGlobal [_forEachIndex, _mats select (_index + 1)];
};
} forEach getArray(_cfg >> "hiddenSelectionsMaterials");
};
The issue is that barely any objects have hiddenSelectionsMaterials defined
why retrieve it from config when you can use https://community.bistudio.com/wiki/getObjectMaterials ?
It only returns user-defined materials
ah fuck
So if you didn't define any, it won't return anything
Its pretty useless as barely any vehicles have materials defined
B_G_Offroad_01_repair_F does for example
what's the prupose matra?
The issue is that mat's and tex's are not listed in any particular order, they're just table of "turn this path into this path if damaged" list
So they're completely unrelated to setObjectTexture\Material indexes
Well you can try selecting mats where index % 3 == 1 (damaged material)
Hoping that first materials will match setObjectMaterial materials
But you might end up having wrong material as they can be in any order in mat array
Ha, this method works alright with all BI content I tested
cursorTarget call {
_mats = getArray(configFile >> "CfgVehicles" >> typeOf _this >> "damage" >> "mat");
{
_index = _forEachIndex * 3 + 1;
if(_index < count _mats) then {
_this setObjectMaterialGlobal [_forEachIndex, _mats select _index];
};
} forEach getObjectMaterials _this;
};
Might be wrong with some mod content though, depending on what order author had their "mat" array
Yeah, it works fine with vehicles with few hidden selections
More complex vehicles get messed up
so, again, what's the intent here? have a "damaged" vehicle that still has 0 damage taken?
Does setObjectMaterialGlobal even work on stuff not defined in hiddenSelections?
Well I guess we need a command to return default material for hidden selection then (I assume there can be several, most used one then?)
No, of course not, you again have to assume hiddenSelections cover entire model so you can achieve it looking damaged.
You can get lazy and just set mat index 1 to every hidden selection
I see.
Again, hoping its some general destruction material that will fit everything
lol destructed glass gear
yeah my second attempt is not really a solution
They issue is that there is nothing to find, barely any vehicles have materials defined
*in hidden selections
Another issue is that materials might list damaged materials for stuff like glass or something minor first
so just picking first damaged material might end up being glass or something instead of some general damaged material that might fit
So yeah some scripting command to return hidden selection material is needed here
Actually materials of selection, why stop at hidden selections
Command to set the damage state of simple objects : /
in the meantime you're probably better off having a normal vehicle with disabled sim
Ideally the whole system of damage materials would be compatible with hidden textures... Atm damage materials stop working with every object that uses hiddenMaterialsObject.
What a sturdy jet
It fell slowly.
And had a drill on the nose to dig into the ground
๐
I-it fell into a swamp.
disabled sim + disabled damage should work without needing to search all over the place for that one damaged mat
Can you bury them under ground or will they physx jump?
nope, you can
just tested in 3DEN, if you spawn it at 0,0,0, damage it, disable sim, damage and THEN place it it works fine
still have to lock it tho
but that wouldnโt transmit new pos in mp?
unless you have 50 of those around the map perf shouldn't matter
Crashed jets EVERYWHERE
vehicle pos syncing, especially for a non moving vehicle is barely anything
I think he means during the mission.
Guess it's a tradeoff in this dumb game. Either damaged or simple object.
have you done any tests ?
There's a graphic on the wiki.
ah, yes, the famous performance %
Looks to me like all vehicles are essentially the same.
% framerate drop that 400 of simulated, disabled, simple and super simple objects on scene cause.
yeeaaaaah
so no help with dialog?
also, those helos are rotorlib ones
now that you mention it, I wonder if SFM just ignore rotorlib stuff until a player with AFM enters it as pilot
... that's very likely, so yes they are all rotorlib enabled
yup, same, it's probably what happens to lessen the MP sync cost, also AI wouldn't be able to stay in the air for 5s
good thing mast bumping isn't a thing in arma
or overtorque, AI rotor disc wouldn't be attached to the helo for long ๐
yes
(got both)
I didn't check for those, but I know the gear is there
yup, it's there
RC is up btw
only if you redownload the entire game, duplicate the files then its an easy 2 or 3.
For some reason this code works on any map besides VR ```SQF
// Get current location text
private _neareastLocations = nearestLocations [getPos player, ["NameCity", "NameCityCapital", "NameLocal", "NameMarine", "NameVillage"], 10000];
private _locationText = [format ["NEAR %1", toUpper text (_neareastLocations select 0)], "In the middle of nowhere"] select (_neareastLocations isEqualTo []);
16:34:37 Error in expression <ate _locationText = [format ["NEAR %1", toUpper text (_neareastLocations select >
16:34:37 Error position: <toUpper text (_neareastLocations select >
16:34:37 Error toupper: Type Text, expected String
There are no locations on VR.
I know, therefore _neareastLocations isEqualTo [] is true.
You are incorrect
this works on VR and no other map
because toUpper doesn't work with text
as that error message already told you
just swap toUpper and text
Yeah, the array will be empty on VR and therefore NOT error in VR.
Because select 0 will be nil
Also not true
both will error
because the format is always evaluated
if in scheduled
wut
Scheduled doesn't error when a command gets nil input.
It errors when you use a variable that is undefined/nil.
Try it.
0 spawn {
toUpper text ([] select 0)
};
I'm 40 minutes away from the next Arma capable computer that I have access to
Thanks guys.
@still forum - as I said it was works everywhere but VR. I checked.
The error you posted only happens when there are locations though
does text nil return empty text?
Can't check atm.
Did you fix your error and retest?
private _locationText = [format ["NEAR %1", toUpper text (_neareastLocations select 0)], "In the middle of nowhere"] select (_neareastLocations isEqualTo []);
I'll never understand why people torture themselves like this.
Just write it as:
private _locationText = text "In the middle of nowhere";
if !(_neareastLocations isEqualTo []) then {
_locationText = text format ["NEAR %1", toUpper (_neareastLocations select 0)];
};
at this point it's preference
Masochism.
It's also performance ๐ if doing it the commy way
not a fan of the select true stuff either
unless they're very short arguments
i do use the blasphemous return = if (true) then { } else { }; though ๐
Either it's short. as in 40 chars max.
Or you spread it out and indent it cleanly over multiple lines
too late now commy
^^
You forgot to uppercase it.
private _locationText = text "In the middle of nowhere";
if !(
_neareastLocations isEqualTo []
) then {
_locationText = text
format
[
"NEAR %1",
toUpper
(
_neareastLocations select 0
)
];
};
:3
needs more ugly indenting
Does actually look worse than expected
what's the issue with indents?
The issue with ugly indenting is, that it's ugly.
well I like it as I read it easier
Then it wasn't ugly. Idk what you're trying to say.
I may or may not be using select because I recently found out you can use like in the above example... ๐
Could and Should
The... Param Syndrome.
Still better than = if
What's bad about _var = if?
It reminds the reader that this is SQF.
It does basically the same as call [{},{}] select
but needs more space and is slower
you can also do
call ({} else {} select <condition>) if you want
That's horrible, make it stop.
I like it.
or even [] spawn ({} else {} select <condition>)
-4557๐๐๐๐๐ +6547๐๐๐๐๐
Why is the red book called "closed book" but the green book is "green book"
if (_book == "red") exitWith {"closed"}
_book
Wow.. If you read that out it does actually say really well what it does
if book is red exit with closed book
I'm sure some people will take my performance advice to heart... Instead of to their brain and do something like
["unknown", "closed", "blue", "green", "yellow"] select ((["red", "blue", "green", "yellow"] find (toLower _book)) + 1)
Also RGB is RBG now
what about sqf _var = if(<condition>) then [{<true>}, {<false>}];
Have we gone full circle?
is there anyway to stop a model animation whose source is time? Thinking about things like Ind_Oil_Pump_EP1.p3d, the oil pump that constantly moves in CUP
Simple object.
Sure, dunno if that stops the animation though.
right
gonna try right now
otherwise the only approach I have is animateSource with some kind of while loop?
because animDone does not work for objects
well disable simulation does not stop the animation
I mean
I'm just trying to have a wheel that rotates around continuously
unless stopped
animateSource will not work for an animtation using "time" as source. We had this discussion last week.
They all have to be "user".
I know
that's what I'm saying: I need to have user as source, and then I need to script some kind of loop
I was hoping to have a way to start an animation and that's that, it would loop
Are you writing the config / model.cfg of the windmil?
Because you would have to do that for changing stuff like this.
Edit the model.
i wrote the model
Ah.
it's a pylon, a cablecar pylon
when the car goes, I want the wheels to spin
if I stop it, then the wheels to stop
right now I either have them rotate all the time, or...
0 = [] spawn {
while { true } do {
pylon animateSource ["wheels_l_source", 0, true];
pylon animateSource ["wheels_l_source", 1];
sleep 1;
};
};
something like that
1 being the animation time
The best thing I know would be making the wheel a proxy and having one constantly rotate while the other stands still.
And then hide one of them.
Certainly better than a scripted loop.
and hide a selection?
Yeah. Hide one of the proxy.
Either the moving one, or the fixed one.
2 hide user anims.
Proxy so you don't have to duplicate the model.
Idk, maybe just copy it.
I don't like to dup things in models, but it doesn't really matter I guess.
That how the fan works on the BWA3 box.
any pointers welcome
Never used a hide type user anim?
How do you provide the ability to hide a part of an object that is also animated (when not hidden)?ย ExampleA door has a camo net attached.When the door is o...
mil animate ["my_hide_anim_animated", 1];
mil animate ["my_hide_anim_fixed", 0];
to make it stop
and vice versa.
I don't know any windows that use "user" hide, but I guess?
You just have to set up the skeletonBones "inheritance" (?) correctly, but if you ever managed to get a helicopter to work, that should be easy.
Because two anims on the same selection etc. etc.
tbh @little eagle there is a benefit to the if then solution over the select one
if the selection is requiring a method call, the method is only callen when the condition actually matches
But that's not a benefit over my call select code stuff
@little eagle the example you gave me though is attached to a user object
I can't seem to find a way to hide one selection and show another based on a user script
I mean, I can easily SHOW the steady wheels by setting them to type hide
and then doing what you are saying
but how do I hide the turning wheels?
because if I set type to rotationx I can not set it to hide obviously
Okay, was going to update with my incredible success, but it seems to have broken the zeus modules, from remote control to time control. Huh.
Okay, I think I just deleted the official map's Zeus module in my cleanup. Restarting and... NOT doing that, worked.
For future reference:
[getAssignedCuratorLogic player, [LIST OF OBJECTS HERE, nearestObjects [PROT, [], 300]], true]] remoteExecCall ["addCuratorEditableObjects", 2];
Adds units added via admin console on the official servers to the Zeus interface. Many thanks go to the Achilles mod team for directing me to their code.
isn't pylon hideSelection ["wheel_l_1", 1]; supposed to hide the wheel_l_1 selection of pylon?
yes, the name is returned in selectionNames pylon
cursortarget?
If there is no geo lod you are prob screwed trying to detect it with any of the line intersects commands. Prob will just have to use nearobjects etc
because if I set type to rotationx I can not set it to hide obviously
You need two animations on the same selection.
One rotation and one hide.
I finally got to test if Arma supports ๐ด emoji...
It doesn't. Only alphabetic characters ("c" locale. So ASCII basically) and _ and numbers for variable and command names
But.... I might have an idea
Doesn't support รรร too. Because only "C" locale... But.. I think you can change the locale
Long awaited intercept feature. Emoji variable names.
you can do it in sqfvm if you want to @little eagle
sqfvm doesn't comply with SQF stuff! SQF doesn't support non alphanumeric characters in the C locale
which is kinda ridiculus and does not rly interesting for commands anyways :3
sqfvm will also error on commands when they are passed a nil
You mean after you set _EHVar _EHVar is still nil?
yeah. I think I might try something different though so
Anyone know how to draw lines using scripts?
Similar to how you draw in the map in A3?
Is there a efficient way to look through all the graphic assets in arma?
You mean... Like the drawLine script commands?
What graphic assets?
And how do you imagine that?
Go through all paa files that exist in any PBO? No.
alright extracting them ๐
What is the best way to get height for drawIcon3d. If the player goes prone it is floating too high over their head.
check for the Stance ๐
per frame? sounds pretty intense.
Yep
if !standing -> inside that check for kneeling exitWith -> after that is prone-check
modelToWorldVisual selectionPosition "head" vectorAdd [0,0,1] ?
Don't think performance difference would be THIS drastic, unless we're talking about 50-100 units at once
But you'll have precise icon position no matter the animation
I tried to attach oranges to the player's eyes by guessing the offsets for the head position
I gave up XD
ok thanks Sa-Matra.
I'm running into an error in a loot spawning script I wrote
I'm using SelectRandomWeighted and I'm getting a BadConversion: Scalar
error
I'm compressing the loot tables into sub arrays to hopefull save execution time
example data: [["classname1","classname2"],0.90,["classname3"],0.2]
won't matter in the end i don't think
you'll piss away more processing time on arrays of arrays of arrays of arrays
each level of depth takes longer to process
the fastest would be to just flatten it out. Which I doubt you want to do in this case
Well
the idea is that if I remove repeated coefficents, the radomweighted will be more efficent
since it won't have to work through duplicates
Right
Plus, i'm also turning two arrays into a single alternating array
What are you using this for exactly?
I'm running into an error in a loot spawning script I wrote
I'd guess loot spawning. And choosing what loot to spawn
๐ค
Do I need to pay for this loot box? knee slap
@plucky beacon That'll be #350 please
๐
epoch style exile? weren't exile and epoch different things?
Evlis...hmmm
I think you're the devils spawn and you're trying to send me a message
EVIL
EEEVVVIILL
heh
I've never run into a scalar conversion error before
and now it's gone
code still doesn't work lol
check your rpt
try logging the var before and after conversion
is there any premade functionality to set a vehicle's direction realitve to it's surroundings?
or am I going to have to whip up my own method?
pos1 getDir pos2 ```
pos2: Object, Position2D or Position3D - to where```
@subtle ore
How the hell did I miss that?
BIS_fnc_dirTo also works, although it just feeds straight into getDir now
yeah I need my precious 3 Ms of execution time for bigger things another day
lol
i had to look it up to make sure it was getDir that got that functionality lol
Yeah it does
I've used it for a fancy physics-object movement script
before setVelocityRelative was made >.>
those were dark days
days filled with trig
and vectormath
i use it for object placement in a circle, easier to use than trig
lol
Trig is nice if you absolutely need it I guess
I think the only thing I ever used it was to find the angle of the weapon and torso of a player
yeah vectors are wonky
Yep
two normalized vectors
fml
why can't it just be nice like
[rotationx,rotationy,rotationz]?
or better
rotationx rotationy
I guess it's honestly just the legacy bullshit they are sticking aroundw ith
it's always been like that iirc
like wtf? Left/Right? Up/Down?
yeah
enfusion pls
I want to believe
I do believe
now if only Keen Software house would fix their shit...
lol
still beating my head against the wall on this lootspawn script
what
the
fuck
it's working
all i did was add debug code?
I'm really really confused
apparently adding a diag_log has made my code work now
welp
lol wut
I have no idea
I assigned a value to a variable then printed that variable with a diag_log and now everything works
i don't even
I guess arma doesn't like oneliners
also it's totally because I moved stuff around, not because the diag_log... But it's funnier that way
I moved stuff to add it to debug output
then it worked
kk arma
You've got to admit though
Arma is pretty customizable in it's mission setting
(setting as in environment) and to further it, extensions and mods
there isn't something like this in your AAA titles. So I guess we're almost like the spoiled child that got too much sugar for one day lol
you probably didn't private your vars and it's being redefined somewhere else down you scopes
heh, that seems to be a problem in this channel of recent
lol the thought of having several year lifetime on triple A titles makes EA executives shit themselves.
fuck that we need releases every year to keep max profit pouring in
letting people change how the game functions? not a chance.
wrong channel for that
What is the best way to detect that someone presses escape to close a dialog?
onKeyDown EH / DIK code for escape as shortcut for the close button
I have no experience with keydown/up events.
display displayAddEventHandler [eventName, code]
How do I know which display to use and how does this effect the way the eventhandler works?
I'm assuming that this script will fire with each keyDown/Up and I have to create a script in code section to check what button was pressed or something?
How do I know which display to use and how does this effect the way the eventhandler works?
UI EHs don't apply only to displays, you can add them directly to controls too https://community.bistudio.com/wiki/ctrlAddEventHandler
I'm assuming that this script will fire with each keyDown/Up and I have to create a script in code section to check what button was pressed or something?
It will fire with each key DOWN, there's a separate event for keyUp, yes you do have to check which button was pressed, the arguments passed are on this page:
https://community.bistudio.com/wiki/User_Interface_Event_Handlers
be wary Justin, the event name isn't going to contain the prefix "On" , it'll always be "KeyDown" instead of "OnKeyDown" in that case
forgot to mention that, altho it's in the big yellow warning on the second link I posted
Is it only me who thinks it's weird that if a switch doesnt find a case that fits variable, it will return true?
Is it only me who thinks in that case, if even a boolean needs to be returned, it should rather be false as for not found?
use a default case, that way you don't have that behavior
Of course, however still weird that it returns true
eeeeh, imho it shouldn't return anything but eh
Exactly
Hello, is there a way do save logs in a specific files and not in the rpt ?
Is it possible to create a mutex in sqf, and if so what is the simplest way to achieve this behaviour ?
@real vessel what came to my mind would be a "mutex" solution that can work globally or locally. You would set a variable on the object you want to lock, or your set a global variable on some broadcaster dummy object, just to share the information.
So your have a function _myfunc1 that works on something like a object or a critical variable, and the first thing you do in that function is to do something like ````global_mtx setVariable["locked", true, true]```
Now any other script that wants access to that variable or object needs a waituntil { !(global_mtx getVariable["locked", false] )}
yep, but since its not atomic I cannot guarantee reliability to use it as an entrance criteria for a critical section.
so it keeps waiting for the var to chance
no its not 100% relyable but its the best attemt that came to my mind
I do not see an engine solution to this, so you need to script it
And the scripting engine is not relyabe when it comes to execution order of different scripts etc
Nor where a script might be paused
Sooo this only works for locking a object or var for lenghty computations
e.g status change every 10 sec or something
and interesting challenge without atomics. Since its so common in concurrent programming, I assumed that i was not the first to have the issue
no you have not been the first. I had a data race for some vehicles in the past, and i solved it by doing what I just said
always worked
I can see how you can get reasonable reliability if the events are infrequent. I use something similar on vehicle ids. But occasionally we'll get duplicant Ids, when the race condition kicks in
@real vessel Make an extension to handle mutexs
You can try todo a mutex in sqf, but it won't work properly especially if you are dealing with remoteexec code etc
Or you can make up a FIFO queue to handle the events etc to avoid race conditions etc
@Lifetap [3CB]#4538 Atomic mutexes don't make sense in Arma. As there is no parallelism
wherever you are in whatever script. There is never another script running at the same time
@tough abyss @simple solstice thanks you
Wrong & wrong ;)
When you not sure where a script a suspended etc, its basically multithreaded but on runs on a single core, you still need mutexes.
You can try rewrite code to reduce the chances of it happening etc
I have also seen & replicated multiple remoteexecuted code getting past a sqf mutex using pushbackunqiue technique
Its easy enough to replicate by disconnecting client from server so it can spam remoteexecuted code, and reconnect to server before client gets booted (default timeout is 90seconds)
Your code inside the mutex cannot be executed twice though.
If you lock the mutex before you enter the script no one can be inside that script twice
My mutexes are just a variable that's true or false
Have done the same with variable, it will get past it. If you test it using remote executed code & d/c client for a few seconds
Ah I see what you mean now..
If you want to have the exchange be atomic you can just do that in unscheduled
It is done in unscheduled via remoteexeccall still happens, i went through debuggin this alot.
I ended up reducing the period serverside it could happen & added timeouts clientside to prevent abuse
unscheduled scripts can't run in parallel though. remoteexeccall happens on networking simulation which is before scheduled scripts
so remoteexec scripts are still quite a way away from your scheduled scripts
It still happens, you can test it out yourself
Dedmen, it happens if you believe.
You are welcome to test it yourself
You just need to remoteexec call it. d/c the client from server so you can spam the requests then reconnect so client sends them all to the server at once
Just stop using scheduled. Problems solved ๐
Hello
How do you make it whenever someone gets shot instead from blood sparks come out?
I want to make a heavy metal armor and when you shoot the person with the armor sparks come out
The optimal solution would be #arma3_config or maybe #arma3_texture for the material.
Scripting you can use drop and Hit eventhandler.. But that would be quite ugly
No.
You just can't write the same crap "I don't care about perf" code in unscheduled.
in unscheduled you can just distribute your load over multiple frames
and sleeping doesn't improve the performance of your script in any way
It happens with remoteexeccall which is unscheduled
same with spawn.. if you sleep.
true
scheduled scripts add overhead to every instruction. And player; are two instructions. as every statement ends with a extra instruction
So the exact same script get's done quicker in unscheduled than scheduled
suspension yes. sleep no
true. in scheduled you only have 3ms every frame.
If I look at ace scripts that run about 0.4ms every frame.. and then the BI scheduled scripts next to that that fill the full 3ms...
you barely notice 100ms
And if you write a unscheduled script that freezes for 100ms in a situation where fps is important you are an idiot
If you don't know how to use unscheduled correctly you should definetly stay in scheduled yes.
true
For things that apparently create problems in scheduled
no point mentioning the bug here, wont get fixed
Put it on feedback tracker and mark it as RC. Wait.. You can't really mark something as RC besides putting it into the title which the devs wil probably ignore..
Maybe in the old tracker
Is it possible to use allmissionobjects to get everything in a mission without a specific name? As in, select all objects WITHOUT 'aircraft carrier' in the name?
What "name" ? Classname or displayname or variable name?
Is this case I believe display name.
No. It can't.
My 'add to zeus' script works fine, but getting control of the pieces of the aircraft carrier is kinda haphazard at best.
But you can use it to get all objects and then filter manually
That'd work too.
allMissionObjects select {>_x is the object. use config commands to get displayName and filter it>}
Solved: >entities [[], ["building"]] turned out to be far more elegant a solution.
If you know what you're doing then there is no reason to ever use the scheduler. Also Quiksilver is an idiot.
There are times when you want non critical code to run slower, when server is under stress.
Same as everything, if u don't know what you are doing you can do more harm than good
Also some people will say the same about u commy
Not surprised. Just proofs that you don't know what you're doing either.
Also some of the debates here are pointless. Ie debating fastest way to structure an if statement, when code readability will prob matter the most to the new script person. Especially for a script that will barely run in mission lifetime
That stuff is interesting to know maybe for some that already knows sqf but it should be in biki for performance tips etc
You're not disagreeing with me. Been saying for months that you should use the most readable method. It's just that I point out when there is a better one (more readable).
I hate people that chat on mobile. zzzZZZ
That is just something in general I noticed this channel is debating lately
If the question is, what's fastest, then that's the answer you'll get. Whether you like it or not.
I have a bit of a problem
I want to run a script (an intro to a mission) when the player appears
Like a panning camera?
nah
screen starts black, text appears
screen fades to normal
some more text appears with infoText
it works when I have the respawn on start option set
because I can run it on respawn and set a local var so it doesn't run again
but if I want players to be positioned that doesn't work
and I don't really know where to run the script
I remember having had this problem before, and what would happen is that it started in the loading screen
and when the player finally was ingame, they'd only see like half of the intro xD
any idea where/when I could run the script so it starts just as the player first sees their character?
initPlayerLocal.sqf
loading screen
I mean, I can try again if you're sure it would work
but I'm pretty sure it doesn't
idk, I don't know what the script does.
if (isNil "intro") then {
cutText ["", "BLACK FADED", 10, true];
sleep 2;
0 = ["30 minutos antes...", -1, -1, 3, 3] call BIS_fnc_dynamicText;
sleep 3;
cutText ["", "BLACK IN", 10, true];
0 = ["Aeropuerto Babylon", "Oeste de Altis"] call BIS_fnc_infoText;
intro = true;
};
can confirm
I can hear the infoText while I'm still on the loading screen
any other ideas?
is there a way to waitUntil the loading screen is gone?
@tough abyss "Or you can make up a FIFO queue to handle the events etc to avoid race conditions etc"
This is only relaible if the FIFO queue is thread safe .... circular argument
deleteAT & append to end of array you can do a queue
If you are very paranoid best thing todo is look at intercept and code something in c++.
Or make up an extension that has simple bool flag if its locked or not.
Personnally sqf mutex will work most of the time, you just need to add some code to client to prevent it spaming requests. If its remotexecute etc