Skip to content

Instantly share code, notes, and snippets.

@csmith
csmith / SoundDescExample.xml
Created December 4, 2015 09:22
Example of adding sound descriptions for Space Engineers
<SoundDesc Id="TtsDockedBay1" SoundName="Base sounds: Docked, Bay 1" />
<SoundDesc Id="TtsDockedBay2" SoundName="Base sounds: Docked, Bay 2" />
@csmith
csmith / SoundDefinition.xml
Created December 4, 2015 09:11
Example definition of a sound in SpaceEngineers
<Sound>
<Id>
<TypeId>AudioDefinition</TypeId>
<SubtypeId>SoundId</SubtypeId>
</Id>
<Category>Sb</Category>
<MaxDistance>100</MaxDistance>
<Volume>1.00</Volume>
<Loopable>false</Loopable>
<Waves>
@csmith
csmith / SoundsSkeleton.xml
Last active December 4, 2015 09:20
Skeleton sounds definitions file for Space Engineers
<?xml version="1.0"?>
<Definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<SoundCategories>
<SoundCategory>
<Id>
<TypeId>SoundCategoryDefinition</TypeId>
<SubtypeId>MyModId</SubtypeId>
</Id>
<Sounds>
@csmith
csmith / Actions.cs
Created December 3, 2015 16:52
Snippet to show how to list actions in Space Engineers
List<ITerminalAction> actions = new List<ITerminalAction>();
block.GetActions(actions);
foreach (var action in actions)
{
Echo(action.Id + " " + action.Name);
}
@csmith
csmith / ElapsedTime2.cs
Created December 3, 2015 11:31
Demo SpaceEngineers script showing use of ElapsedTime while accounting for various edge cases
TimeSpan LastElapsedTime;
void Main(string argument)
{
if (ElapsedTime.TotalSeconds == 0)
{
// First run. The script has just been created/compiled, or the game was loaded.
SetupThings();
}
else if (LastElapsedTime == null || ElapsedTime < LastElapsedTime.Add(TimeSpan.FromSeconds(10)))
@csmith
csmith / ElapsedTime1.cs
Last active December 3, 2015 10:46
Simple demo of using ElapsedTime in a SpaceEngineers script
void Main(string argument)
{
Echo("Time since last run: " + ElapsedTime.TotalSeconds);
}
@csmith
csmith / antenna.cs
Created December 2, 2015 06:58
Sample code showing debugging using antennae in Space Engineers
void Main(string argument)
{
var blocks = new List<IMyTerminalBlock>();
GridTerminalSystem.GetBlocksOfType<IMyRadioAntenna>(blocks);
blocks[0].SetCustomName("Received argument: " + argument);
}
@csmith
csmith / Actions.cs
Created December 2, 2015 06:42
Sample code showing old and new action styles for Space Engineers
void Main(string argument)
{
var block = GridTerminalSystem.GetBlockWithName("Beacon");
// Verbose way:
block.GetActionWithName("OnOff").Apply(block);
// Better way:
block.ApplyAction("OnOff");
}
@csmith
csmith / SolarPanel.cs
Last active December 2, 2015 06:44
Sample code to retrieve solar panel output in Space Engineers
void Main(string argument)
{
var info = GridTerminalSystem.GetBlockWithName("Solar Panel").DetailedInfo;
var lines = info.Split('\n');
var output = lines[2].Split(':')[1].Trim(); // output = "110 kW"
}
@csmith
csmith / Storage.cs
Created December 2, 2015 06:27
Using script storage in Space Engineers programmable blocks
void Main(string argument)
{
// Read some persisted data from Storage
Echo("Argument from last time was " + Storage);
// Write some data to Storage
Storage = argument;
}