malware-dev/MDK-SE

Properties of certain blocks do not work

FMuz opened this issue · 1 comments

FMuz commented

Properties of certain blocks do not work

Hello everyone,
And excuse my intrusion. I'm a couple of weeks into my first SE script. My knowledge is scarce but I am going to spend my time in the development of a script that simulates an Intranet network system Using Laser antennas and Radio Antennas for my SE faction.

First of all, thank you for this MDK and for making our lives easier. What would I do without you... Thank you very much!

I write here desperate because I see that certain procedures of certain mdk blocks do not exist. For example, the radio antenna block has procedures like TextHud, or Radius that don't work for me particularly.

At first I thought that it could be due to a bad definition of the variables or something, but no, I see that I cannot use certain procedures since it indicates that the property does not exist.

To reflect a little more information on the matter below, I paste a small function that simply wants to modify the radius of the antenna and little else.


public Boolean Antena_Invisible()
{
IMyRadioAntenna antena = GridTerminalSystem.GetBlockWithName(antenaRadioKeyword) as IMyRadioAntenna;
if (antena != null)
{
antena.Radius(0);
antena.TextHud("Starline");
return true;
}
else
{
LCD_Log(starlineLCDLogKeyword, " - Antena no encontrada");
return false;
}
}

Thank you in advance for your time reading me and if you can help me you don't know how much I would appreciate it.

I'm just looking for a way to change the range of my antennas, change the name of the antenna hud, etc.

Note that for the sake of my own sanity, I don't usually provide scripting help here, it's only for MDK issues. Scripting help is done at Keen's Discord #programmable-block channel, where I'm not alone about it. That said:

https://github.com/malware-dev/MDK-SE/wiki/Sandbox.ModAPI.Ingame.IMyRadioAntenna
Here are all available members. You'll note that what you're trying to set are properties not methods. Thus, you don't call them, you set them.

antena.Radius = 0;
antena.HudText = "Starline";

(note, HudText, not TextHud)

Other advice:
it's generally frowned upon in C# to use the .NET Framework names of the primitives. It's bool, int etc, not Boolean, Int32 etc. Finally - you shouldn't fetch your blocks on the fly like that. It's a relatively slow method. It's better to get your blocks in the constructor only once, and reuse the variables for them.