#arma3_scripting

1 messages ยท Page 384 of 1

loud python
#

The obvious solution would be to just loop through both arrays

#

but maybe there's already a function that does that?

little eagle
#
private _newArray = (_oldArray select 0) apply {[_x, (_oldArray select 1) deleteAt 0]};

Assuming you don't need the old one anymore.

loud python
#

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?

little eagle
#

Foresight and lack thereof.

loud python
#

๐Ÿ˜

jade abyss
#
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

little eagle
#

Yes, it will keep going forever.

jade abyss
#

without failing

little eagle
#

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.

jade abyss
#

It's not "failing", it continues just endlessly

#

It would just be "shitty written"

little eagle
#

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.

jade abyss
#

ยฏ_(ใƒ„)_/ยฏ

jaunty zephyr
#

btw, anyone ever done a unit testing framework in arma?

little eagle
#

Just make a script with some diaglogs.

jaunty zephyr
#

hm. I thought I had seen a bit of more structured testing code years ago. anyway, thx

little eagle
#

But there is no reason to not just use diag_log instead.

astral tendon
lone glade
#

it creates an invisible waypoint

astral tendon
#

does the AI cancel the this command in some case?

lone glade
#

"thos" ?

#

depends, if you give it a new waypoint via zeus yes

astral tendon
#

i mean, in case they are in combat, under fire or have contact with enemy

lone glade
#

yes, they'll still stay in formation / engage stuff

astral tendon
#

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

lone glade
#

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

astral tendon
#

enable full path planning?

lone glade
still forum
#

@simple solstice The scheduler itself. Or scheduled scripts?

simple solstice
#

the scheduler

still forum
#

What would you want to profile on that?

simple solstice
#

active scripts can be viewed by diag active scripts

#

I guess something like whats loading the scheduler

#

similar view to the diag capture frame

still forum
#

Not easily. My debugger can profile every script that runs in a frame. But it's quite ugly and requires a lot of maintenance

simple solstice
#

I guess so

#

the question is would it be useful

winter dune
#

@lone glade i tried using the pixel grid system, but i cannot make it work with safezones

cedar kindle
#

since when did hideObject allow players to move through walls? ๐Ÿค”

peak plover
#

Dynamic sim/eden?

lone glade
#

@winter dune what do you mean you couldn't make it work?

winter dune
cedar kindle
#

it's eden sp / testing, dunno why dynamic sim would matter

lone glade
#

you're missing safezones there

winter dune
#

i know that, but i think that I've added them wrong and know is showing my dialog in a random position

peak plover
#

Maybe that's when they changed it?

lone glade
#

aaaah, you have to understand safezones first ๐Ÿ˜„

cedar kindle
#

oh, maybe. wtf. then i'll have to scrap this mission

winter dune
#

i kinda know about them, used them before, but this is my first time using the grid system + safezones

lone glade
#

safezoneX is the leftmost part of the screen,
safezoneX + safezoneW the rightmost
safezoneY the top edge
safezoneH the bottom edge

peak plover
#

โ˜

winter dune
#

yep

peak plover
#

y+h?

#

y != 0

lone glade
#

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";
peak plover
#

Also grids are not neccesary, but useful /40 for XandW and /25 for YandH are decent

lone glade
#

X: safezoneX + half of safezoneW to get in the center of the screen, - half of the width of the control for perfect centering

winter dune
#

@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

lone glade
#

now, question, how many grid up from the bottom of the screen will this control be @winter dune ?

peak plover
#

algathes exampe is like always the same amount of screen space, no matter how big the screen is

lone glade
#

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

winter dune
#

the only problem that different interfaces has to do with my dialog, it's with controls based on texts

lone glade
#

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*

winter dune
#

ok, I'll be trying tonight to make it work, otherwise tomorrow I will be here crying ๐Ÿ˜„

lone glade
#

better examples can be found in the 3DEN config btw

winter dune
#

where can I find that?

lone glade
#

in ubined data in the P drive, if it's not there you can use the BIS tools to get it

winter dune
#

๐Ÿ‘Œ

peak plover
#

pixlegrid looks nice

#

Didn't even know about it, thanks

lone glade
#

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

kindred lichen
#

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?

agile pumice
#

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

lone glade
#

you can't do that

agile pumice
#

can't do what?

lone glade
#

use an image in a stringtable

little eagle
#

Sure?

lone glade
#

fairly sure it would error out since it wouldn't be able to find the path

robust hollow
#

thats not the filepath for locked_ca unless you're not on 1.76

little eagle
#

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.

robust hollow
#

\A3\ui_f\data\GUI\rsc\rscdisplaysinglemission\locked_ca.paa
thats what i have it as

agile pumice
#

you can use images in a stringtable

lone glade
#

surprising, what's the point tho?

robust hollow
#

i guess it would make sense if your image had text on it

lone glade
#

use a define for the path, there's no reason to put it in a stringtable

agile pumice
#

"i guess it would make sense if your image had text on it" < this

#

its not actually my stringtable

tough abyss
#

Where does the GUI origin point live?

little eagle
#

Top left.

compact maple
#

Yea stringtable take only text

#

BUT you CAN call a stringtable with parameters

barren magnet
#

@compact maple ? A string table with parameters ?

#

I only know localize "keyword" and "$keyword"

still forum
#

I guess he means format[localize "str", params]

little eagle
#

This?

barren magnet
#

Ok makes sense, I took that one for obviously granted

tough abyss
#

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};
};

lone glade
#

rscText doesn't take structured text as text afaik

tough abyss
#

What does?

lone glade
#

the structured text variant gimme a sec

lone glade
#

RscStructuredText

tough abyss
#

Alright, I'll try that.

#

@lone glade - that did not work.

lone glade
#

try to use ctrlSetText with some "test" string, also privatize your local var

tough abyss
#

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"];

lone glade
#

AAAAAAAH

tough abyss
#

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.

lone glade
#

try using ( around the parseText format

tough abyss
#

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".

lone glade
#

hhahahaha

tough abyss
#

Ok everything works now, I changed the size entry in the config to 0.035.

#

Thanks @lone glade.

tough abyss
#

{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?

subtle ore
#

because your Z is going to be the lowest number of the getPos

#

say I had [1,1,0] it'd always return zero

queen cargo
#

{floor _x} forEach [1, 2, 3] would return 3?

#

gah ... need to adjust something in sqf-vm ...

subtle ore
#

None the less ๐Ÿ™„

tough abyss
#

How would I go about flooring an array then?

queen cargo
tough abyss
#

getPos player apply {floor _x}?

queen cargo
#
position player apply {floor _x}```
tough abyss
#

Basically what I wrote ๐Ÿ˜ƒ

queen cargo
#

yup
just different alias

tough abyss
#

Thanks nontheless.

still forum
#

@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

tough abyss
#
Return Value:
Anything - will return the value of last executed statement
``` Oh yeah, must've missed that.
#

Learning by doing I guess ๐Ÿคท

spiral merlin
#

Anyone know how to tell if a specific position is in view of the player?

still forum
#

You mean. In camera direction AND without obstacles inbetween?

spiral merlin
#

Yes

#

Or maybe just terrain, not objects

#

Either way

still forum
#

My solution would be to math camerapos + view direction + fov and the position.
And if it is then lineIntersects to check for obstacles.

spiral merlin
#

Yeah, I was worried I'd have to do that rather than it already being done

still forum
#

But lineIntersects can also tell you "You don't see him" when there is just a cm thick wooden stick in the way

spiral merlin
#

hmm

still forum
#

I never did that.. Maybe there is a pre-made way.. But I don't know of one

spiral merlin
#

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

still forum
#

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

spiral merlin
#

Yeah, like how the AI can see things or not

ionic orchid
#

you can at least narrow it down with a dot product on the player->pos vector vs view vector

cosmic kettle
#
[cursorTarget,0] spawn function;

works

[cursorTarget,0] call function;

doesn't work.
Anyone that might know why? No sleep or anything in the function.

still forum
#

Can you post the contents of that function? Any error message?

cosmic kettle
#

The spawn returns my errors, call just nothing at all.

#

mind = blown

still forum
#

You are missing a }

#

So I don't see why spawn even works

#

line 47

cosmic kettle
#

Why does spawn work then?

#

Yeah exactly

#

Thanks dedmen, weird, doesn't mikero lintcheck?

still forum
#

no

#

not on scripts

cosmic kettle
#

never used to?

still forum
#

true

cosmic kettle
#

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'

still forum
#

Spawn shouldn't work

cosmic kettle
#

I swear it does

still forum
#

Do you call/spawn from unscheduled script?

cosmic kettle
#

It might have to do with using infistar console

still forum
#

If the script has an error then it won't compile. And your function variable will be Nil.
In unscheduled that doesn't error

cosmic kettle
#

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

still forum
#

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.

cosmic kettle
#

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

little eagle
#

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.

still forum
#

It was missing closing the code block before an else

jade abyss
#

A missing } isn't necessarily a compile error. I think if you do it right it fails silently.
Yep, gave me some headaches sometimes.

little eagle
#

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;
    };
};
inner swallow
#

i've had it complain about missing } though

little eagle
#

True, hence >necessarily

tough abyss
#

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?

little eagle
#

I never liked tutorials.

tough abyss
#

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.

little eagle
#

What's the problem?

tough abyss
#

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.

little eagle
#

Is this for a mission?

tough abyss
#

Yes.

#

But later on it will be an addon.

little eagle
#

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.

tough abyss
#

Which would be better?

#

Addon or mission?

lone glade
#

addon

little eagle
#

Neither is "better".

lone glade
#

mission GUIs are terrible to make

#

inheriting base classes for them is a shitfest

tough abyss
#

Okay first things first I need to know how to make a GUI.

#

What information do I need to know?

little eagle
#

With a config.

cosmic kettle
tough abyss
#

Where do the base classes come from?

little eagle
#

Either description.ext or config.cpp.

#

A3_UI_F

#

Thanks, A3.

tough abyss
#

The pbo file?

cosmic kettle
#

@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

tulip cloud
#

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?

cosmic kettle
#

np commy, I know how much u like tinkering ๐Ÿ˜†

little eagle
#

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.

tough abyss
#

TypeOf

#

In theory.

#

if you want to take a "object name"

#

convert it to a class to be spawn'd?

tough abyss
#

Anywhere that explains how all the GUIs work?

#

And should you use the GUI editor?

little eagle
#

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.

cosmic kettle
#

@tough abyss you really want to learn using arma gui editor?

#

I'll pm you a link

tough abyss
#

That was the mod I took apart.

tulip cloud
#

I'm using it with createVehicleLocal

tough abyss
#

I found his addon was incomplete.

tulip cloud
#

so no netID

tough abyss
#

Added in a Compass etc.

little eagle
#

They still can use those functions, justin.

tulip cloud
#

the objects are 0:0

little eagle
#

The first one always is.

tough abyss
#

What should I use to edit the GUI commy2?

little eagle
#

Pen and paper.

tulip cloud
#

Do I need to create a global variable to keep track of every local object created so that I pull the correct object then?

cosmic kettle
#

Lmao enter 'back in the days' here

#

But he's right, I find myself using (pen &) paper very often.

little eagle
#

I created some slick stuff using pen and paper.

tulip cloud
#

@tough abyss I use Adobe Illustrator. if you have access

cosmic kettle
#

ADC for me

little eagle
#

It would help if you explain what you're trying to do, justin.

tough abyss
#

I still don't know the fundementals of GUI creation.

#

Where it starts
How to build it from the beginning knowing where anything is.

little eagle
#

Step one: create the display/dialog class.

cosmic kettle
#

Step 2: suffer, question life and why you started

tulip cloud
#

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.

lone glade
#

nah, it's quite easy tbh

little eagle
#

I had fun with it and didn't suffer.

tough abyss
#

Where do you find the "display dialog class"?

cosmic kettle
#

Oh c'mon one can't have some fun... Yeah it depends on how far you push things, as always.

tough abyss
#

Doesn't it have base classes?

#

Where do you get the base classes?

little eagle
#

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.

tulip cloud
#

@little eagle it does

little eagle
#

If you say so.

tulip cloud
#

You can give them animation, gear, and when they die you can access their inventory

cosmic kettle
little eagle
#

The controls should use base classes imo (e.g. RscText).

tulip cloud
#

so they are pretty functional

little eagle
#

Soldiers have to be created using createUnit, not createVehicle(Local)

tough abyss
#

@cosmic kettle Still not detailed enough.

cosmic kettle
tulip cloud
#

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.)

cosmic kettle
lone glade
#

NO

little eagle
#

creating an object from a string
Like the classname?

lone glade
tulip cloud
#

@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

tough abyss
#

@tulip cloud No it's just the information strung across the internet thats the issue.

#

And an illogical flow wiki.

cosmic kettle
#

Welcome

tulip cloud
#

I agree geek it's terribly taught everywhere...that is the grind

cosmic kettle
#

And a discord available 24/7 with guys like Commy hanging around all the time ๐Ÿ‘Œ

little eagle
#

You might not believe it, but I'm trying to help.

tough abyss
little eagle
#

I'd say you skip the mission step and do it with addon straight away.

cosmic kettle
#

Just copy-paste the example and try it out, that's the only way to learn.

little eagle
#

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-

tough abyss
#

Okay... guides to making an addon?

little eagle
#

requiredAddons A3_UI_F

#
class RscDisplayEmpty;
class Tag_MyDisplay: RscDisplayEmpty {
};
#

createDialog "Tag_MyDisplay";

#

done?

cosmic kettle
#

10 bucks he still has a lot of ?????

tough abyss
#

^

#

0 Experience with creating addons.

cosmic kettle
#

Honestly all I could do is send you an example

#

but I literally PM'ed you a dialog editor

tough abyss
#

As I said I've reverse engineered other peoples work.

#

But still left a lot of unanswered questions.

lone glade
#

do not use the GUI editor FFS, it's terrible

tough abyss
#

Do you modify the positioning with the editor ever?

lone glade
#

nope, I do it all by hand

tough abyss
#

So how do you determine where everything is?

lone glade
#

safezones + pixelGrid

#

at some point you just end up knowing where everything will be approximately, just restart / use diag_mergeConfig to fine tune

tough abyss
#

...

cosmic kettle
#

basically it's math

#

you figure out positions by calculating what X and Y value you want.

lone glade
#

not if you're using pixelGrid, like any sane human should

#

it's much simpler

cosmic kettle
#

Could be, I'm used to this. ^^

little eagle
#

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?

tough abyss
#

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

little eagle
#

There is a picture on the wiki that explains the safezone stuff.

tough abyss
#

Found it.

little eagle
#

Top left corner is:
safeZoneX, safeZoneY
Bottom right corner is
safeZoneW, safeZoneH

tough abyss
#

You can use either?

little eagle
#

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.

cosmic kettle
#

I PM'ed you the example commy posted earlier, packed in a pbo.

little eagle
#

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";
tough abyss
#

So values in safeZoneX are between negative and 0 ?

little eagle
#

Yes.

#

Same for Y

#

But this would work even if they were positive.

tough abyss
#

So why would you divide a / 2 ?

little eagle
#

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

tough abyss
#

So the SafeZone is simply to prevent drawing things off screen?

#

Defining the limits to which you can have things placed.

little eagle
#

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
tough abyss
#

CWA system

#

What is that?

little eagle
#

I don't know.

tough abyss
#

Absolute (red frame) - based on CWA system. Its always 4:3 and changes together with Interface Size.

little eagle
#

I don't think you want your control to be resized by the interface size setting, do you?

tough abyss
#

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

little eagle
#

Yeah.

tough abyss
#

How come the positions are broken in 4 positions?

#

["0.479375 * safezoneW + safezoneX",
"0.489 * safezoneH + safezoneY",
"0.216563 * safezoneW",
"0.286 * safezoneH"]

little eagle
#

x,y is the positon and w,h is the size.

#

Did I mix them up before? It this ^ anyway.

tough abyss
#

Ohhhh.

#

Right.

#

That makes a lot more sense.

#

So when you say for example convert ScreenSpace to world Space

little eagle
#

Right oops.

#

Let me correct it.

tough abyss
#

if I was to draw a GUI over that object?

#

Would that be the best way?

little eagle
#
x = "safezoneX + 0.5 * safezoneW - a/2";
y = "safezoneY + 0.5 * safezoneH - b/2";
w = a;
h = b;
#

Over what object?

tough abyss
#

So SafeZoneX and SafeZoneY are displacement and SafeZoneW and SafeZoneH is scale

#

Got it.

#

adds to notes

little eagle
#

That's how I use them at least.

errant herald
#

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
#

๐Ÿคฆ

errant herald
#

@lone glade What do you reckon?

lone glade
#

that you should REALLY read the wiki for the "while do" entry

errant herald
#

Sorry, not very proficient in arma scripting

#

Will take a look at it

#

Anything I should look at specifically?

lone glade
#

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

errant herald
#

Yes.

lone glade
#

well, that's where your issue is

errant herald
#

I see.

#

subsitution would be using an if statement perhaps?

lone glade
#

well, no, you'll have to think about what you want to do and find a solution to that

errant herald
#

ok.

manic sigil
#

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.

manic sigil
#

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.

tough abyss
#

@manic sigil You can technically use network programming theory and apply it to A3

manic sigil
#

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?

tough abyss
#

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"

manic sigil
#

Yeah, nothing I've tried has worked :/ Even the debug console has been no help.

tough abyss
#

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.

cedar kindle
#

wouldnโ€™t be the first

simple solstice
#

can you setObjectTexture on it?

vital onyx
#

@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

simple solstice
#

guess you could use find

vital onyx
#

huh

#

did not know setobjectmaterial helps

still forum
#

@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.

simple solstice
#

to find the damage materia

#

put them into array and selextRandom

#

yeah

#

where is mat[] defined?

#

that makes things easy then

tulip cloud
#

@still forum thanks, Commy2 helped me witht he problem and taught me the right way.

meager granite
#

@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

meager granite
#

You're looking at textures, is there anything in hiddenSelectionsMaterials?

worldly locust
#

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

meager granite
#

@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

lone glade
meager granite
#

It only returns user-defined materials

lone glade
#

ah fuck

meager granite
#

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

lone glade
#

what's the prupose matra?

meager granite
#

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

lone glade
#

so, again, what's the intent here? have a "damaged" vehicle that still has 0 damage taken?

little eagle
#

Does setObjectMaterialGlobal even work on stuff not defined in hiddenSelections?

meager granite
#

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

little eagle
#

I see.

meager granite
#

Again, hoping its some general destruction material that will fit everything

#

lol destructed glass gear

#

yeah my second attempt is not really a solution

little eagle
#

Use find in the array Quiksilver posted?

#

And then add 2.

meager granite
#

They issue is that there is nothing to find, barely any vehicles have materials defined

#

*in hidden selections

little eagle
#

I see.

#

Sometimes they have _damage for both DAMAGED and REALLYDAMAGED states.

meager granite
#

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

little eagle
#

Command to set the damage state of simple objects : /

lone glade
#

in the meantime you're probably better off having a normal vehicle with disabled sim

little eagle
#

Ideally the whole system of damage materials would be compatible with hidden textures... Atm damage materials stop working with every object that uses hiddenMaterialsObject.

lone glade
#

ah shit

#

use one of the "pre defined" wrecks then?

#

it's a separate one entirely tho

meager granite
#

What a sturdy jet

little eagle
#

It fell slowly.

meager granite
#

And had a drill on the nose to dig into the ground

subtle ore
#

๐Ÿ˜‚

little eagle
#

I-it fell into a swamp.

lone glade
#

disabled sim + disabled damage should work without needing to search all over the place for that one damaged mat

little eagle
#

Can you bury them under ground or will they physx jump?

lone glade
#

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

cedar kindle
#

but that wouldnโ€™t transmit new pos in mp?

lone glade
#

unless you have 50 of those around the map perf shouldn't matter

little eagle
#

Crashed jets EVERYWHERE

lone glade
#

vehicle pos syncing, especially for a non moving vehicle is barely anything

little eagle
#

I think he means during the mission.

#

Guess it's a tradeoff in this dumb game. Either damaged or simple object.

lone glade
#

have you done any tests ?

little eagle
#

There's a graphic on the wiki.

lone glade
#

the fuck

#

who made that graph, wat

lone glade
#

ah, yes, the famous performance %

little eagle
#

Looks to me like all vehicles are essentially the same.

lone glade
#

% framerate drop that 400 of simulated, disabled, simple and super simple objects on scene cause.

#

yeeaaaaah

worldly locust
#

so no help with dialog?

little eagle
#

What?

#

RscTree
Never used it.

lone glade
#

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

robust hollow
#

only if you redownload the entire game, duplicate the files then its an easy 2 or 3.

tough abyss
#

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
little eagle
#

There are no locations on VR.

tough abyss
#

I know, therefore _neareastLocations isEqualTo [] is true.

still forum
#

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

little eagle
#

Yeah, the array will be empty on VR and therefore NOT error in VR.

#

Because select 0 will be nil

still forum
#

Also not true

#

both will error

#

because the format is always evaluated

#

if in scheduled

little eagle
#

toUpper text ([] select 0)
does not error

#

Even in scheduled it will not error.

still forum
#

wut

little eagle
#

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)
};
still forum
#

I'm 40 minutes away from the next Arma capable computer that I have access to

tough abyss
#

Thanks guys.

little eagle
#

^^

#

param

tough abyss
#

@still forum - as I said it was works everywhere but VR. I checked.

still forum
#

The error you posted only happens when there are locations though

tough abyss
#

Nope.

#

Happens only on VR.

still forum
#

does text nil return empty text?

tough abyss
#

Can't check atm.

still forum
#

Did you fix your error and retest?

tough abyss
#

Sorry ๐Ÿ˜•

#

Not yet fixed, away from PC atm.

#

Will update once I tested.

little eagle
#
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)];
};
lone glade
#

at this point it's preference

little eagle
#

Masochism.

still forum
#

It's also performance ๐Ÿ˜‰ if doing it the commy way

austere granite
#

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 ๐Ÿ˜„

still forum
#

Either it's short. as in 40 chars max.
Or you spread it out and indent it cleanly over multiple lines

little eagle
#

Wait no.

#

^^

austere granite
#

too late now commy

little eagle
#

^^

austere granite
#

NEAR: In the middle of nowhere

#

tbh

#

SAD

little eagle
#

You forgot to uppercase it.

austere granite
#

ah yea

#

damn

#

๐Ÿ˜ฆ

little eagle
#

ahaha

#

redeemed

#

?

still forum
#
private _locationText = text "In the middle of nowhere";

if !(
    _neareastLocations isEqualTo []
    ) then {
    _locationText = text 
    format 
    [
        "NEAR %1",
        toUpper 
                (
                    _neareastLocations select 0
                )
    ];
};

:3

austere granite
#

needs more ugly indenting

still forum
#

Does actually look worse than expected

worldly locust
#

what's the issue with indents?

little eagle
#

The issue with ugly indenting is, that it's ugly.

worldly locust
#

well I like it as I read it easier

little eagle
#

Then it wasn't ugly. Idk what you're trying to say.

tough abyss
#

I may or may not be using select because I recently found out you can use like in the above example... ๐Ÿ‘€

little eagle
#

Could and Should

tough abyss
#

The... Param Syndrome.

little eagle
#

Still better than = if

tough abyss
#

What's bad about _var = if?

little eagle
#

It reminds the reader that this is SQF.

still forum
#

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

little eagle
#

That's horrible, make it stop.

tough abyss
#

I like it.

still forum
#

or even [] spawn ({} else {} select <condition>)

tough abyss
#

-4557๐Ÿ“•๐Ÿ“•๐Ÿ“•๐Ÿ“•๐Ÿ“• +6547๐Ÿ“—๐Ÿ“—๐Ÿ“—๐Ÿ“—๐Ÿ“—

still forum
#

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

queen cargo
#

what about sqf _var = if(<condition>) then [{<true>}, {<false>}];

little eagle
#

Have we gone full circle?

candid jay
#

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

little eagle
#

Simple object.

candid jay
#

that cannot be done at runtime

#

but I could disable simulation, I guess?

little eagle
#

Sure, dunno if that stops the animation though.

candid jay
#

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

little eagle
#

animateSource will not work for an animtation using "time" as source. We had this discussion last week.

#

They all have to be "user".

candid jay
#

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

little eagle
#

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.

candid jay
#

i wrote the model

little eagle
#

Ah.

candid jay
#

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

little eagle
#

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.

candid jay
#

and hide a selection?

little eagle
#

Yeah. Hide one of the proxy.

candid jay
#

so the user script would hide a selection

#

why proxy

little eagle
#

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.

candid jay
#

that's a good idea commy

#

not sure how to hide a selection in a model though

little eagle
#

That how the fan works on the BWA3 box.

candid jay
#

any pointers welcome

little eagle
#

Never used a hide type user anim?

candid jay
#

no

#

i can set to hide indeed, and then how do I change it scripting

little eagle
#

mil animate ["my_hide_anim_animated", 1];
mil animate ["my_hide_anim_fixed", 0];

#

to make it stop

#

and vice versa.

candid jay
#

so like windows

#

thank you commy, really great idea.

little eagle
#

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.

candid jay
#

not sure I got exactly how to do it but will give it a try

#

thanks

queen cargo
#

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

still forum
#

But that's not a benefit over my call select code stuff

candid jay
#

@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

manic sigil
#

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.

candid jay
#

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

lone glade
#

cursortarget?

tough abyss
#

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

little eagle
#

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.

still forum
#

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

little eagle
#

Long awaited intercept feature. Emoji variable names.

queen cargo
#

you can do it in sqfvm if you want to @little eagle

still forum
#

sqfvm doesn't comply with SQF stuff! SQF doesn't support non alphanumeric characters in the C locale

queen cargo
#

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

still forum
#

You mean after you set _EHVar _EHVar is still nil?

agile pumice
#

yeah. I think I might try something different though so

tough abyss
#

Anyone know how to draw lines using scripts?

#

Similar to how you draw in the map in A3?

tulip cloud
#

Is there a efficient way to look through all the graphic assets in arma?

still forum
#

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.

tulip cloud
#

alright extracting them ๐Ÿ˜„

tulip cloud
#

What is the best way to get height for drawIcon3d. If the player goes prone it is floating too high over their head.

jade abyss
#

check for the Stance ๐Ÿ˜„

tulip cloud
#

per frame? sounds pretty intense.

jade abyss
#

Not rly

#

small switch(), done.

#

(with standing, kneeling at first entrys)

tame portal
#

nested if statements are faster than a switch, isnt it?

#

(atleast in sqf)

jade abyss
#

Yep

#

if !standing -> inside that check for kneeling exitWith -> after that is prone-check

meager granite
#

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

agile pumice
#

I tried to attach oranges to the player's eyes by guessing the offsets for the head position

#

I gave up XD

tulip cloud
#

ok thanks Sa-Matra.

old glade
#

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]

noble pond
#

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

subtle ore
#

the fastest would be to just flatten it out. Which I doubt you want to do in this case

old glade
#

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

subtle ore
#

Right

old glade
#

Plus, i'm also turning two arrays into a single alternating array

subtle ore
#

What are you using this for exactly?

still forum
#

I'm running into an error in a loot spawning script I wrote
I'd guess loot spawning. And choosing what loot to spawn

tame portal
#

๐Ÿค”

plucky beacon
#

Do I need to pay for this loot box? knee slap

subtle ore
#

@plucky beacon That'll be #350 please

old glade
#

lol

#

god dammit

plucky beacon
#

๐Ÿ˜…

old glade
#

nah it's epoch style loot configs for exile

#

and maybe other stuff

plucky beacon
#

wait you're telling me they're free?

#

alright I'll stop

still forum
#

epoch style exile? weren't exile and epoch different things?

old glade
#

my programming playlist just turned into elvis music 0.o

#

oh

subtle ore
#

Evlis...hmmm

old glade
#

that was actually one of the songs in bladerunner

#

nvm lol

subtle ore
#

I think you're the devils spawn and you're trying to send me a message

#

EVIL

#

EEEVVVIILL

old glade
#

lol

#

dammit

subtle ore
#

heh

old glade
#

I've never run into a scalar conversion error before

#

and now it's gone

#

code still doesn't work lol

subtle ore
#

check your rpt

old glade
#

ik lol

#

my logging function is blank -.-

subtle ore
#

try logging the var before and after conversion

subtle ore
#

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?

noble pond
#
pos1 getDir pos2 ```
#
pos2: Object, Position2D or Position3D - to where```
#

@subtle ore

subtle ore
#

How the hell did I miss that?

noble pond
#

BIS_fnc_dirTo also works, although it just feeds straight into getDir now

subtle ore
#

yeah I need my precious 3 Ms of execution time for bigger things another day

old glade
#

lol

noble pond
#

i had to look it up to make sure it was getDir that got that functionality lol

old glade
#

Yeah it does

subtle ore
#

Yeah I wasn't quite sure

#

thanks though

old glade
#

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

noble pond
#

i use it for object placement in a circle, easier to use than trig

old glade
#

lol

noble pond
#

maths are shit

#

i can do th ebasics and thats about it

#

trig goes way over my head

subtle ore
#

Trig is nice if you absolutely need it I guess

old glade
#

it is

#

vector math sucks tho

#

also

#

Bi's rotation vectors are really annoying

subtle ore
#

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

old glade
#

I've never been able to figure them out

#

Mainly bi's vectorDirandUp

subtle ore
#

Yep

old glade
#

two normalized vectors

#

fml

#

why can't it just be nice like

#

[rotationx,rotationy,rotationz]?

#

or better

#

rotationx rotationy

subtle ore
#

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?

old glade
#

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

agile pumice
#

lol wut

old glade
#

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

subtle ore
#

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

lone glade
#

you probably didn't private your vars and it's being redefined somewhere else down you scopes

subtle ore
#

heh, that seems to be a problem in this channel of recent

noble pond
#

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.

lone glade
#

wrong channel for that

tulip cloud
#

What is the best way to detect that someone presses escape to close a dialog?

lone glade
#

onKeyDown EH / DIK code for escape as shortcut for the close button

tulip cloud
#

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?

lone glade
#

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

subtle ore
#

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

lone glade
#

forgot to mention that, altho it's in the big yellow warning on the second link I posted

subtle ore
#

true, but sometimes people miss it

#

ยฏ_(ใƒ„)_/ยฏ

rotund cypress
#

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?

lone glade
#

use a default case, that way you don't have that behavior

rotund cypress
#

Of course, however still weird that it returns true

lone glade
#

eeeeh, imho it shouldn't return anything but eh

rotund cypress
#

Exactly

compact maple
#

Hello, is there a way do save logs in a specific files and not in the rpt ?

real vessel
#

Is it possible to create a mutex in sqf, and if so what is the simplest way to achieve this behaviour ?

barren magnet
#

@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] )}

real vessel
#

yep, but since its not atomic I cannot guarantee reliability to use it as an entrance criteria for a critical section.

barren magnet
#

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

real vessel
#

and interesting challenge without atomics. Since its so common in concurrent programming, I assumed that i was not the first to have the issue

barren magnet
#

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

real vessel
#

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

tough abyss
#

@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

still forum
#

@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

compact maple
#

@tough abyss @simple solstice thanks you

tough abyss
#

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)

still forum
#

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

tough abyss
#

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

still forum
#

Ah I see what you mean now..
If you want to have the exchange be atomic you can just do that in unscheduled

tough abyss
#

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

still forum
#

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

tough abyss
#

It still happens, you can test it out yourself

little eagle
#

Dedmen, it happens if you believe.

tough abyss
#

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

still forum
#

Just stop using scheduled. Problems solved ๐Ÿ˜„

gleaming cedar
#

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

still forum
#

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

tough abyss
#

It happens with remoteexeccall which is unscheduled

still forum
#

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

tough abyss
#

no point mentioning the bug here, wont get fixed

still forum
#

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

manic sigil
#

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?

still forum
#

What "name" ? Classname or displayname or variable name?

manic sigil
#

Is this case I believe display name.

still forum
#

No. It can't.

manic sigil
#

My 'add to zeus' script works fine, but getting control of the pieces of the aircraft carrier is kinda haphazard at best.

still forum
#

But you can use it to get all objects and then filter manually

manic sigil
#

That'd work too.

still forum
#

allMissionObjects select {>_x is the object. use config commands to get displayName and filter it>}

manic sigil
#

Solved: >entities [[], ["building"]] turned out to be far more elegant a solution.

little eagle
#

If you know what you're doing then there is no reason to ever use the scheduler. Also Quiksilver is an idiot.

tough abyss
#

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

little eagle
#

Not surprised. Just proofs that you don't know what you're doing either.

tough abyss
#

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

little eagle
#

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

tough abyss
#

That is just something in general I noticed this channel is debating lately

little eagle
#

If the question is, what's fastest, then that's the answer you'll get. Whether you like it or not.

loud python
#

I have a bit of a problem

#

I want to run a script (an intro to a mission) when the player appears

little eagle
#

Like a panning camera?

loud python
#

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?

little eagle
#

initPlayerLocal.sqf

loud python
#

loading screen

#

I mean, I can try again if you're sure it would work

#

but I'm pretty sure it doesn't

little eagle
#

idk, I don't know what the script does.

loud python
#
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?

real vessel
#

@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

tough abyss
#

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