Cursor Interaction (Effects) - emd4600/SporeModder-FX GitHub Wiki
Effects are able to be limitedly interacted with using the Cursor. This is achieved through a set of special options and flags for the Effect component block. An interactable effect block can contain anything a normal effect block can, and will be activated upon cursor interaction so long as it and the exported effect block have the necessary options and flags.
A few limitations to note before progressing:
- Cursor interaction is depth-independent and cannot (at present) be blocked, meaning that effects can be activated behind other effects, or through obstructions like entities with only a single click if aligned correctly.
- There currently seems to be no way to force an effect to start active.
- Effects can only be activated and deactivated, not toggled between different states to achieve things like fade outs.
- Activation methods can't evidently be combined, such as toggling an effect by hovering the cursor over it.
On the other hand, these effects can be used effectively anywhere, including as rigblock
effects for Creature parts (inside and outside of the Editor mode), and placeable effects in the Adventure Editor. They can also, as with any effect block, use the game
attribute, meaning they can potentially be very powerful.
The -applyCursor
flag is essential to the functioning of an interactable effect block, and must be applied to the block that will be exported:
effect export_effect -applyCursor
# effect cursor_effect
end
export export_effect
An exported block that contains an effect with this flag will not function correctly unless the export block has the flag as well.
Note: in all cases, <float>
is a multiplier for the radius from the centre of the effect that is clickable. Due to the overlap issue mentioned above, if the radii of two effects intersect from the view perspective at the position where the cursor is hovered or clicked, they will both be triggered.
-cursorActivate
<float>
: The effect will be activated when the cursor hovers (or passes) over it.
-radioButtonActivate
<float>
: The effect will be activated when clicked on, and will deactivate when anywhere else on the screen, including other radio buttons, is clicked.
-toggleButtonActivate
<float>
: The effect will be activated when clicked on, and will remain active until clicked on again.
The following effect will create an array of three dark spheres, each of which, when hovered over by the cursor, will spawn a fully-lit and slightly larger sphere and play a ping sound.
effect lit_sphere -cursorActivate 0.9 # the effect that will be activated by being hovered over by the cursor;
# the scale is tweaked to match the radius of the darker base sphere
# or else it would activate when it intersects the resulting larger lit sphere
model -name builtins!sphere -scale 1 -color 1 # the model in question to spawn
# note: due to shading differences across different parts of the game,
# this model will likely not render properly in certain model worlds
sound -name 0x8259039e -stop # the sound to play
# the -stop flag will make the sound cut off immediately
# if the effect ends before it finishes playing the entire sound
end
effect sphere_holder # this effect holds the effect to be activated
# and a dummy model to indicate where to pass the cursor over
# it doesn't need the -applyCursor flag
effect lit_sphere # the interactable effect
model -name builtins!sphere -scale 0.9 -color 0.2 # the dummy model
end
effect export_effect -applyCursor # the effect block that will be exported
# each of the following are one instance of a clickable sphere
# unless their interaction radii overlap, they will each only
# activate when hovered
effect sphere_holder -offset (0,-5,0)
effect sphere_holder
effect sphere_holder -offset (0,5,0)
end
export export_effect
All of the above applies to this one, except that the effects will only activate when clicked, and will be deactivated when any other part of the screen outside its interaction radius is clicked.
effect lit_sphere -radioButtonActivate 0.9 # the effect that will be activated by being clicked on by the cursor;
# and will stop when any other part of the screen, including other "buttons" are clicked on
model -name builtins!sphere -scale 1 -color 1
sound -name 0x8259039e -stop
end
effect sphere_holder
effect lit_sphere
model -name builtins!sphere -scale 0.9 -color 0.2
end
effect export_effect -applyCursor
effect sphere_holder -offset (0,-5,0)
effect sphere_holder
effect sphere_holder -offset (0,5,0)
end
export export_effect
This version is also essentially the same as the last one, but the effect will stay active until clicked on again. The same rule regarding radii applies.
effect lit_sphere -toggleButtonActivate 0.9 # the effect that will be activated by being clicked on by the cursor;
# and will stay active until clicked on again
model -name builtins!sphere -scale 1 -color 1
sound -name 0x8259039e -stop
end
effect sphere_holder
effect lit_sphere
model -name builtins!sphere -scale 0.9 -color 0.2
end
effect export_effect -applyCursor
effect sphere_holder -offset (0,-5,0)
effect sphere_holder
effect sphere_holder -offset (0,5,0)
end
export export_effect