Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Script that enables "nudging" objects in the 3den editor for precision alignment/adjustment. Execute script from 3den debug menu. (Ctrl + D to open) - execVM "nudge.sqf"
- // Select 1 or more objects in 3den and you can adjust their position(s).
- // Created by Rylan
- //
- // Controls:
- // Shift + Numpad 5 = Nudge "forward" (Global coordinates so it probably won't be forward for the object if it has changed rotation.)
- // Shift + Numpad 1 = Nudge "left"
- // Shift + Numpad 2 = Nudge "backward"
- // Shift + Numpad 3 = Nudge "right"
- // Ctrl + Numpad 5 or 2 = Increase or decrease the nudge increment by 0.0025 - For high precision
- // Ctrl + Numpad 1 or 3 = Increase or decrease the nudge increment by 0.01 --- For lower precision
- //
- // The default value and the amount the increment can be increased or decreased can be changed by editing the first 3 variables of this script.
- // These variables can also be changed on the fly from the editor via the debug menu. Simply redefine any of the variables with the values you want.
- //
- // I eventually plan on adding a way to adjust the vertical position of an object, as well as its rotation. It would also be ideal to be able to nudge along local object coordinates.
- A3EM_nudgeIncrement = 0.01; // Default nudge value
- A3EM_ni_inc1 = 0.0025; // ---- High precision adjustment
- A3EM_ni_inc2 = 0.1; // ------- Low precision adjustment
- A3EM_fnc_nudgeTranslate =
- {
- collect3DENHistory
- {
- private ["_keypress", "_EditorObjects"];
- _keypress = _this select 0;
- _EditorObjects = get3DENSelected "object";
- if (count _EditorObjects < 1) exitWith {systemChat "No object(s) selected!"};
- {
- if (_keypress == "NudgeUp") then {
- private _oldPos = (_x get3DENAttribute "Position") select 0;
- set3DENAttributes [[[_x],"Position",[(_oldPos select 0),(_oldPos select 1) - A3EM_nudgeincrement,(_oldPos select 2)]]];
- };
- if (_keypress == "NudgeDown") then {
- private _oldPos = (_x get3DENAttribute "Position") select 0;
- set3DENAttributes [[[_x],"Position",[(_oldPos select 0),(_oldPos select 1) + A3EM_nudgeincrement,(_oldPos select 2)]]];
- };
- if (_keypress == "NudgeRight") then {
- private _oldPos = (_x get3DENAttribute "Position") select 0;
- set3DENAttributes [[[_x],"Position",[(_oldPos select 0) - A3EM_nudgeincrement,(_oldPos select 1),(_oldPos select 2)]]];
- };
- if (_keypress == "NudgeLeft") then {
- private _oldPos = (_x get3DENAttribute "Position") select 0;
- set3DENAttributes [[[_x],"Position",[(_oldPos select 0) + A3EM_nudgeincrement,(_oldPos select 1),(_oldPos select 2)]]];
- };
- } forEach _EditorObjects;
- };
- };
- waitUntil {!isNull (findDisplay 313)};
- #include "\a3\ui_f\hpp\definedikcodes.inc"
- _display = findDisplay 313;
- if (_display getVariable ["A3EM_eh_nudgecontrols", -1] != -1) exitWith {};
- _EventHandler = _display displayAddEventHandler [ "KeyDown", {
- params[
- "_display",
- "_keyCode",
- "_shft",
- "_ctr",
- "_alt"
- ];
- call {
- if ( _shft && { _keyCode isEqualTo DIK_NUMPAD5 } ) exitWith { // up
- ["NudgeUp"] call A3EM_fnc_nudgeTranslate;
- true
- };
- if ( _shft && { _keyCode isEqualTo DIK_NUMPAD2 } ) exitWith { // down
- ["NudgeDown"] call A3EM_fnc_nudgeTranslate;
- true
- };
- if ( _shft && { _keyCode isEqualTo DIK_NUMPAD3 } ) exitWith { // right
- ["NudgeRight"] call A3EM_fnc_nudgeTranslate;
- true
- };
- if ( _shft && { _keyCode isEqualTo DIK_NUMPAD1 } ) exitWith { // left
- ["NudgeLeft"] call A3EM_fnc_nudgeTranslate;
- true
- };
- if ( _ctr && { _keyCode isEqualTo DIK_NUMPAD5 } ) exitWith {
- A3EM_nudgeIncrement = A3EM_nudgeIncrement + A3EM_ni_inc1;
- systemChat str A3EM_nudgeIncrement;
- true
- };
- if ( _ctr && { _keyCode isEqualTo DIK_NUMPAD2 } ) exitWith {
- A3EM_nudgeIncrement = A3EM_nudgeIncrement - A3EM_ni_inc1;
- systemChat str A3EM_nudgeIncrement;
- true
- };
- if ( _ctr && { _keyCode isEqualTo DIK_NUMPAD3 } ) exitWith {
- A3EM_nudgeIncrement = A3EM_nudgeIncrement + A3EM_ni_inc2;
- systemChat str A3EM_nudgeIncrement;
- true
- };
- if ( _ctr && { _keyCode isEqualTo DIK_NUMPAD1 } ) exitWith {
- A3EM_nudgeIncrement = A3EM_nudgeIncrement - A3EM_ni_inc2;
- systemChat str A3EM_nudgeIncrement;
- true
- };
- false
- };
- }];
- _display setVariable ["A3EM_eh_nudgecontrols", _EventHandler]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement