razzored 37 Posted August 10, 2020 How would one go about making a script that defines a bunch of objects as object namespace.. Example if i then later call a ["coolstuff", true] call SomeFunction. How do i make it so that the script knows that "coolstuff" is EVERY ect sandbag and concretewall placed in the mission.. just two objects used as examples. Thanks in advance, any help appriciated 🙂 Share this post Link to post Share on other sites
pierremgi 4911 Posted August 10, 2020 You could use allMissionObjects if I understood what you need. Share this post Link to post Share on other sites
razzored 37 Posted August 10, 2020 @pierremgi Thanks for the reply, sadly that would not work as i only want certain objects, ect all Sandbags and all tank traps.. but not tents, this is again just an example. But due to the specificness, i wanna be able to just use a script to classify all the object names into one array and call using a variable. Share this post Link to post Share on other sites
Sgt. Dennenboom 98 Posted August 10, 2020 I'm sure that what you are asking for is possible, I'm just not sure I understand what you are asking... In your example, what is "coolstuff"? Is it a classname which you use to retrieve all objects with that class? Is it a variable name that refers to a (pre-made) array of objects? Or is it a string parameter that is used inside SomeFunction to run specific functionality? Share this post Link to post Share on other sites
razzored 37 Posted August 11, 2020 @Sgt. Dennenboom a variable i want applied to all objects of a class, including those spawned AFTER mission start. Example The variable would be "IsSandbag" would be applied to all of the sandbags. Afterwhich i will be able to run a secondary script that recognizes them by ["issandbag", true] call Cool_Api_addobjectVariable; So i need something that will do checks for whenever new sandbags gets spawned or made and then applies "issandbag". Just like vehicles can have "IsLocked" or players in ace "IsMedic". But since sandbag is an example and it is regarding more than 1 object type, it would need to check for example - If ["land_sandbag_F", "Concretewall_long", "other_classname"] setvariable Issandbag Share this post Link to post Share on other sites
razzored 37 Posted August 11, 2020 Sorry that my explanation or well, lack thereof is so retarded. I feel like a catholic priest trying to explain quantum mechanics. Share this post Link to post Share on other sites
sarogahtyp 1109 Posted August 11, 2020 this can be used to set/get a variable on/of an object: https://community.bistudio.com/wiki/setVariable https://community.bistudio.com/wiki/getVariable you should just set those variable in ur sandbag-spawning-script... Share this post Link to post Share on other sites
sarogahtyp 1109 Posted August 11, 2020 _checkTime = 30; //check all 30 seconds for new objects allNeededObjectsAreSpawned = false; // set this to true to stop searching for private _classNames = ["land_sandbag_F", "Concretewall_long", "other_classname"] apply {toLower _x}; while {!allNeededObjectsAreSpawned} do { private _newObjects = allMissionObjects select { private _objClass = toLower (typeOf _x); private _obj =_x; (_classNames findIf { _x isEqualTo _objClass } > -1) && isNil {_obj getVariable "coolStuffVariableAsIWantItToHaveOnCoolObjects"} }; _d = {_x setVariable ["coolStuffVariableAsIWantItToHaveOnCoolObjects", myWantedCoolValue, true]} count _newObjects; sleep _checkTime; }; not tested but should set that variable to all new spawned objects 2 Share this post Link to post Share on other sites
razzored 37 Posted August 11, 2020 Hot damn, Thank you so much @sarogahtyp You are a real life saver, i will test it asap, as for the VALUE in example "mywantedcoolvalue" its not something i would wanna think too much over right? I've read up on it, but it really seems pointless, other than having to exist, well atleast in this scenario, i can imagine some scripts and systems where its good to be able to call values using the variable, but here its just there as a technicality? right? Also, the reason for not setting their variable using a spawn script, is because many of the objects will be made in the mission by players ect and multiple other factors where its easier to just have a script keep track of it. Share this post Link to post Share on other sites
sarogahtyp 1109 Posted August 11, 2020 myWantedCoolValue is a placeholder for whatever value u want those variable to have on init Share this post Link to post Share on other sites
pierremgi 4911 Posted August 11, 2020 Or perhaps, you should describe what you intend to do/obtain. Applying a variable on something spawned is perhaps not useful as you can pushback the object itself in an array. 1 Share this post Link to post Share on other sites
razzored 37 Posted August 12, 2020 @pierremgi Well im going to have a script save the objects, so that the playerbuilt fortifications stay around after restarts and what not. However, the script that saves uses those kinds of variables to pick what whether to save something or not. Whenever the save function kicks in, it will save stuff by checking stuff for this : Examples [“canBeMoved”, true] call [“isLocked”, false] call [“isMedic”, false] Hence why i want to be able to save fortifications by having "issandbag" or something like that applied to them. Share this post Link to post Share on other sites
pierremgi 4911 Posted August 12, 2020 profileNameSpace (server or client) can be the tool for that. You can create a variable which is an array profileNameSpace setVariable ["isSandBag",[]] see this post ... and others related to that on forum. Share this post Link to post Share on other sites
razzored 37 Posted August 21, 2020 @sarogahtyp Hey finally tested it, while it may have worked, it sadly did not work exactly as intended, but that could also have been on me. Do you have any knowladge of Hunterz persistance, it would also have to compatible with that. It would seem the object can also be called by "_obj call Hz_pers_API_addCrate;" Thing is, if i were to have it run with example "Land_sandbag_long_F call Hz_pers_API_addCrate;" I don't think it would recognize and save all sandbags. I have read the resources Hunterz included in his work, and have gotten it to work with vehicles and such, but it sadly does not cover Vehicles very well. Not actually asking anyone to read this just to help me. But if someone does stumble by and is intrigued or think they might have a deeper understanding then me.https://pastebin.com/xEqW4sJe Outlined the most important section (the whole document is long, so i made /////// around the most relevant part) Share this post Link to post Share on other sites