Install Steam
login
|
language
简体中文 (Simplified Chinese)
繁體中文 (Traditional Chinese)
日本語 (Japanese)
한국어 (Korean)
ไทย (Thai)
Български (Bulgarian)
Čeština (Czech)
Dansk (Danish)
Deutsch (German)
Español - España (Spanish - Spain)
Español - Latinoamérica (Spanish - Latin America)
Ελληνικά (Greek)
Français (French)
Italiano (Italian)
Bahasa Indonesia (Indonesian)
Magyar (Hungarian)
Nederlands (Dutch)
Norsk (Norwegian)
Polski (Polish)
Português (Portuguese - Portugal)
Português - Brasil (Portuguese - Brazil)
Română (Romanian)
Русский (Russian)
Suomi (Finnish)
Svenska (Swedish)
Türkçe (Turkish)
Tiếng Việt (Vietnamese)
Українська (Ukrainian)
Report a translation problem
It should get rid of the errors but a lot of deprecation warnings still remain I just wanted to try this API first, and hopefully, someone else could verify that it still works on their existing code
Just replace the very long last line, the one with the minified library code with this:
<I tried to paste the very long line here but it exceeded the 1000 char limit>
Any suggestion as to how I could send the fix for everyone here?
42/19765, There is no argument that corresponds to the required formal parameter 'items' of MyInventory.GetItems
In my example https://gtm.steamproxy.vip/workshop/filedetails/discussion/379297410/357288572132613477/ everything goes well :)
LKS
LKS
LKS
If you write this:
Blocks.Named("LCD [AP] (O1)").GetBlock(0).<whatever you want>
If no block was found you cought an exception like "index out of range". A better way should be "do no action" don't you think ?
LKS
And you can use it like that:
public class Example : EasyAPI
{
public Example(IMyGridTerminalSystem grid, IMyProgrammableBlock me, Action<string> echo, TimeSpan elapsedTime) : base(grid, me, echo, elapsedTime)
{
// Start your code here
Blocks.NamedLike("Blabla").GetBlock(0).BlaBla();
}
}
And f.e. a block named "PB (Blabla)" will echoes "PB (Blabla) BlaBla" ... a silly example but yes, a proof of concept ;)
LKS
You can use Echo in extensions like this one:
} //Trick: close the Program class so we can define Extensions classes
public static class EasyEXTBlaBla
{
public static void BlaBla(this Program.EasyBlock easyblock)
{
Program.Echo(easyblock.Name() + " BlaBla");
}
//Trick: no closing brace here, SE will close it automaticaly
(cont ...)
/*********************************************/
/*** Advanced users only beyond this point ***/
/*********************************************/
Example state;
public static Action<string> Echo;
void Main(string argument)
{
Program.Echo = (this as MyGridProgram).Echo;
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);
}
(cont ...)
In this case EasyEXTHelpersColors here: http://pastebin.com/TZg7HSLd
It does a conversion from a string to a color, like this:
public void Main(string argument)
{
Color color = "{R:10 G:20 B:30 A:255}".ToColor();
Echo(Convert.ToString(color));
}
@rockyjvec: u to you to say to me where store my code ? I have 3 choices: pastebin, githup (if I have an access to your repository let's say in a subfolder like "EasyEXT", of even in the discussions section here ?
LKS
I think it should be cool to implement it in the EasyAPI core ? So EasyAPI extensions can use it (useful for debuging)
LKS
I do like MMaster and CAL (one of the most powerful ones) but I don't want to depend any more on it for some "extra" features, like triggering an event in case of critical value (refused) or display only the informations I need (f.e. one line saying that your ions are 7/10 On, instead of having a huge list of 10 ions displaying On/Off)
LKS
BTW: possible to have some tchat on Steam sometimes ? Much more faster, I think ;)
Get works for Boolean, String ... issues with certain types such as StringBuilder (Keen's known bug, again) and other exotic ones (no way to handle them at this time).
When (partially) done I will publish it (on pastebin ?) and give you the link. I will use it for myself (to display only certain properties values on LCDs) but up to you to integrate it in the core code (usefull to re-write the DebugDumpProperties, f.e.)
More to come ;)
LKS
PS: when/if I have time I will try to work on autopiloting, etc ... Again a shame that Keen does not give any access to the remote control (tautopilot to a GPS point) neither to jump drives (idem). So a bit much more complicated :(
LKS
If I understand well: "public static Action<string> Echo;" is a kinda pointer to a function (like in C, C++) or am I wrong ?
So you link it to the KeenAPI Echo at runtime and then you can call it from outside and it will be "forwarded" ?
BTW Action is a "generic" (?) type provided by the KeenAPI ?
LKS
public static Action<string> Echo;
void Main(string argument)
{
....Program.Echo = (this as MyGridProgram).Echo;
}
then in your extension method you can call Echo like this:
Program.Echo("hello world");
;)
LKS
LKS
// Start your code here
String output = "Say Hello:\n";
Blocks.NamedLike("[EXT]").Hello(ref output);
Echo(output);
...(after the minified EasyAPI code)
} //Trick: close the Program class so we can define Extensions classes
public static class EasyAPIExtensions
{
public static Program.EasyBlocks Hello (this Program.EasyBlocks easyblocks, ref String output)
{
for(int i = 0; i < easyblocks.Count(); i++)
{
easyblocks.GetBlock(i).Hello(ref output);
}
return easyblocks;
}
public static Program.EasyBlock Hello (this Program.EasyBlock easyblock, ref String output)
{
output = output + "Hello " + easyblock.Name() + "\n";
return easyblock;
}
//Trick: no closing brace here, SE will close it automaticaly
LKS
} //Trick: close the Program class so we can define Extensions classes
public static class EasyAPIExtensions
{
public static Program.EasyBlocks Hello (this Program.EasyBlocks easyblocks)
{
for(int i = 0; i < easyblocks.Count(); i++)
{
easyblocks.GetBlock(i).Hello();
}
return easyblocks;
}
public static Program.EasyBlock Hello (this Program.EasyBlock easyblock)
{
//Program.Echo("Hello " + easyblock.Name());
return easyblock;
}
//Trick: no closing brace here, SE will close it automaticaly
But the fact Bocks is now public is a good point. New problem: as you can see (commented) I can't get any access to the Echo command :/ Any Clue ?
BTW this works also:
// Start your code here
Blocks.Named("").Hello();
Echo("OK");
But the fact is I cannot have any aoutput from the Hello command itself :/
LKS
} //Trick: close the Program class so we can define Extensions classes
public static class EasyAPIExtensions
{
public static Program.EasyBlocks Hello (this Program.EasyBlocks easyblocks)
{
return easyblocks;
}
//Trick: no closing brace here, SE will close it automaticaly
But the problem is that I have no access to the Blocks attribute ...
When I try ...
for(int i = 0; i < easyblocks.Blocks.Count; i++)
{
}
It says to me that Program.EasyBlocks contains no definition of Blocks, neither Extention method ... so how can I have access to the attribute of the extended class ?
LKS
Program.EasyBlocks
Program.EasyBlock
} //Trick: closte the Program class so we can define Extensions classes
public static class EasyAPIExtensions
{
public static EasyBlocks Hello (this EasyBlocks easyblocks)
{
for(int i = 0; i < this.Blocks.Count; i++)
{
this.Blocks[i].Hello();
}
return this;
}
public static EasyBlock Hello (this EasyBlock easyblock)
{
echo("Hello " + easyblock.Name());
return this;
}
//Trick: no closing brace here, SE will close it automaticaly
It says to me that the type or namespace EasyBlocks can not be found. Same for EasyBlock (what a surprise !?). So how can I extend them ?
LKS
class Program {
....void Main()
....{
....}
}
extension classes cant be in another class so we insert a closed bracket to break out of the Program class like this:
....void Main()
....{
....}
} // extra close brace
class TestExtension { // unterminated brace at the end
On the backend, what actually happens is this:
class Program {
....void Main()
....{
....}
}
class TestExtension { // this was unterminated in our code but space engineers still has the next brace which used to end the Program class but now ends our TestExtension class
}
For that example I just extended the string class to have an output method which outputs the string to the programming block via an exception.
You have to add an end bace at the end of the minified code, then put your extension class, then leave off the last end brace in your extension class.
Can you give me an example of a working class extension please ?
LKS
The terminating brace I mentioned below should appear at the very end of the script. So in the case of EasyAPI it would go after all the easyapi code. This is exactly the method I was going to use a few months ago to add features to easy api in a modular way.
Yes, you can add methods to easyapi using extension methods like you did below. The trick is that you have to trick the programming block in to terminating the parent class and then leave off your last end curly brace so the one in the parent class terminates it. I'll try to give you a working example later today but here is the general idea
void Main(str args)
{
}
} // this brace closes the parent class that is not visible in the programming block
// define your extension classes here
class ExtensionClass {
// leave off the closing curly brace because the parent class closes it for you
// note: this has been discussed in keen forums and the last I heard it was allowed because scripts are still required to follow complexity rules, etc.
(That's why the rest is in italic)
LKS
public static class EasyAPIExtentions
{
public static EasyBlocks Hello (this EasyBlocks easyblocks)
{
for(int i = 0; i < this.Blocks.Count; i++)
{
this.Blocks .Hello();
}
return this;
}
public static EasyBlock Hello (this EasyBlock easyblock)
{
echo("Hello");
return this;
}
}
Nothing works :/ I always get error messages when checking code (also whenI tried to use non static classes/methods). And I really need that for example to add a "Rename" method for EasyBlock(s) to change their names, add parsing to LCDs, etc etc ... Heeeelp me please ;)
LKS
Can you add in the DebugDumpProperties method:
1° the actual value it has ?
2° a way to filter the property you only want ?
So you can get a return like this: DebugDumpProperties(false, "Override");
And receive a string like "Single Override 100" only and not the whole stuff ?
Is it in C# an easy way to "overload" classes such as EasyBlocks ? Because if I want to add methods to them I prefer to add them externaly, instead of having to break your code (that I don't want and neither have to minify it again). So for example to add a thing like this (formal syntax):
EasyBlocks::MyMethod(args) ...
And then call:
Blocks.MyMethod(args) ...
Is it possible ?
LKS