ckfinite
Matrix Veteran

Posts: 377
Joined: 7/20/2013 Status: offline
|
I'm working on a scenario, and wrote this little library for making and modifying arcs in a more convenient way than manually writing tables, and thought that it could be useful to other people here. The library can be found here, to add, just copy and paste into an event that runs whenever the scene is loaded, and it should be available. Usage: Arcs created by the library can be used immediately by Command with no modifications. Example: quote:
ScenEdit_UpdateUnit({guid='2c246071-b2a3-4603-a8a5-6d2033ff4a73', mode="add_sensor", dbid=3352, arc_detect=Arc():forward()}) Constructors: This library adds a single function, Arc(), which provides several constructor methods for arcs: Arc():from(from_angle):to(to_angle) This will create a new arc which extends from from_angle, in degrees off of the front of the unit, to to_angle, in the same frame. Notably, the system sweeps clockwise, so, for example, Arc():from(0):to(0) will include all angles. Examples: quote:
Arc():from(0):to(90) -- front right quadrant Arc():from(180):to(0) -- port side Arc():new(arc) The "new" method makes a library-usable arc from a default arc. This is used when adding arcs manually is desirable. Names are as in the default system, see here for them Examples: quote:
Arc():new({"SB1"}) -- adds the "SB1" arc. Arc():all(), Arc():forward(), Arc():backward(), Arc():port(), Arc():starboard() As the name implies, these return a pre-defined arc over the named area. Examples: quote:
Arc():all() -- an arc over all aspects Arc():forward() -- an arc over the forward aspect Arc Utilities: Arcs created by the library can be added, using the + operator. For example, Arc():forward() + Arc():backward() is equivalent to Arc():all(). These arcs can then be added themselves, ad infinitum. Arcs created by Arc() can be converted to string for printing and debug with the built-in tostring method, which prints out the names of the aspects included in the arc.
< Message edited by ckfinite -- 2/25/2017 6:40:23 AM >
|