Event_EmitterTransform (and fixed onBrickLoaded)

Author Topic: Event_EmitterTransform (and fixed onBrickLoaded)  (Read 4518 times)

Event_EmitterTransform
Version 1.0.4





Use events to adjust your emitter position, rotation, and scale!


setEmitterScale
Put in a single value (applied to x y and z) or 3 values (x y z). Scale defines a box that the emitter shoots out of (not rotated)

setEmitterTransform
-Vector to determine offset from the center of the brick
-Rotation (euler x y z in degrees, or axis-angle in radians. axis vector will be normalized)

Invalid rotation values (empty box or not exactly 3 or 4 values) will result in the emitter using the brick's wrench menu direction.

Simple explanation of how to use rotation
Euler rotation: Three values, in degrees, to rotate around the X, Y, and Z axis
The rotations are done in order (X axis first, then Y, then Z) - imagine rotating around x axis first, then the resulting position around the  Y axis, then finally the Z axis

Axis-angle: 3 values to define a vector, plus a rotation value (radians) around said vector using right hand rule

Warning
Please be warned that setEmitterTransform screws up client saving, since it uses janky-ass client container searches to save emitters, items, and lights rather than have the server send the data over.  So don't be surprised if your emitter gets assigned to the wrong brick.

Server autosavers should be fine since they use the actual emitter property of bricks.

Note: May find this working version of Event_onBrickLoaded to be useful for automatic emitter transformation on loading your build


Download
« Last Edit: September 08, 2019, 12:27:25 PM by Conan »

this is really neat, makes builds a lot more flexible with emitters


holy crap!

now make something similar but for lights
« Last Edit: August 16, 2019, 09:11:26 PM by 8hbc »

You have no idea how long I've been wanting this. Thank you.

This has to be one of the best addons this year loving hell conan

This is going to be incredibly useful, thank you so much!

going to put out a fix for the euler rotations; the default eulerToMatrix (aka euler to axis angle) function is major broken lol

in layman’s terms: the x y z rotation format is broken (ex: 90 0 45 doesnt result in a 45 degree horizontal emitter (but 90 0 0 does work))


edit: its fixed. update/redownload.

edit2: added explanation how to use rotation in the OP
« Last Edit: August 18, 2019, 11:17:30 PM by Conan »



I'm actually surprised this wasn't already a thing. A very useful add-on, thanks Conan!

Please be warned that setEmitterTransform screws up client saving, since it uses janky-ass client container searches to save emitters, items, and lights rather than have the server send the data over.  So don't be surprised if your emitter gets assigned to the wrong brick.

Server autosavers should be fine since they use the actual emitter property of bricks.
« Last Edit: August 22, 2019, 04:56:52 PM by Electrk.. »

Please be warned that setEmitterTransform screws up client saving, since it uses janky-ass container searches to save emitters, items, and lights rather than have the server send the data over.  So don't be surprised if your emitter gets assigned to the wrong brick.

Server autosavers should be fine since they use the actual emitter property of bricks.
once again quality coding from the hand of badspot
i have a ridiculous overcomplicated somewhat plausible solution: script_healthbar style client/server handshake where if both the client and server has the mod, the client will ask the actual emitter values on bricks to the server rather than do a search
idk if you can actually modify the saving function
maybe just let admins and super admins directly download a bls from the server?

once again quality coding from the hand of badspot
i have a ridiculous overcomplicated somewhat plausible solution: script_healthbar style client/server handshake where if both the client and server has the mod, the client will ask the actual emitter values on bricks to the server rather than do a search
idk if you can actually modify the saving function
maybe just let admins and super admins directly download a bls from the server?
the handshake method is exactly how to fix it, and its not ridiculously overcomplicated. dunno why badspot didnt write some code in to do it.

you can definitely modify the saving function, but if the server doesnt have any function to let the client request the brick an emitter is spawning from theres not much it can do. downloading a .bls directly is much much much slower, and would require both the server and the client to have a way to handle the file transfer process (and probably optimize it)

Added a link to a fixed copy of Event_onBrickLoaded (by Carbon Zypher/Darksaber) to the OP for those who might want it to automatically apply your emitter transformations on build load.

also added a few pics/examples of how it can be used.
« Last Edit: September 03, 2019, 05:59:59 PM by Conan »