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

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

IntantBuildingEnable not changing?

$
0
0
Code:
		  <InstantBuildingEnabled>false</InstantBuildingEnabled>  ("true" desired)
		  <GetOwnershipFromProjector>false</GetOwnershipFromProjector> ("true" desired)
Code:
void Main(string argument)
{
  // block declarations
  string ERR_TXT = "";
  List&lt;IMyTerminalBlock&gt; l0 = new List&lt;IMyTerminalBlock&gt;();
  IMyProjector v0 = null;
  GridTerminalSystem.GetBlocksOfType&lt;IMyProjector&gt;(l0);
  if(l0.Count == 0) {
	ERR_TXT += "no Projector blocks found\n";
  }
  else {...
IntantBuildingEnable not changing?

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

Rotor Lock

$
0
0
Hey people

The new patch notes mention:

  • Rotor lock added to scripting API

Does anyone anyone know what exactly was added?
This would really help my current project :)

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

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

Getting IMyThrust's orientation

$
0
0
Hello, I am currently working on a script that handles everything around hydrogen & hydrogen thrusters.
I came to a point where I need to get all thrusters in specific direction.

I tried to do it using IMyThrust's GridThrustDirection and comparing to to set of 3I vectors.
Strangely enough, GridThrustDirection returns nothing but 0 when nobody sits in the cockpit.

Is this really the intended behaviour of this getter, and if so, what can I use to get thruster's direction relative to cockpit...

Getting IMyThrust's orientation

1.186.201 Wheel information added for scripts/Mod


Generating a directional gps point

$
0
0
Does anyone has know how to get directional gps points? I've been trying to find a ship's directional vector (not the nose heading but it's current trajectory) and create a gps point 5km ahead of this trajectory. My aim is to use this gps point as an autopilot waypoint to be used as a speed brake for a simple gravity drive system. So far I've come up with this code but I not sure how to create the directional gps point. In the following script I'm using two blocks: a timer block used to...

Generating a directional gps point

Most useful cockpit function dont work in MP

$
0
0
Cockpit functions MoveIndicator, RotationIndicator and RollIndicator work for any cockpit(or even passenger seat) in single player. But in multiplayer they work only for Main cockpit.
Fixing it wont hit perfomance by any means, but some cool scripts will be possible.

SP behavior:


MP behavior:

IMyAirVent.GetOxygenLevel

$
0
0
In Testing
Creative, Earth-Like -200m sealevel:
Large Grid returns 0.90
Small Grid returns 7.2

Moved both up to 3000m sealevel:
Large Grid returns 0.90
Small grid returns 7.2
? ? ? ?
add/remove a block from both large grid and small grid
Large Grid returns 0.7131
Small Grid returns 6.267


So it appears unless a door opens or closes or a block added or removed, the grids do not update GetOxygenLevel
GetOxygenLevel returns 0-1 with 0.5 is 50%
Small grid returns well above the upper limit...

IMyAirVent.GetOxygenLevel

PB return value by use of events (idea/concept)

$
0
0
Some of you might have encountered the problem of PBs not being able to return a value to its caller. I know, this is kind of rare.

Theoretical problem:
You made library wich you're using in some of your scripts.
This library migght have grown to a point where it consumes to much space to be included.
You think: "oh well! why not put in into another pb an use it like an API!?" but then it hits you: PBs dont have any return value (besides using an lcd or customdata as buffer/cache)

I might...

PB return value by use of events (idea/concept)

Need help with gyro control logic - Greatly Appreciate any assistance

$
0
0
Hi guys.

I write a lot of code related to drones and making them do things like mine, dock, and stuff.. like that.
I'm having trouble with some simple... kind of simple logic that keeps tripping me up.

Here's the situation. I control the navigation of my drones by overriding the gyros and thruster's manually using code rather then using the good-Ai system.
The problem with the way I'm controlling the gyros is when a gyro is placed on grid facing a direction not matching my control block,...

Need help with gyro control logic - Greatly Appreciate any assistance

[resolved]projector.LoadBlueprint() not working?(it does work afterall)

$
0
0
hi im trying to make a script to automatically configure all of the projectors on a structure so i can build a space elevator, each section is welded by a climber and has a projector on it which projects the next section, since blueprints are stored in the projector by value and not by reference i need to constantly update all the projectors to the bottom most version (their are 4 nested sections of slack so the script docent have to run as quickly).

anyway everything is working except for...

[resolved]projector.LoadBlueprint() not working?(it does work afterall)

Vanilla default missile acceleration, start and max speed

$
0
0
I'm tuning a predicted interception point logic, and have issues with precise missile travel time calculation. Right now I'm using hardcoded value of 195, which works more-a-less well.

I've checked the sources recently, and found this:

Code:
if (ammoDefinition.AmmoType == MyAmmoType.Missile)
	{
		//missiles are accelerating, shotSpeed is reached later
		var mDef = (Sandbox.Definitions.MyMissileAmmoDefinition)ammoDefinition;
		if (mDef.MissileInitialSpeed == 100f &&...
Vanilla default missile acceleration, start and max speed

Self diagnosing flow chart framework

$
0
0
For some weird reason I have found making this kind of flow chart machinery interesting:

http://steamcommunity.com/sharedfiles/filedetails/?id=1350063872

the point of the whole circus is that you can define the functionality as a sequence of
flow chart states like this:
Code:
new ActionState(new BlockAction(ROT_CAMERA_NAME,
	action: camera_block => {
		var camera = camera_block.CastOrRaise<IMyCameraBlock>();
		camera.EnableRaycast = true;
	}), delay:1),

new...
Self diagnosing flow chart framework

Remote control gps script

$
0
0
I write a lot of python scripts for se, generating flight paths and things like that, however in game scripting has eluded me so far, I was wondering if anyone wouldnt mind providing a script that just loads a list of coordinates into a remote control for auto-piloting, for instance dropping space deliminated list of x y z coords into say custom data or a text panel that loads it into the remote control so that i dont need to have 100+ gps coords in my gps menu sort of thing. This script...

Remote control gps script

LF Speed Script

$
0
0
Hello together,

i´m playing on a server with a increased speedlimit of 500 m/s.
When i getting faster than 150 m/s and i fire some rockets, may ship get instantly rekt.
It seems that the shipspeed wasnt added to the speed of the rockets.

So i´m looking for a script/programm code that disable my rocket launcher at the speed of 150 m/s and acivates the rocket launcher, when the speed drops under 150 m/s.

I´ve no experience in programming/coding, so it will be nice to get some support for...

LF Speed Script

IMyInventory.CanItemsBeAdded usage

$
0
0
Some time have passed since last question about it so I wonder if today exists any possibility to use a method IMyInventory.CanItemsBeAdded and how to do that. This metod requires an argument of type "VRage.ObjectBuilders.SerializableDefinitionId" which can be build from a string and another argument of type "VRage.ObjectBuilders.MyObjectBuilderType".
It seems that a type SerializableDefinitionId is permitted in ingame scripts, but MyObjectBuilderType is not. Is there any way to obtain...

IMyInventory.CanItemsBeAdded usage

Rare exception when compiling code.

$
0
0
Whenever i try to make this:
Code:
List<IMyTerminalBlock> ListName = new List<IMyTerminalBlock>();
GridTerminalSystem.GetBlockGroupWithName("Group of blocks to get").GetBlocks(ListName);
That gets all the items in a certain group and puts them into a list. I get an execution exception that displays the following: Object reference not set to an instance of an object.

I know this error is common in C# when you put:
Code:
List<var> ListName;
instead of
Code:
List<var>...
Rare exception when compiling code.
Viewing all 903 articles
Browse latest View live