Space Engineers

Space Engineers

Not enough ratings
Water Mod 3.0 Modding Guide
By Jakaria
This guide is for how to use the Water Mod's ModAPI. This is intended for modders only so players won't get any useful knowledge out of this.

Please direct your questions to the Discord, where you're more likely to get responses from other players or I.
https://discord.gg/GrPK8cB
   
Award
Favorite
Favorited
Unfavorite
WaterModAPI.cs (Scripting)
The easiest way to access WaterModAPI.cs is through the Github.

https://github.com/jakarianstudios/SE-Water/blob/master/API/WaterModAPI.cs

There isn't much to explain on how to use this as I'm assuming you already know C# and the general gist of how to make SE mods. Just include the CS file in ModLocation/Data/Scripts/ and the mod will automatically register/unregister itself. You can access the static API methods through the namespace Jakaria.API

All the methods in that CS file are summarized with comments.

If you want to see an example of how the scripting API can be used, see this:

https://github.com/jakarianstudios/SE-Water/blob/master/API/APIUsageExample.cs
WaterConfig.xml (SBC Editing)
Setup

Click on the hyperlinked text to download WaterConfig[github.com], it is used for setting up planets and blocks for special use in the Water Mod. If you're unable to download the file, here is an empty form of the file that may or may not be out of date
Figure 1. Base XML

The WaterConfig[github.com] file is a lot like your typical SBC file, though it's a little more picky on where it should be located. WaterConfig[github.com] should be located in the Data/ folder of your mod (Figure 2) and should not be renamed. If it is in a different location or has a different name, I won't be able to detect it.


Figure 2. Config File Location

Configurations are loaded depending on mod order. If you want a particular config to overwrite the other, have it load later so it can overwrite the other mod.

You can verify that a definition is loaded by checking the game's log. All my log information begins with the phrase WaterMod:
WaterConfig.xml (Blocks)
If you want to see actual examples of how this is used, find the WaterConfig.xml file inside the Water Mod's contents.

Blocks can be defined for special use in the Water Mod, such as only functioning underwater or the surface. In addition to this, the block volume (displacement) can be provided to improve the accuracy of the buoyancy physics.

<BlockConfigs> <!-- Functional Blocks --> <BlockConfig TypeId="SolarPanel" SubtypeId="LargeBlockSolarPanel" Volume="40" FunctionalUnderwater="false" FunctionalAboveWater="true" PlayDamageEffect="false" /> </BlockConfigs>
Figure 3. Example of Block Configs

There are currently 3 possible parameters you can set for a block's configuration.

FunctionalUnderwater

This boolean is for blocks that can be powered on or off only. You don't need it for blocks like armor. It will decide whether your block works underwater.

FunctionalAboveWater

This boolean is for blocks that can be powered on or off only. You don't need it for blocks like armor. It will decide whether your block will work out of water/on the surface.

Volume
This is the volume of space the block takes up. It is used to calculate the displacement of water and therefore the buoyancy of the block. If it is not provided I have some ways to approximate the value, but I can't guarantee it's accuracy.

There are two methods of calculating this:

Method 1 (In-blender):

Enable the 3D-Print Toolbox addon that is by-default installed with Blender and open the Tool Shelf (N) and go to the 3D-Print tab. Select the object you want to calculate volume for and then press the Volume button. You should see the volume in cm^3. Convert that value into m^3 by dividing the value by 1000000.


See that the volume outputted is 125000cm^3. 125000cm^3 divided by 1000000 is 0.125m^3; this is volume of a small grid block. Input the calculated value into the volume field.

Method 2 (In-game):

Place the block and build a solid mock up of it using only the small full-armor-block variants (Figure 4).


Figure 4. Small Grid Mockup

Afterwards, locate the block count of the grid you have just built by opening the Info tab in the control panel (Figure 5). See that the grid I have built is 172 small grid blocks.

Figure 5. Mockup Block Count

We can use this number to calculate the volume of water the block displaces. One SE Small Grid armor block is 0.5*0.5*0.5m^3, meaning that the total volume will be 21.5m^3 (Figure 6).


Figure 6. Block Volume Calculation

Input the calculated value into the Volume parameter.

PlayDamageEffect
this is a boolean that determines if the block will play it's designated damage effect when underwater. If false the block will not spark/smoke underwater, it depends on what effect is defined in the block's definition. Damage Effect is a part of the vanilla block SBC, it's usually smoke/fire.
WaterConfig.xml (Planets)
Planets can be set up to automatically spawn water when the planet is placed, this is an old feature that I've ported into this new API. The old method still works but is considered obsolete.

<PlanetConfigs> <PlanetConfig TypeId="MyObjectBuilder_PlanetGeneratorDefinition" SubtypeId="EarthLike"> <WaterSettings> <!-- Run /wexport at the planet and paste the text here. --> </WaterSettings> <ColorIntensity>1</ColorIntensity> <Specularity>8</Specularity> <SpecularIntensity>2</SpecularIntensity> <AmbientColorIntensity>0.2</AmbientColorIntensity> </PlanetConfig> </PlanetConfigs>
Figure 7. Example of Planet Configs

WaterSettings
This is for spawning water on the planet automatically. I recommend setting up the planet settings in-game then running the command /wexport when you are ready to plug it into XML. That command will export XML text into your clipboard where you can then paste it into <WaterSettings>. Delete the property if you don't want water to spawn automatically.

ColorIntensity
This property is the brightness water appears to render, it's useful for planets that seem to make water darker than it should be.

AmbientColorIntensity
This property is the minimum brightness the water will render at night. Zero is completely black.

Specularity
This property is the sharpness factor of the specular reflections for the sun. The higher the value, the sharper it will be.

.png]
Wolfram Research (2007), Specularity, Wolfram Language function, https://reference.wolfram.com/language/ref/Specularity.html.

SpecularIntensity
This property sets the intensity of the specular reflection, increasing the value will make the reflection more intense.

DistantRadiusOffset
This is the maximum amount the water will grow when the camera is further from the surface, it can be used to improve how the planet looks from space.

DistantRadiusScaler
This property changes how fast the radius grows with the camera's distance from the surface, it is a power function where 2 is exponential, 3 is cubic, etc...
WaterConfig.xml (Characters)
Characters can be setup to behave differently from humans, such as being able to swim fast or breath underwater. This is notably useful for setting up NPCs with the Water Mod.

<CharacterConfigs> <CharacterConfig SubtypeId="Default_Astronaut" Volume="0.1" SwimForce="40" CanBreathUnderwater="False" MaximumPressure="2940" /> </CharacterConfigs>
Figure 8. Example of Character Configs

Volume

This is the amount of space the character takes up, it's hard to calculate so you can just leave it default.

SwimForce

SwimForce is the maximum force the character can use to swim around. The higher the value the faster the character can swim. If it's low, the character can't swim.

CanBreathUnderwater

This boolean toggles whether the character is able to breath water. If it is false the character will drown when underwater without a helmet activated.

MaximumPressure

This float is the maximum amount of pressure the character can withstand before taking crush damage. The unit is in KPa. The equation for hydrostatic pressure is p = ρ * g * h. Where ρ is fluid density, g is gravity, and h is height/depth. Make sure to convert Pa into KPa by dividing by 1000.
WaterConfig.xml (Respawn Pods)
Respawn pods can be setup to spawn on water, underwater, or on voxel. The SubTypeId is the SubtypeId of the Prefab's definition.

<RespawnPodConfigs> <RespawnPodConfig TypeId="RespawnShipDefinition" SubtypeId="Respawn Boat"> <SpawnAltitude>5</SpawnAltitude> <SpawnOnWater>true</SpawnOnWater> <SpawnOnLand>false</SpawnOnLand> </RespawnPodConfig> </RespawnPodConfigs>
Figure 8. Example of Respawn Pod Configs
The above example sets up the default respawn pod to spawn only on water at an altitude of 1000 meters.

SpawnAltitude

This is the altitude the pod will spawn at in meters.

SpawnOnWater

This is a boolean that determines if the ship can spawn on water or not.

SpawnOnLand

This is a boolean that determines if the ship can spawn on land or not.
WaterConfig.xml (Water Textures)
Water Texturess now must be defined in order to be able to set them. They will also show in the command /wtexturelist

<WaterTextures> <Texture>JWater</Texture> </WaterTextures>
Figure 8. Example of Water Materials List
The above example will make the transparent material JWater show in /wtexturelist. It will now be accessible to the player.

<WaterTextures> is an array, so just add a new line with <Material> and the TransparentMaterials SubtypeId. Check out TransparentMaterials.sbc for info on adding them.
WaterConfig.xml (Water Materials)
TODO if anyone needs it :)
WaterConfig.xml (Weather Configs)
TODO if anyone needs it :)
2 Comments
AryxCami 20 Aug, 2023 @ 10:51am 
Is there a way to make water not transparent in orbit? I've noticed it becomes extra-transparent when further away but this distance doesn't appear to be settable. I'm working on a planet with fairly deep oceans and high mountains so it has the problem of the water going fully transparent whilst the camera is still well within the atmosphere
Jakaria  [author] 31 Oct, 2021 @ 10:49am 
Please direct your questions to the Discord, where you're more likely to get responses from other players or I.
https://discord.gg/GrPK8cB