zippy 10 Posted May 19, 2013 I am trying to move more than 1 object vertically to use as a gate, via another object as some sort of ingame switch/trigger. Maybe also have it auto close/rise after a certain time period if it's not been. Having it talk in local chat would be a bonus too. Could I be pointed please in the right direct of what I need to research and learn in order to achieve this please? Share this post Link to post Share on other sites
soolie 189 Posted May 19, 2013 This is a great Idea. I can't right now but Im going to work on it in an hour or two. I think i know what to do. Share this post Link to post Share on other sites
soolie 189 Posted May 19, 2013 (edited) I did it! well the moving up and down part any way. I know its A3 but the codes should all work. http://s1290.photobucket.com/user/MikeSulo/media/Arma%203%20-%20Map%20Editing/SecretDoor_zps1fbb9511.mp4.html I placed the barrier in the editor, named it door, and put this in the init open=door addAction ["Open Door","opendoor.sqf"]; Then I made opendoor.sqf door setPos [(getPos door) select 0, (getPos door) select 1, 2.6]; door removeaction open; closed=door addAction ["Close Door","closedoor.sqf"]; Then closedoor.sqf door setPos [(getPos door) select 0, (getPos door) select 1, 0]; door removeaction closed; The last variable (the one i changed to 2.6 and then back to 0) is the height Edited May 19, 2013 by Soolie Share this post Link to post Share on other sites
killzone_kid 1326 Posted May 19, 2013 Have you tried it in multiplayer? I know we had something similar on our server before. Depending on how busy the server it can take up to 5-7 seconds between action and reaction. In the end we went for instant hide object solution. Share this post Link to post Share on other sites
soolie 189 Posted May 19, 2013 I just threw it together tbh but I will be testing this thoroughly soon. Share this post Link to post Share on other sites
zippy 10 Posted May 19, 2013 (edited) so basically i can addaction to a laptop object and it should work. any way to make them move in a slower motion? I might use a crane as some fluff. a 5-7 second delay doesn't bother me. ---------- Post added at 14:43 ---------- Previous post was at 14:07 ---------- mission.beidi class _gate { objectType="vehicle"; class Arguments { POSITION="[7102.2964, 15019.693]"; TYPE="FoldTable"; LOCK="LOCKED"; INIT="open=gate addAction ["Open Gate","opengate.sqf"]"; AZIMUT="90"; PARENT=""; }; }; class _door1 { objectType="vehicle"; class Arguments { POSITION="[7104.1743, 15011.879, 0]"; TYPE="Land_Misc_Cargo2E"; PARENT=""; }; }; class _door2 { objectType="vehicle"; class Arguments { POSITION="[7108.6548, 15011.737, 0]"; TYPE="Land_fort_bagfence_long"; AZIMUT="90"; PARENT=""; }; }; opengate.sqf door1 setPos [(getPos door1) select 0, (getPos door1) select 1, 3.5]; door2 setPos [(getPos door2) select 0, (getPos door2) select 1, 3.5]; gate removeaction open; closed=gate addAction ["Close Gate","closegate.sqf"]; closegate.sqf door1 setPos [(getPos door1) select 0, (getPos door1) select 1, 0]; door2 setPos [(getPos door2) select 0, (getPos door2) select 1, 0]; gate removeaction closed; Getting an error on my init, typo? Edited May 19, 2013 by zippy Share this post Link to post Share on other sites
zippy 10 Posted May 20, 2013 class _button { objectType="vehicle"; class Arguments { POSITION="[7102.3203, 15019.694]"; TYPE="FoldTable"; AZIMUT="90"; INIT="this addAction [""Open Door"",""opendoor.sqf""];"; PARENT=""; }; }; class _gate { objectType="vehicle"; class Arguments { POSITION="[7104.1743, 15011.879, 0]"; TYPE="Land_Misc_Cargo2E"; PARENT=""; }; }; gate setpos [ getPos gate select 0, getPos gate select 1, 2.6]; this removeaction open; this addAction ["Close Door","closedoor.sqf"]; gate setpos [ getPos gate select 0, getPos gate select 1, 0]; this removeaction closed; this addAction ["Open Door","opendoor.sqf"]; Still having trouble chaps. just using opendoor.sqf and only using the single line; gate setpos [ (getPos gate select 0), (getPos gate select 1), +2.6]; gate setpos [ getPos gate select 0, getPos gate select 1, +2.6]; gate setpos [ getPos gate select 0, getPos gate select 1, 2.6]; isn't even moving the object higher. Share this post Link to post Share on other sites
Silderoy 1 Posted May 20, 2013 Stupid question, did you make sure the gate is called "gate" in the editor? Worth a try. One more thing I noticed, you can't write "this" in the script, as it doesn't mean specific object. Use: Opendoor.sqf: _table = _this select 0; _id = _this select 2; _table removeAction _id; gate setpos [ getPos gate select 0, getPos gate select 1, 2.6]; _table addAction ["Close Door","closedoor.sqf"]; closedoor.sqf: _table = _this select 0; _id = _this select 2; _table removeAction _id; gate setpos [ getPos gate select 0, getPos gate select 1, 0]; _table addAction ["Open Door","opendoor.sqf"]; Share this post Link to post Share on other sites
zippy 10 Posted May 21, 2013 (edited) I thought if you did '_object' was local and 'object' was global. I'm trying to addaction a open then close option on a object, that will move a 2nd object. I named the objects button and gate. the problem I have with the addaction is that it wont give the open option without some sort of word in front of it and the wiki isn't very clear. ---------- Post added at 23:49 ---------- Previous post was at 23:36 ---------- I see there is a name option in the edit properties of the object. So I have now mission.biedi class _unit_2 { objectType="vehicle"; class Arguments { POSITION="[7102.3203, 15019.694]"; TYPE="FoldTable"; AZIMUT="90"; NAME="button"; INIT="button addAction [""Open Door"",""opendoor.sqf""];"; PARENT=""; }; }; class _unit_3 { objectType="vehicle"; class Arguments { POSITION="[7104.1743, 15011.879, 0]"; TYPE="Land_Misc_Cargo2E"; NAME="gate"; PARENT=""; }; }; opendoor.sqf gate = _this select 0; id = _this select 2; button removeAction id; gate setpos [ getPos gate select 0, getPos gate select 1, 2.6]; button addAction ["Close Door","closedoor.sqf"]; closedoor.sqf gate = _this select 0; id = _this select 2; button removeAction id; gate setpos [ getPos gate select 0, getPos gate select 1, 0]; button addAction ["Open Door","opendoor.sqf"]; This teleports the button 'TYPE="FoldTable";' 2.6 in the air. I'm trying to understand the expansion what you gave me to put in. A breakdown of how each element links will give me a better understanding, and much appreciated. ---------- Post added at 01:15 ---------- Previous post was at 00:49 ---------- Ok so after this name stuff, I finally figured it out. And working I have... mission.biedi class _unit_2 { objectType="vehicle"; class Arguments { POSITION="[7102.3203, 15019.694]"; TYPE="foldtable"; AZIMUT="90"; NAME="button"; INIT="open=button addAction [""Open Door"",""opendoor.sqf""];"; PARENT=""; }; }; class _unit_3 { objectType="vehicle"; class Arguments { POSITION="[7104.1743, 15011.879, 0]"; TYPE="Land_Misc_Cargo2E"; NAME="gate"; PARENT=""; }; }; opendoor.sqf gate setPos [(getPos gate) select 0, (getPos gate) select 1, 4.0]; button removeaction open; closed=button addAction ["Close Door","closedoor.sqf"]; closedoor.sqf gate setPos [(getPos gate) select 0, (getPos gate) select 1, 0]; button removeaction closed; open=button addAction ["Open Door","opendoor.sqf"]; Item I'm moving has no physics so it stays in position. Edited May 20, 2013 by zippy Share this post Link to post Share on other sites
Silderoy 1 Posted May 21, 2013 Ok so here is an explenation of addAction: When you use addAction, you call a file (sqf or sqs). The addAction command has to have an Identefier (the word infront of the "="). It could be a number or a variable (local or global). The Identefier is used to remove the action and basicly Identefy the action and seperate it from any other action. Now the addAction returns an array to the identefier. The array contain the object the addAction was assigned to, the unit that pressed the action, and a uniqe number assigned to the action. So for example you created the "closed" action. So when the action is used, "closed" will be equal to an array, that will look like this: closed = [target, caller, id]; So this array is now part of the script you called. So you can refer to those just like any array's elements, with the "_this" local variable. Those elements are being called in the script file with _target = _this select 0; //first element of the array. _caller = _this select 1; //second element of the array. _id = _this select 2; //third element. Then to remove the action, for example, you can use _target remove _id; Hope it helped :) for future use. Share this post Link to post Share on other sites
GODSPEEDSNAKE 12 Posted June 14, 2013 Is there a way to make that object move over time so it doesn't just 'pop to the setpos position? make it look like its 'moving' the the setpos?? Regards, GODSPEEDSNAKE Share this post Link to post Share on other sites
Silderoy 1 Posted June 14, 2013 yes, you can move it with very small steps. for example if you want to move it 2 meters up, you can use something like this: gate = _this select 0; id = _this select 2; button removeAction id; for [{_i = 0.05},{_i < 2.01},{_i = _i + 0.05}] do { gate setpos [ getPos gate select 0, getPos gate select 1, _i]; sleep 0.05; }; button addAction ["Close Door","closedoor.sqf"]; it will move 5cm every 0.05 seconds, until it gets to 2 meters. 40 small moves... Share this post Link to post Share on other sites
miscology 10 Posted June 14, 2013 A sine function creates a smoother animation. Here's an example script. testanim.sqf _obj = createvehicle["Fort_RazorWire",[(Position Player select 0),(Position Player select 1) +2, Position Player select 2],[],0,"NONE"]; _theta = 0; _height=3; _step = 1; _pos = Position _obj; //_theta: values 0 to 90 to lift object // values 91 to 180 to let it down again while {_theta<180} do { _obj setPosATL [_pos select 0,_pos select 1,_height*sin(_theta)]; _theta = _theta + 1; hintsilent format["theta:%1",_theta]; sleep 0.02; }; sleep 5; deletevehicle _obj; Share this post Link to post Share on other sites
GODSPEEDSNAKE 12 Posted June 20, 2013 Thanks guys will look into and test it... Share this post Link to post Share on other sites