b3lx 161 Posted July 25, 2018 I'm trying to store an array of terrain objects in a file so I can hide them when the mission starts. I used "copytoclipboard str _array" and I get something like this: _array = [20095d4100# 39897: dum_istan4_big.p3d,1ff0daeb00# 56369: dum_olez_istan2.p3d]; When I pass the array to a forEach loop like below I get an "error missing ]". {hideobjectglobal _x} forEach _array; Also tried : {hideobjectglobal (str _x) } forEach _array; But doesn't work either I can't see what's wrong here. Is it the fact that objects are being referenced by a string and that isn't recognised? Is there some other way to do it? I'm not using any other method for hiding objects because the list is huuuge and the method involved in selecting them isn't reproducible at mission start. Share this post Link to post Share on other sites
POLPOX 779 Posted July 25, 2018 The _array contains no objects anymore since you used copyToClipboard. Why not just store the array of object and use it directly? How did you use this? Share this post Link to post Share on other sites
b3lx 161 Posted July 25, 2018 I'm trying precisely to store the array in a sqf file. Here I'm defining the array by using _array = [20095d4100# 39897: dum_istan4_big.p3d,1ff0daeb00# 56369: dum_olez_istan2.p3d]; But it doesn't even matter because the problem is not with the array but with the object references themselves. So this bellow gives "generic error": systemchat str (getpos ("20095d4100# 39897: dum_istan4_big.p3d")); And this is missing parenthesis: systemchat str (getpos (20095d4100# 39897: dum_istan4_big.p3d)); Share this post Link to post Share on other sites
POLPOX 779 Posted July 25, 2018 I have no idea why you have to do this. Please post the entire script. If you do something like this: str _object The return: "20095d4100# 39897: dum_istan4_big.p3d" This is not an object anymore. Either has quotes or not. So every script commands to fetch data from an object/modify object won't work. 1 Share this post Link to post Share on other sites
Larrow 2823 Posted July 25, 2018 6 minutes ago, POLPOX said: This is not an object anymore. Either has quotes or not. So every script commands to fetch data from an object/modify object won't work. Exactly, What you have there is a STRING representation of an object reference. If you want to hide them at mission start, just use what ever you used to output them in the first place but instead hide them (as they are object references at this point). Do it in a postInit function and you can do it behind a loading screen that will run really fast. 1 Share this post Link to post Share on other sites
b3lx 161 Posted July 25, 2018 OK, so its no longer an object but just a string, right? So here is what's going on: 1st part: _array = nearestTerrainObjects [_pos, _type, _radius, false]; _filter = crazyfunction that does a lot of filtering but is not relevant here, _array call _filter; 2nd part: {hideobjectglobal _x} forEach _array; //This works no problem at all But what I want is to store the objects that were seleced with the first part in a file so that I don't have to execute the first part every time. Ideally I could just pass a list of terrain objects stored in that file to the second part. Share this post Link to post Share on other sites
b3lx 161 Posted July 25, 2018 14 minutes ago, Larrow said: Exactly, What you have there is a STRING representation of an object reference. If you want to hide them at mission start, just use what ever you used to output them in the first place but instead hide them (as they are object references at this point). Do it in a postInit function and you can do it behind a loading screen that will run really fast. The postInit function sounds really nice and I will look into it. But is there no way of writing down actual workable object references? Share this post Link to post Share on other sites
Harzach 2518 Posted July 25, 2018 That said, it looks like Quote 20095d4100# 39897: dum_istan4_big.p3d that might be the object id, so you could recompile your array _array = [39897,39898,39899,39900,39901,...]; {(_pos nearestObject _x) hideObject true} forEach _array; But those guys^ are smarter than me, so maybe listen to them instead. Share this post Link to post Share on other sites
b3lx 161 Posted July 25, 2018 14 minutes ago, Harzach said: that might be the object id, so you could recompile your array if that was the case then I guess this should work: systemchat str (getpos 39897) it doesn't, but maybe there's some other way of recompiling it, no? Also just to clarify on why i don't want to repeat the full function: 1- the first part takes a long long time 2 - it involves a lot of randomness so results are different on each run and in this case I want to "freeze" the results so to speak, so that I can do further editing in 3den Share this post Link to post Share on other sites
Harzach 2518 Posted July 25, 2018 5 minutes ago, b3lx said: I guess this should work: systemchat str (getpos 39897) Nope! hint format["%1", getpos (_pos nearestobject 39897)]; Or, for testing purposes hint format["%1", getpos (getpos player nearestobject 39897)]; Share this post Link to post Share on other sites
POLPOX 779 Posted July 25, 2018 Your script just posted doesn't make sense for me. If you want to go Harzach style, here's an easy way to convert a string to a number. parseNumber (("0000000000# 00000: something.p3d" splitString "#: ") # 1) 2 Share this post Link to post Share on other sites
Grumpy Old Man 3547 Posted July 25, 2018 32 minutes ago, b3lx said: OK, so its no longer an object but just a string, right? So here is what's going on: 1st part: _array = nearestTerrainObjects [_pos, _type, _radius, false]; _filter = crazyfunction that does a lot of filtering but is not relevant here, _array call _filter; 2nd part: {hideobjectglobal _x} forEach _array; //This works no problem at all But what I want is to store the objects that were seleced with the first part in a file so that I don't have to execute the first part every time. Ideally I could just pass a list of terrain objects stored in that file to the second part. 19 minutes ago, b3lx said: if that was the case then I guess this should work: systemchat str (getpos 39897) it doesn't, but maybe there's some other way of recompiling it, no? Also just to clarify on why i don't want to repeat the full function: 1- the first part takes a long long time 2 - it involves a lot of randomness so results are different on each run and in this case I want to "freeze" the results so to speak, so that I can do further editing in 3den I don't get what you're trying to do. You define terrain objects, filter them and have those objects stored in an array. Storing the array of objects inside a file contradicts your statement of wanting to randomize these objects in the first place. As @Larrow stated, doing it via postInit should eliminate most performance issues. Alternatively you could run BIS_fnc_objectVar on every object and save that as an array instead (if this actually works on terrain objects). Cheers 1 Share this post Link to post Share on other sites
Harzach 2518 Posted July 25, 2018 _obj = (("20095d4100# 39897: dum_istan4_big.p3d" splitString "#: ") # 1); systemchat _obj; systemchat format["%1", getpos (getpos player nearestobject (parseNumber _obj))]; 1 Share this post Link to post Share on other sites
b3lx 161 Posted July 25, 2018 2 hours ago, Grumpy Old Man said: You define terrain objects, filter them and have those objects stored in an array. Storing the array of objects inside a file contradicts your statement of wanting to randomize these objects in the first place. Ok , I was not clear, let me try again: So this is a mass replacement script that replaces most objects on a terrain (combination of hideobject and createvehicle). I have been running it everytime on mission start. It's great. The slowness part can maybe be addressed using postInit, I will look into that. But now I'm using this script in a different way: I want it to run one time in the editor, and place actual editor objects that stay the same whenever I load the mission. For this I'm using create3denentity instead of createvehicle. It all goes very well except now the objects that were hidden by script in the editor will show up when the mission starts, and I cannot use the script again because it will hide different objects that the ones that were selected in the first place. So my idea was to pushback all the hidden objects into an array that I can store in a file and run on mission start. The script partially randomises the selection of which objects should go in the array. After the objects are chosen and put in the array, then from that moment onwards this is the array I want to work with, so that it stays the same all the time. The randomisation is only for the selection and is supposed to be a one off event. Doing this allows me to to do further editing in 3den and not be worried about things changing on mission start. Hope it makes sense now. Anyway , you all gave very valuable suggestions that I think will help me to pull this off, and I will look into all of them. hint format["%1", getpos (getpos player nearestobject 39897)]; This actually works in game, but not on the editor, so it seems IDs are processed on the mission start, I didn't know that. Thank you guys very much. Will report back on the solution when it's done. Share this post Link to post Share on other sites
b3lx 161 Posted July 25, 2018 It's DONE!!! This goes in the end of the replacement script and copies all id's to clipboard _newlist = []; { _obj = (str _x) splitString " "; _obj = (parsenumber (_obj select 1)); _newlist pushback _obj; } forEach _objectarray; copytoclipboard str _newlist; Then I pasted the result into a file: _newlist = [id1,id2,...]; In the end I put: {hideobjectglobal ([0,0,0] nearestobject _x)} forEach _newlist; execVM the file and I also tried the BIS_fnc_objectVar method but it didn't seem to work. Thanks again you all, really amazing help. Now it's time to make Fallujah map great again! (disclaimer: no terrain editing, just mission) Share this post Link to post Share on other sites