.Net Tutorial

Hello Everyone,

I have been looking through the forums and I notice a lot of people want a tutorial on how to use ISXEVE in .net. I have also been looking for examples and a good tutorial to use, but atlas I haven't been able to find one. So after some toying around I am going to write a quick tutorial on how to get your apps started.

First to note is that you should have the latest Innerspace (build 5513 or greater) as it allows for the use of .net framework 4.0
As well this tutorial is written in C#.

Let's start
------------------------------------------------------------

Setting up the Project

Step 1. Create a new project (windows form application, or whatever your heart desires to make).


Step 2. Right click on the project and add the following references:
(The following are found in the root of the InnerSpace Directory)
Lavish.InnerSpace.dll
Lavish.LavishNav.dll
(The Following is found in InnerSpace/.Net Programs)
ISXEVEWrapper.dll

These will allow you to use the isxeve and innerspace libraries.

For a good reference keep: http://eve.isxgames.com/wiki/index.php?title=Main_Page open as a lot of the members/methods are named the same thing as in the wiki.

Step 3. Right click the project and click properties and go to the "Build" tab.
Under the output heading where it says "Output Path:". Click the browse button and browse to the "InnerSpace/.Net Programs/" directory.
*This sets the compiler to build the program in that folder so you can build it and run it from the eve client without having to copy anything.*

That's it for setting up the program stuff, we can now do some programming!

--------------------------------------------------------------------------------

I will walk you through a very simple program that gets the names of all the pilots in local and displays it on a list. (Consider this the hello eve application)...

First thinks first, make a form with a listbox (name it with a good name) and a button.

For the sake of this application the listbox will be named PilotList and the button will be named Button1

After doing that and go double click the button (this should bring you to the code designer with a onclick event for the button)...

You should now have some that looks like the following:

Code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Threading;

namespace HelloEve {
    public partial class Form1 : Form
    {
        public Form1() {
            InitializeComponent();
        }
        private void Form1_Load(object sender, EventArgs e) {

        }
        private void button1_Click(object sender, EventArgs e) {

        }
    }
}
Now we also want to be able to use the lavishscript / ISXEVE namespaces in our project.

At the top of the file, directly under:
Code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
Add the following:

Code:
using EVE.ISXEVE;
using LavishScriptAPI;
using LavishVMAPI;
(my one problem with the ISXEVE wrapper is that "EVE" is used as a namespace and as a object... Seems to confuse intellisense every now and then)

Ultimately we would like our program to obtain a list of pilot names when the user clicks the button on the form. So in our button_Click event method
we are going to want to do the calculations.

Before going on and showing you the code, I would like to direct you to the following website: http://www.lavishsoft.com/wiki/index.php/NET:Concepts:Frame_Locking#OnFrame_LavishScript_event
This is the most important concept to getting your .Net application to be used inside of eve.

So what is the FrameLock?

It's essentially a method to allow our thread (form/program/whatever) to read the object data from the eve client. What it does, is stops the client from advancing the frame and overwriting the object we may be wanting to use. Thus allowing us to get consistent data for that particular frame in the game loop.

Anyway, I am fairly poor at explaining these things. So I would recommend taking a read through it to get a better understanding of what it does.

So, how do we use this in our applications?

Well let's jump back to our button click method. And do the following:

Code:
private void button1_Click(object sender, EventArgs e) {
	using (new FrameLock(true)) {
		EVE.ISXEVE.EVE eve = new EVE.ISXEVE.EVE();
		List<String> pilotNames = new List<string>();
		foreach (Pilot p in eve.GetLocalPilots()) {
			pilotNames.Add(p.Name);
		}
		PilotList.DataSource = pilotNames;
	}
}
Breaking this down, we declare a new FrameLock
Code:
using (new FrameLock(true))
for a section of code (again this locks the frame so we can obtain some data).
If you want to update any of the eve members, you must framelock first!

Next we create an EVE.ISXEVE.EVE object (I wrote this the long way because intellisense thought it would look better). This is basically the EVE object on the wiki, thus we are able to use all the same methods and members listed on the wiki. The one we are looking for is "GetLocalPilots", which will get a list of pilots in the current system.

Now we only want the names, so we make a list of strings that will represent the names of the each pilot.

Now we get to the loop:
Code:
foreach (Pilot p in eve.GetLocalPilots()) {
    pilotNames.Add(p.Name);
}
What this does, is gets every Pilot (Pilot is a built-in ISXEVE datatype) from the list that is returned from GetLocalPilots. And even though this takes a parameter, it's not needed (I can only assume the parameter is for filtering).
From there we fill the list of strings that we declared earlier with the pilots name (p.Name member).

The last part is the assign the datasource for our listbox. This essentially gives the listbox it's display data, and it takes a IEnumerable, how convenient


Alright that's it!!!

you should have code that looks like the following:

Code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Threading;

namespace HelloEve {
    public partial class Form1 : Form
    {
        public Form1() {
            InitializeComponent();
        }
        private void Form1_Load(object sender, EventArgs e) {

        }
		private void button1_Click(object sender, EventArgs e) {
			using (new FrameLock(true)) {
				EVE.ISXEVE.EVE eve = new EVE.ISXEVE.EVE();
				List<String> pilotNames = new List<string>();
				foreach (Pilot p in eve.GetLocalPilots()) {
					pilotNames.Add(p.Name);
				}
				PilotList.DataSource = pilotNames;
			}
		}
    }
}
You should be able to build this and run it in eve by using the DotNet command ("DotNet HelloEve").
Your form should now be launched from eve (make sure you are running in window mode!). Click the button and see the list populate with the names of all the pilots in local.

I hope some of you find this useful, I am sorry if I did not explain things very well...
This is my first tutorial, so don't be too harsh.

I will be happy to write more if people request use of different features, or post code to get people on their way.

Happy Flying!
 

tinyromeo

Active Member
Great tutorial!! Quick, concise, and includes one of the largest hurdles I have been having... Where to start. I didn't know which application type to use for a dotnet app. Now for some interrogations, cause I find myself now with new questions that I think anyone in my position would have...
Does using the windows form app type create and display a UI element? Would using a different application type wield different results? I noticed the InitializeComponent(), so I think that answers most of my questions, but I think its the choice of app types kinda confuses me.
Whats next?!?! We have our list of pilots now... how do we interact with that information? Could you put in a step 2? I mean I didn't try building it, but I notice we don't ever interact with one of those pilots. Can you show us how to use/interact with the information we have stored while using framelock properly? I hear that after the framelock the objects are no longer usable. So would we then interact with the data inside of this same method, or carry the framelock to a new method, or release the framelock...
AHHH Stupid framelock.....
I dunno, I always wanted to learn dotnet, but use it... maybe someday... And your single page has enlightened me more than my entire year of scouring for information. Since your tutorial is so well spoken I hope I can ask you for just that little bit more...
Maybe add how to :InviteToFleet or :WarpTo or something like that. Can you show us what to do with the objects once we have acquired them, and how to use Framelock a little more? Framelock is a scary thing to me and is the main reason now keeping me from going to c#.
I guess if you are up to it, maybe put up two separate examples with some common and contrasting ideas, I think that would nail the coffin shut on this dotnet thing is if there were at least 2 good examples to compare and contrast. I know I am being needy here, but the net seems to be completely devoid of any good c# examples so I am going to hop on this opportunity to pick apart someone with knowledge.
So ya... if you are up to it maybe give us an example of how to retrieve (already great tutorial) then interact with the pilots based on the listbox/button, then maybe an example of something like iterating through your hangar items, moving a few, storing info, and display some totals to the user in the end. I think this would provide very solid foundational knowledge for anyone attempting dotnet.

Once again great tutorial, pwetty pwease can I has more nao?!:evil:
 
Hey Tinyromeo,

I will post another tutorial doing more advanced things today. For now I will answer your question about the windows form app.
So when you run the program from the innerspace console, it creates a new thread that is your application. The key behind innerspace is that it allows your thread to communicate with the main innerspace thread. With that being said if you create a project with a different type (WPF, Console, w/e) it will create that type of program.

Unfortunately for this, the dotnet app will not run inside eve (it will not make the UI in eve like evebot). On the plus side you get a much nicer language with a butt load of features. Now I haven't tried it but there are lavishscript / ISXeve methods to create a UI in game. I can only imagine that this can be accomplished from your .net app, but it would require some tweaking.

Ultimately it doesn't matter what app choice you use as long as you are happy with interacting with it. I chose a form app, because I like pressing buttons to do things. However if you just wanted an application to run something in the background then a console app would be more than sufficient (check: http://social.msdn.microsoft.com/Fo.../thread/26396b5e-6ebf-426a-86ae-a767719db9b9/ - This would allow you to hide your app in the background, so you never have to see it. But you lose interaction with this method).
 

CyberTech

Second-in-Command
Staff member
You should not be interacting with ISXEVE for game data inside UI code; you should only be doing that from within the ISXEVE_OnFrame event. Outside that event any interaction with ISXEVE will have undefined behavior.
 

tinyromeo

Active Member
And all that makes sense, but saying is easier than doing. You can prattle on all day about how to do it right, but without an example it kinda falls on deaf ears.
Which is why I am eagerly awaiting part 2!
 

CyberTech

Second-in-Command
Staff member
And all that makes sense, but saying is easier than doing. You can prattle on all day about how to do it right, but without an example it kinda falls on deaf ears.
Which is why I am eagerly awaiting part 2!
I suppose I should just cease my prattle, then, and let you get on with using a design which will result in instability and necessitate a core rewrite later. Good luck to you!
 

tinyromeo

Active Member
Thats my bad cyber, rereading that it came out with more flame than I intended.
It wasn't my intent to insinuate there wasn't going to be issues with integrating an interaction in the onframe event, I just don't know shit about this and when the typical response to someone asking for just a bit more elaboration is "DO IT THIS WAY" it is really frustrating.
So far I have found exactly dick searching for this mysterious coding style. Just one example of using the onframe properly is all I ask...
 

Amadeus

The Maestro
Staff member
I'm amazed no one has offered Stealthy money to write a stupid-simple .NET bot that did nothing but show how to do things (i.e., a 'hello world' bot for innerspace/isxeve.)

Personally, I see no reason to mess with .NET. Lavishscript can do everything you need to do and stupid easy to learn. If you can write C#, you can write lavishscript.
 
I'm interested in this too,please slowpython go with the second tutorial

This is a reason to learn c#,never had a good project to start really learning it
 

CyberTech

Second-in-Command
Staff member
I'm amazed no one has offered Stealthy money to write a stupid-simple .NET bot that did nothing but show how to do things (i.e., a 'hello world' bot for innerspace/isxeve.)

Personally, I see no reason to mess with .NET. Lavishscript can do everything you need to do and stupid easy to learn. If you can write C#, you can write lavishscript.
I asked Stealthy to update the ISXEVE_Bot_Framework in the .net sample dir on isxgames repo. There's not much he'll have to update, I think, so hopefully he can get it done in a few days. It'll make a decent example.

Also, I've spoken with slowpython on IRC about the techniques.
 

stealthy

ISX Specialist
I asked Stealthy to update the ISXEVE_Bot_Framework in the .net sample dir on isxgames repo. There's not much he'll have to update, I think, so hopefully he can get it done in a few days. It'll make a decent example.

Also, I've spoken with slowpython on IRC about the techniques.
Now that we're making progress on this damned crash I may get to! :p
 
Top Bottom