Space Engineers

Space Engineers

EasyAPI
Showing 31-40 of 58 entries
< 1  2  3  4  5  6 >
Update: 15 May, 2015 @ 7:29pm

Added support for Programmable Block arguments. There is a new event On() which allows you to trigger an event when the specified argument gets passed in. Example below. I changed the way the script gets the running pb since Me was added and added support for the Echo function in EasyAPI.

In this example, if you drag the "Run" action of the pb block to a button panel and give it "Up" as the argument, then when you press that button it will print "Up was pressed" to the exception area in the PB.

public class Example : EasyAPI { public void pressedUp() { Echo("Up was pressed"); } public Example(IMyGridTerminalSystem grid, IMyProgrammableBlock me, Action<string> echo, TimeSpan elapsedTime) : base(grid, me, echo, elapsedTime) { On("Up", pressedUp); } }

NOTE: THIS UPDATE IS SLIGHTLY INCOMPATIBLE WITH PREVIOUS VERSIONS. YOU SIMPLY NEED TO CHANGE THE CONSTRUCTOR LIKE BELOW:

Change (in Example class):
public Example(IMyGridTerminalSystem grid) : base(grid)
To:
public Example(IMyGridTerminalSystem grid, IMyProgrammableBlock me, Action<string> echo, TimeSpan elapsedTime) : base(grid, me, echo, elapsedTime)

AND

Change Main() so it looks like this (added argument, Me and Echo):
void Main(string argument) { if(state == null) { state = new Example(GridTerminalSystem, Me, Echo, ElapsedTime); } // Set the minimum time between ticks here to prevent lag. // To utilise onSingleTap and onDoubleTap, set the minimum time to the same // time period of the timer running this script (e.g. 1 * EasyAPI.Seconds). state.Tick(100 * EasyAPI.Milliseconds, argument); }

Update: 30 Apr, 2015 @ 1:23am

Merged Bush Tucker Man's lifecycle methods

Update: 27 Apr, 2015 @ 11:52pm

Added FindOrFail function

This makes it easy to prevent your script from running without all the
required blocks. Basically you call something like
Blocks.Named("Timer").FindOrFail("Timer is missing!"); and if the block
is missing, the message will display in the exception area.

Update: 26 Apr, 2015 @ 9:45pm

Changed debug functions so you can pass in false to them to return the debug string instead of throwing an exception.

Update: 7 Apr, 2015 @ 8:38am

Fixed a bug with Plus/Minus functions, changed GetThis to GetSelf

Update: 5 Apr, 2015 @ 9:32pm

Added easier event api for adding multiple events to an EasyBlocks set.
Here is a quick example that will call the function below when a reactor is damaged beyond 50%

public bool whenReactorDamagedBeyond50Percent(EasyBlock b)
{
// Do something here when a reactor is damaged beyond 50 percent
return false; // Remove the event once it is triggered. Otherwise it will continue to be called until the Damage goes back to above 50%.
}

AddEvents(
Blocks.OfTypeLike("Reactor"), // Add this event to each of these
delegate(EasyBlock b) { // When this function returns true, the event is triggered
return b.Damage > 50; // when the block is damage more than 50%
},
whenReactorDamagedBeyond50Percent
);

Update: 5 Apr, 2015 @ 9:14pm

Added advanced filter: FilterBy() to the EasyBocks class. Here is a quick example to find all blocks damaged greater than 50%:

EasyBlocks damaged50percent = Blocks.FilterBy(delegate(EasyBlock b) {
return b.Damage() > 50;
});

Also added Damage() (percent damaged), CurrentDamage() (the amount of integrity damaged) and MaxIntegrity() (The max integrity).

Update: 5 Apr, 2015 @ 3:35pm

Made EasyBlocks Plus and Minus functions distinct and simplified them.

Update: 25 Mar, 2015 @ 6:13pm

Added new WithInterface<T>() block filter which allows you to find blocks that have a certain interface. The advantage to this is that it allows you to, for example, find all blocks that use the IMyDoor interface which includes all modded doors. If you use OfType("Door") it only finds the vanilla doors.

Example:
EasyBlocks allDoors = Blocks.WithInterface<IMyDoor>();

Update: 25 Mar, 2015 @ 8:43am

Merged EasyUtils class from github.
https://github.com/rockyjvec/EasyAPI/commit/5fcbfb00155de9f02c0f9d03f8cb4ed48af39225