Barotrauma

Barotrauma

Barotrauma Workshop
You can build your own submarines and monsters with in-game editors and share your creations with other players. Imagine and experiment.
Setting variables in Conditional statement
I have a CustomInterface component and I can apply status effects by interacting with Tickboxes.

Tickboxes can call StatusEffects; I'd like to have these Tickboxes set variables for my item so I can choose different behavior (color schemes, sound, etc).

Is there a way to do this cleanly? My first jank thought is modifying the Condition through the tickbox and checking for that accordingly, but this dirties the UI for the user.
< >
Showing 1-1 of 1 comments
DuckieMcduck 5 18 May, 2023 @ 9:57pm 
I managed to do this by adding the following:
<MemoryComponent Value="a" canbeselected="false" />

This creates a memory, or in this context a variable, in whatever you want, it can work in installations and items. It is initialized with the string "a". This even persists through loadscreens in the campaign.

From there, you can use StatusEffects as usual to change its Value like so:

<StatusEffect type="OnUse" targettype="This" Value="b"/>

And somewhere, you may have conditionals inside status effects and use the public Value property of the MemoryComponent to check behavior:

<StatusEffect type="OnActive" target="This" IsActive="true"> <Conditional Value="a"/> <sound file="Content/Items/Weapons/StunGrenade.ogg" range="2000" /> </StatusEffect> <StatusEffect type="OnActive" target="This" IsActive="true"> <Conditional Value="b"/> <sound file="Content/Items/Weapons/ExplosionSmall1.ogg" range="3000" /> </StatusEffect>

You can use this to make items that behave completely differently when updated with a signal or other event. "canbeselected" may be set to true in order to allow players to change it via the game UI instead of using wires or anything else.

In this mod I made I used this alongside CustomGUI to make buttons which picked different sounds to play on the Sonar Beacon:

https://steamhost.cn/steamcommunity_com/sharedfiles/filedetails/?id=2977641329

https://steamhost.cn/steamcommunity_com/sharedfiles/filedetails/?id=2956831535
Last edited by DuckieMcduck; 18 May, 2023 @ 10:07pm
< >
Showing 1-1 of 1 comments
Per page: 1530 50