Quantcast
Channel: Programming (In-game)
Viewing all 903 articles
Browse latest View live

Gravity aligning thrusters

$
0
0
Hello, I wanted to try and create a script that uses thrusters on rotors to rotate them to match gravity for a modular miner I was going to try and build. I was wondering if anyone here had tried a project like this and how you went about it, since I was thinking about making it where you feed the gravity vector into the rotor and have it rotate the thruster to match the angle (or the inverse of it).

I attempted to look at the Gravity Aligned Camera script to see how he was rotating the...

Gravity aligning thrusters

[API Request] An Interface for block state for IMyTerminalBlock

$
0
0
I have also submitted this to the API Requests Thread and I am posting it separately here so that it can have it's own discussion.

I would like an Interface that is connected to IMyTerminalBlock that gives access to all the blocks non-modifiable block information (example: like rotor angle for rotors, or piston extension for pistons) without the need for downcasting from IMyTerminalBlock.

Currently we have "ITerminalProperty" and "ITerminalAction" that give us access to the properties and...

[API Request] An Interface for block state for IMyTerminalBlock

Block scripts requests thread

$
0
0
As programmable blocks came to SE, and not all players are programmers, I guess a thread with block requests is reasonable.

Basically, if you want a script on your block, post explanation here. Other programmers and I (Although I'm generally a busy person so maybe not often) will be more than happy to program it for you. Of course I still suggest you to learn programming, but you might not want to, and it's all fine. Other people like other things.
(Yes, I wanted to create website for that,...

Block scripts requests thread

Save and load variable?

$
0
0
So I'm trying to automate mining on my ship, I have pistons that need to go after each other in order to not break the drills. So I created a simple program.

Code:
public void Main(){
   IMyPistonBase Piston_up_one = (IMyPistonBase) GridTerminalSystem.GetBlockWithName("Mining - Piston up 1");
   IMyPistonBase Piston_up_two = (IMyPistonBase) GridTerminalSystem.GetBlockWithName("Mining - Piston up 2");
   IMyPistonBase Piston_down_one = (IMyPistonBase)...
Save and load variable?

Using Echo in separate class

$
0
0
Hello,

I have the Main method and I want to call another class. Inside the separate class (being a full script with it's own methods and class variables), I want to use Echo to display an output to the console.

I'm getting an error that 'Echo' isn't referenced / available in the separate class (called from main). I'm referencing the separate class as ??? xclass = new ???();

Is there a way to use Echo in another class and if so, how do I do it?

Thanks

UpperLimitDeg = UpperLimitRad

$
0
0
IMyMotorAdvancedStator

UpperLimitDeg behaves like UpperLimitRad.
UpperLimitRad behaves normally.

LowerLimitDeg behaves normally.
LowerLimitRad behaves normally.

Suspension Strength per Tonne

$
0
0
Does anyone have a more accurate formula to adjust suspension strength?

I've dabbled with the following formula:
0.0036x² - 0.1x + 6

[​IMG]

Be careful with it, because it becomes increasingly inaccurate over 17500 kg. Of course, it is also inaccurate at values lower than 17500 kg.

PHP:
// Only tested on small grids between 17500 and 50000 kg
float massTonnes vehicleMassTotal 1000;
suspension.Strength 0.0036f * (float)Math.Pow(massTonnes2) -...
Suspension Strength per Tonne

Accessing GridTerminalSystem from Sub-class without statics?

$
0
0
Sorry if this is a really obvious question but I couldn't find an answer elsewhere.

Since I started in-game scripting, I've always created a static reference to the master Program - something I almost certainly copied from someone else - at the top of the main script:

Code:
static Program me;

public Program()
{
	me = this;
}
I can then access GridTerminalSystem from anywhere via me.GridTerminalSystem.

Malware has frequently said that statics are bad, mmkay. As I'm just a hobbyist...

Accessing GridTerminalSystem from Sub-class without statics?

Autogenerated API index

$
0
0
This index contains all types and members available to ingame scripting - with exception to the .NET types, because including those would have made the listing far too big. There will be links to Microsoft's own documentation for those types where appropriate.

https://github.com/malware-dev/MDK-SE/wiki/Api-Index

Interface extension

$
0
0
Instead of doing this.

PHP:
class InventoryTable
{
    public 
IMyInventory Inventory getset; }
    public 
VRage.MyFixedPoint PreviousMass getset; }
}

I was thinking of doing this.

PHP:
interface IMyInventoryManager IMyInventory
{

    
VRage.MyFixedPoint PreviousMass getset; }
    
}

But, I'm getting an assembly error when I try to update PreviousMass.

PHP:
var inventory cargoContainer.GetInventory() as IMyInventoryManager;
inventory.PreviousMass = new...
Interface extension

PB Scripting Guide: How To Use Self-Updating

$
0
0
Greetings engineers! As you all have (hopefully) read in last week's update post, the PB now has some fancy new self-updating features which means you no longer need timer blocks!

This self-update system is relatively straightforward, but does require a bit of explanation, so let's get into it!


Update Frequency:
The self-update system is controlled through the Runtime.UpdateFrequency property. Those of you who are familiar with GameLogic components should recognize...

PB Scripting Guide: How To Use Self-Updating

New way to read inventory?

$
0
0
I got this error on test, in the EasyAPI code (which I had updated to handle currently live changes but that hasn't been pushed to github or the store).

There is no argument that corresponds to the required formal parameter `items` of `IMyInventory.GetItems(List<IMyInventory>, Func<MyInventoryItem, bool>`)
Adjusting to use MyInventoryItem instead of IMyInventoryItem, error:

'MyInventoryItem' does not contain a definition for 'Content' and no extension method...​

New way to read inventory?

New to coding, need a little help :-)

$
0
0
Hi there!
So I've *just* yesterday started coding, so complete newbie here.
Read up on the basics for C# and started to try it out ingame with a few trial program blocks, started with just turning on lights / opening doors, combining it, writing the results on lcd's etc. to kinda get the hang/feel for it.

So I wanted to up the stakes, but I can't find why my current script isn't working... the compiler gives a solid "succes" but nothing happens :(
(also guessing there is an easier way to...

New to coding, need a little help :)

IMyMechanicalConnectionBlock throw exception only when loading session

$
0
0
Hi o/

I face a strange behavior with IMyMechanicalConnectionBlock object.

Here's a code who works on function main() script; but not on program() only when call 1st time after loading a game, if I recompile after first exception all become fine again.


Code:
	// Identify and Rename Subgrids
	List<IMyMechanicalConnectionBlock> _MechConn = new List<IMyMechanicalConnectionBlock>();
	GridTerminalSystem.GetBlocksOfType<IMyMechanicalConnectionBlock>(_MechConn, x => SatisfyGridPolicy(x) &&...
IMyMechanicalConnectionBlock throw exception only when loading session

Quick Introduction to Space Engineers Ingame Scripts


My first ingame script [help]

$
0
0
Error In line 72 which is:
"GridTerminalSystem.SearchBlocksOfName("[Mining stop]", Alerts);"

Error CS1503 Argument 2: cannot convert from 'System.Collections.Generic.List<SpaceEngineers.Game.ModAPI.Ingame.IMySoundBlock>' to 'System.Collections.Generic.List<Sandbox.ModAPI.Ingame.IMyTerminalBlock>' MinerCargocheck
--- Automerge ---
Hello guys,

I finally got some time to start learning C# and try to make my first ingame script. I am writting...

My first ingame script [help]

Getting a warning in script

$
0
0
Hi there, can someone tell me why am I getting a Warning after compiling this script? And does anyone know if it breaks something within the code?

Warning: 'IMyShipConnector.IsConnected' is obsolete: 'Use the Status property'

Code:
public void Save()
{
}

public void Main()
{
/*======================================| VARIABLES |=====================================*/

//THRUSTERS
    var thrusters = GridTerminalSystem.GetBlockGroupWithName("PF_W_S1 - Thrusters"); 
    List<IMyThrust>...
Getting a warning in script

MDK: Malware's DevKit for Space Engineers

$
0
0
https://github.com/malware-dev/MDK-SE

MDK-SE
(Malware's Development Kit for SE)

A toolkit to help with ingame script (programmable block) development for Keen Software House's space sandbox Space Engineers. It helps you create a ready-to-code project for writing ingame scripts, and provides an analyzer which warns you if you're trying to use something that is not allowed in Space Engineers.

General features
  • Helps you create...

MDK: Malware's DevKit for Space Engineers

Using depency injection (DI) and several files

$
0
0
So, after coming back to SE after like 4 years, I have some reqeusts for the C# scritping system (not sure if they are implemented alaready).

Allow for people to define a class in a separate file, then use Dependency injection or usings to access these classes inside the scripts.

This would reduce script sizes enormously , since people can actually have 1 file per class, and reuse defined types in other scripts without having to reupload them.

Further it could lower the execution...

Using depency injection (DI) and several files

IMyInventory GetItems working?

$
0
0
Hmm The behavior of this has changed from how it was before and how it was during the release tests and it seems to be broken.
from the ingamte script interface for "IMyInventory" the method "GetItems"
void GetItems(List<MyInventoryItem> items, Func<MyInventoryItem, bool> filter = null);

Originaly this retruned the neede dinfo.
During the release tests it was changed to return void but ot accepted a list with the out keyword so that list would be populated with the needed info rather than...

IMyInventory GetItems working?
Viewing all 903 articles
Browse latest View live