Ivanoff.N 61 Posted September 29, 2017 Hi I am having a problem with storing object data. I have an object, lets say it is "Land_Camping_Light_F" and it calls a function. Inside a function: getdir this select 0 //gets me the direction of the object this function is executed by all objects of this class. However I need to store this data for every object so that later I can see where this object was pointing although now it`s direction is different. Is that possible in arma ? Share this post Link to post Share on other sites
das attorney 858 Posted September 29, 2017 // set _myCampingLight setVariable ["direction",getDir _myCampingLight]; // get _dir = _myCampingLight getVariable ["direction",0]; 1 Share this post Link to post Share on other sites
Grumpy Old Man 3545 Posted September 29, 2017 "Land_Camping_Light_F" is not an object, it's a classname of datatype string. _object = "Land_Camping_Light_F" createVehicle [0,0,0]; _object would hold an actual datatype object. "this" does not exist outside of object init fields in the editor. So you either use setVariable/getVariable in an objects init field to store the direction of it, or you adjust your script to accept actual variables, hard to tell without providing further examples. Cheers Share this post Link to post Share on other sites
Mr H. 402 Posted September 29, 2017 _directions = { if (_x == typeOf "Land_camping_light) then {getdir _x;}} forEach (allMissionObjects ""); copytoclipboard _directions; Not tested, just an idea, it might not work. Share this post Link to post Share on other sites
Tajin 349 Posted September 29, 2017 Hadrien, allMissionObjects already includes a filter functionality, USE IT !!! { _x setVariable ["direction", getDir _x]; } count allMissionObjects "Land_camping_light"; Share this post Link to post Share on other sites
Mr H. 402 Posted September 29, 2017 2 minutes ago, Tajin said: Hadrien, allMissionObjects already includes a filter functionality, USE IT !!! { _x setVariable ["direction", getDir _x]; } count allMissionObjects "Land_camping_light"; Cool that's even better Share this post Link to post Share on other sites
Ivanoff.N 61 Posted September 29, 2017 3 minutes ago, Tajin said: Hadrien, allMissionObjects already includes a filter functionality, USE IT !!! { _x setVariable ["direction", getDir _x]; } count allMissionObjects "Land_camping_light"; Will it store many variables for each object ? And if so how to then get those variables and apply them to these objects again ? Share this post Link to post Share on other sites
das attorney 858 Posted September 29, 2017 .................. 1 Share this post Link to post Share on other sites
Tajin 349 Posted September 29, 2017 It stores exactly 1 variable per camping light. Frankly I have no idea what you're trying to achieve there, so only you know where and when to re-apply the rotation. This would restore all of them: { _x setDir (_x getVariable ["direction", 0]); } count allMissionObjects "Land_camping_light"; Share this post Link to post Share on other sites
Ivanoff.N 61 Posted September 29, 2017 56 minutes ago, Tajin said: It stores exactly 1 variable per camping light. Frankly I have no idea what you're trying to achieve there, so only you know where and when to re-apply the rotation. This would restore all of them: { _x setDir (_x getVariable ["direction", 0]); } count allMissionObjects "Land_camping_light"; The idea is you store objects rotation (position or any other data) then you move object then you restore previous data to see how that object was rotated (positioned or other) before it was moved. Is it possible to store it as a string ? Share this post Link to post Share on other sites
Grumpy Old Man 3545 Posted September 29, 2017 18 minutes ago, Ivanoff.N said: The idea is you store objects rotation (position or any other data) then you move object then you restore previous data to see how that object was rotated (positioned or other) before it was moved. Is it possible to store it as a string ? What do you mean by "it"? Do you want to store the object as string? Or the direction? Why are you asking for storing multiple values all of a sudden? You need to be as specific as possible, ultimately describe what you're actually trying to do, instead of trying various probably nonsensical approaches to your problem which could be solved in an entirely different way, everything else will be a waste of time. Cheers 1 Share this post Link to post Share on other sites
Ivanoff.N 61 Posted September 29, 2017 Just now, Grumpy Old Man said: What do you mean by "it"? Do you want to store the object as string? Or the direction? Why are you asking for storing multiple values all of a sudden? You need to be as specific as possible, ultimately describe what you're actually trying to do, instead of trying various probably nonsensical approaches to your problem which could be solved in an entirely different way, everything else will be a waste of time. Cheers The value as a string. For example I get the direction of 180 and I need it to just be a static number, not the dynamic variable. Like I said, place a lantern, e.g set the dir to 130. Store this value. Then rotate this lantern to 220 e.g. Then restore the value e.g. with a hint "previous rotation was 130" Then rotate again to e.g. 300 Then restore the value e.g. with a hint "previous rotation was 220" e.t.c. But I need it to not work with a certain lantern but to all lanterns on the map even those that will be spawned in the future. Share this post Link to post Share on other sites
Grumpy Old Man 3545 Posted September 29, 2017 1 hour ago, Ivanoff.N said: The value as a string. For example I get the direction of 180 and I need it to just be a static number, not the dynamic variable. Like I said, place a lantern, e.g set the dir to 130. Store this value. Then rotate this lantern to 220 e.g. Then restore the value e.g. with a hint "previous rotation was 130" Then rotate again to e.g. 300 Then restore the value e.g. with a hint "previous rotation was 220" e.t.c. But I need it to not work with a certain lantern but to all lanterns on the map even those that will be spawned in the future. Still unsure what you want, when using getDir you'll get a number, but you want to save it as a string for what purpose exactly if you intend to use the number to restore the objects direction at some time? There's some good examples in this thread that show you how to save the current direction of the lantern object as a variable inside its namespace. What would be the sense in saving an objects direction, just to rotate it and set its direction to the previous value? Try this, no idea if that's what you want since your formulation is still vague: _lantern = "Land_Camping_Light_F" createVehicle getposatl player;//place a lantern, at players position for testing purposes _lantern setDir 130; _lantern setVariable ["direction",getDir _lantern];//stored the direction as variable for "_i" from 0 to 10 do { _lantern setDir random 360;//rotate lantern systemchat format ["Previous rotation was: %1",_lantern getVariable ["direction",0]]; _lantern setVariable ["direction",getDir _lantern];//stored the direction as variable again sleep 1; }; I fail to see how this would make any sense though. Cheers Share this post Link to post Share on other sites
Ivanoff.N 61 Posted September 29, 2017 5 hours ago, Grumpy Old Man said: Still unsure what you want, when using getDir you'll get a number, but you want to save it as a string for what purpose exactly if you intend to use the number to restore the objects direction at some time? There's some good examples in this thread that show you how to save the current direction of the lantern object as a variable inside its namespace. What would be the sense in saving an objects direction, just to rotate it and set its direction to the previous value? Try this, no idea if that's what you want since your formulation is still vague: _lantern = "Land_Camping_Light_F" createVehicle getposatl player;//place a lantern, at players position for testing purposes _lantern setDir 130; _lantern setVariable ["direction",getDir _lantern];//stored the direction as variable for "_i" from 0 to 10 do { _lantern setDir random 360;//rotate lantern systemchat format ["Previous rotation was: %1",_lantern getVariable ["direction",0]]; _lantern setVariable ["direction",getDir _lantern];//stored the direction as variable again sleep 1; }; I fail to see how this would make any sense though. Cheers Thanks for the solution guys. Sorry you failed to understand what this is for, but it works exactly how I need it to. Thanks again. 1 Share this post Link to post Share on other sites
Ivanoff.N 61 Posted September 29, 2017 9 hours ago, Grumpy Old Man said: Still unsure what you want, when using getDir you'll get a number, but you want to save it as a string for what purpose exactly if you intend to use the number to restore the objects direction at some time? There's some good examples in this thread that show you how to save the current direction of the lantern object as a variable inside its namespace. What would be the sense in saving an objects direction, just to rotate it and set its direction to the previous value? Try this, no idea if that's what you want since your formulation is still vague: _lantern = "Land_Camping_Light_F" createVehicle getposatl player;//place a lantern, at players position for testing purposes _lantern setDir 130; _lantern setVariable ["direction",getDir _lantern];//stored the direction as variable for "_i" from 0 to 10 do { _lantern setDir random 360;//rotate lantern systemchat format ["Previous rotation was: %1",_lantern getVariable ["direction",0]]; _lantern setVariable ["direction",getDir _lantern];//stored the direction as variable again sleep 1; }; I fail to see how this would make any sense though. Cheers One more question. How to make all lanterns execute my function ? I need to include all those on the map already as well as those that are created mid mission. I use { [[_x]] call NN_fnc_myfunction;} count allMissionObjects "Land_Camping_Light_F"; but that only seems to affect the ones that are already placed but not the future ones. Share this post Link to post Share on other sites
Grumpy Old Man 3545 Posted September 30, 2017 6 hours ago, Ivanoff.N said: I use { [[_x]] call NN_fnc_myfunction;} count allMissionObjects "Land_Camping_Light_F"; but that only seems to affect the ones that are already placed but not the future ones. Trick question, do the future ones exist yet? How to implement a solution is entirely up to how new lanterns get placed. Unless you provide further info on how this is about to happen every attempt to solve it is nonsensical. Kinda ridiculous having to state this 3x in the same thread. Cheers 1 Share this post Link to post Share on other sites
Ivanoff.N 61 Posted September 30, 2017 4 hours ago, Grumpy Old Man said: Trick question, do the future ones exist yet? How to implement a solution is entirely up to how new lanterns get placed. Unless you provide further info on how this is about to happen every attempt to solve it is nonsensical. Kinda ridiculous having to state this 3x in the same thread. Cheers No, they don`t exist, they will be spawned via createvehicle. The script that spawns them can not be altered, it has to be another script that makes them run my function.. Share this post Link to post Share on other sites
Von Quest 1163 Posted September 30, 2017 OMG. PLEASE EXPLAIN what exactly are you trying to do??? Why all the mystery? Just speak in real world terms. What are you trying to do exactly in the Mission? Walk us through it. Speak in normal game-wise human language. Not code. What do you want/need the Objects/Player/Mission to do? Context. Explain what are you trying to do, or want from the Player's perspective, and let the devs write the code/scripts. Show us the script or mission file you have already. Paste the code, or link to a download. Grrrrrrrrr. Good grief. LMAO! 1 Share this post Link to post Share on other sites