Lucky44 13 Posted May 13, 2010 I've searched all over for this: I'm trying to spawn a "notebook" computer in 1 of 3 random positions in buildings. Everything works fine, except the computer keeps ending up outside the building, despite the marker at which it should spawn being IN the building. I'm using createVehicle to spawn the object at the chosen marker, then even trying a setPos to get it at the right height. But it keeps appearing outside the building. Is there a better way to force it to be created (or moved to) the marker, in the building? Share this post Link to post Share on other sites
Egosa-U 10 Posted May 13, 2010 It doesn't even work, if you setpos X- and Y-coordinates? Share this post Link to post Share on other sites
thebarricade 7 Posted May 13, 2010 What you're looking for is probably buildingPos. The following is really, really untested, so your milage will vary... TBR_random_building_pos = { private["_b","_pos","_i","_p"]; _p = [-1,-1,-1]; _pos = [0,0,0]; _b = _this select 0; _i = 0; // find out how many positions there are in this building while {_p select 0 != 0} do { _p = _b buildingPos _i; _i = _i + 1; }; _pos = _b buildingPos (random floor(_i)); _pos; }; notebook_pos = [buildingobject] call TBR_random_building_pos; Share this post Link to post Share on other sites
Egosa-U 10 Posted May 13, 2010 Or use this: this setPos [(getmarkerpos "aaa" select 0),(getmarkerpos "aaa" select 1),((getmarkerpos "aaa" select 2) + 10)]; aaa is the name of the marker you placed on the building. I used the radio-tower on utes, placed the marker and moved the object via code successfully into the controlroom. Share this post Link to post Share on other sites
Funkman 10 Posted May 13, 2010 On a similar note, I am trying to create a disco sort of atmosphere by placing some lights inside of bar, then using the light setLightColor [r, g, b] command (hopefully) to change the colour of the lights every second or so... But I cannot seem to find where to place lights from..I cant see any relevant objects in the 'objects' selection menu in the editor..Where do I find them? Share this post Link to post Share on other sites
loyalguard 15 Posted May 13, 2010 You cannot place a light with the editor. You have to use createVehicleLocal to create a #lightpoint object. The setLightColorCommand entry in the Biki has example code how to do this. Share this post Link to post Share on other sites
Joshii 10 Posted May 13, 2010 To quote myself from the "How to find enterable houses" thread A way to find houses you can enter + adjustable to place random stuff in every house in a radius that you can select. houses = player nearObjects ["House",200]; // The last number in the array is the searchradius in meters. tocount = count houses; counter = 0; while {(counter < tocount)} do { testdata2 = houses select counter buildingPos 1; markerstring = format ["House %1", counter]; namestring = format ["Marker%1", counter]; if !((testdata2 select 0) == 0 && (testdata2 select 1) == 0 && (testdata2 select 2) == 0) then { namestring = createMarker [markerstring, houses select counter]; namestring setMarkerShape "ICON"; markerstring setMarkerType "DOT"; diag_log testdata2; counter = counter +1; } else { counter = counter +1; }; } Share this post Link to post Share on other sites
Lucky44 13 Posted May 13, 2010 Wow, thanks for all the prompt, helpful info. I'll get testing and get back if I have anything useful to say. Share this post Link to post Share on other sites
Lucky44 13 Posted May 13, 2010 To quote myself from the "How to find enterable houses" threadA way to find houses you can enter + adjustable to place random stuff in every house in a radius that you can select. This seems to work strangely: it will declare lots of buildings that are not enterable as enterable. Any ideas why? For instance, I'm getting the guard building at the north gate of the Utes airbase to come up as enterable, but it's not. Am I missing something? ---------- Post added at 10:28 PM ---------- Previous post was at 09:58 PM ---------- Here's what I've come up with, and it's working well. ////////////////////////////////////////////////////////////////// // Spawn an object in 1 of 3 positions in a building, randomly. // Created by: Lucky44 ////////////////////////////////////////////////////////////////// if (! isServer) exitwith {}; // NOTE: in multiplayer, only server should create random numbers. // This creates a random whole number from 1-3. n1 = round ((random 3) + 0.5); // changing the "3" to another number will generate a different value. // e.g., if you make the "3" a "9", you'll get a numbe from 1-9 // This section creates the object (a notebook computer) at the corresponding marker and moves it to the proper height; // (In this case, I'm setting the heights to 1.1 meters) if (n1 == 1) then { G1 = "notebook" createvehicle (getMarkerPos "marker1"); G1 setPos [(getmarkerpos "marker1" select 0),(getmarkerpos "marker1" select 1),((getmarkerpos "marker1" select 2) + 1.1)]; }; if (n1 == 2) then { G1 = "notebook" createvehicle (getMarkerPos "marker2"); G1 setPos [(getmarkerpos "marker2" select 0),(getmarkerpos "marker2" select 1),((getmarkerpos "marker2" select 2) + 1.1)]; }; if (n1 == 3) then { G1 = "notebook" createvehicle (getMarkerPos "marker3"); G1 setPos [(getmarkerpos "marker3" select 0),(getmarkerpos "marker3" select 1),((getmarkerpos "marker3" select 2) + 1.1)]; }; Share this post Link to post Share on other sites