Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //worldedit macro
- // used to change arrow keys to match currently facing direction
- // also provides capability related to modifier functions
- //
- // This does not work very well if the player is not looking level.
- // If you are looking up or down, this macro will have unexpected behavior.
- //
- // Inputs:
- // &direction = direction for input key (forward, back, right, left, up, down)
- // &function_array = string of world edit functions, of form: <key>=<value>,<key2>=<value2>,...
- //
- // Keys:
- // function = (required) fuction to run (shift, move, expand, contract, etc)
- // (use move -s to move the selection with the region)
- // shift = worldedit function to run when the shift key is pressed
- // ctrl = worldedit function to run when the ctrl key is pressed
- // alt = worldedit function to run when the alt key is pressed
- // shift-ctrl = worldedit function to run when the shift+ctrl key is pressed
- // shift-alt = worldedit function to run when the shift+alt key is pressed
- // ctrl-alt = worldedit function to run when the ctrl+alt key is pressed
- // shift-ctrl-alt = function to run when shift+ctrl+alt key is pressed
- //
- //clear variables
- unset(&key)
- unset(&value)
- unset(&keyvalue)
- unset(&func)
- unset(&function)
- unset(&shiftf)
- unset(&ctrlf)
- unset(&altf)
- unset(&shift_ctrlf)
- unset(&shift_altf)
- unset(&ctrl_altf)
- unset(&shift_ctrl_altf)
- // Parse &fuction_array
- &function_array[] = split(",","$$[2]")
- DO
- pop(&function_array[],&func)
- &keyvalue[] = split("=",%&func%)
- &key = %&keyvalue[0]%
- &value = %&keyvalue[1]%
- log(%&key% = %&value%)
- if(%&key% = "function")
- &function = %&value%
- elseif(%&key% = "shift")
- &shiftf = %&value%
- elseif(%&key% = "ctrl")
- &ctrlf = %&value%
- elseif(%&key% = "alt")
- &altf = %&value%
- elseif(%&key% = "shift-ctrl")
- &shift_ctrlf = %&value%
- elseif(%&key% = "shift-alt")
- &shift_altf = %&value%
- elseif(%&key% = "ctrl-alt")
- &ctrl_altf = %&value%
- elseif(%&key% = "shift-ctrl-alt")
- &shift_ctrl_altf = %&value%
- else
- LOG(WARN: %&key% is not recognized (value: %&value%))
- endif
- WHILE(&function_array[0])
- if(!&function)
- log(ERR: no function provided)
- stop()
- endif
- // Set initial variables and index.
- //array of directions, used to rotate frame of reference
- &dir_array[] = split(",","N,E,S,W,N,E,S,W,N")
- //the input direction
- &direction = $$[1]
- //determine rotation to shift index in dir_array
- //this command takes advantage of integer division.
- //We want N to be all angles -45 to +45, so we rotate
- //by 45 degrees so we can perform integer division into
- //the quarters of the unit circle.
- #index_adj = (%CARDINALYAW%+45)/90
- //set the default index, relative to N
- if(%&direction% = "forward")
- #index = 0
- elseif(%&direction% = "right")
- #index = 1
- elseif(%&direction% = "back")
- #index = 2
- elseif(%&direction% = "left")
- #index = 3
- else
- LOG(Err: bad input. Direction does not match options, or was not provided.)
- log( direction = %&direction%)
- STOP()
- endif
- //increment the default index by the index adjustment
- INC(#index,%#index_adj%)
- //set the command based on the modifier keys and functions present
- if((SHIFT) && (CTRL) && (ALT) && (ctrlf))
- &command = %&shift_ctrl_altf%
- elseif((CTRL) && (ALT) && (ctrlf))
- &command = %&ctrl_altf%
- elseif((SHIFT) && (CTRL) && (&shift_ctrlf))
- &command = %&shift_ctrlf%
- elseif((SHIFT) && (ALT) && (&shift_altf))
- &command = %&shift_altf%
- elseif((SHIFT) && (&shiftf))
- log(SHIFT IS IN THE HOUSE)
- &command = %&shiftf%
- elseif((CTRL) && (&ctrlf))
- &command = %&ctrlf%
- elseif((ALT) && (&altf))
- &command = %&altf%
- else
- //no modifier keys or other functions present, so use default function
- &command = %&function%
- endif
- &output = //%&command% 1 %&dir_array[%#index%]%
- echo(%&output%)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement