OFPEC Forum

Editors Depot - Mission Editing and Scripting => ArmA - Editing/Scripting Resources Beta Testing & Submission => Topic started by: Ragnar_Darude on 14 Sep 2008, 22:26:00

Title: ArmaLib To .Net - library
Post by: Ragnar_Darude on 14 Sep 2008, 22:26:00
*** ArmaLib To .Net library by Ragnar_Darude ***

This is a .Net - library to connect a program to ARMA through Kegety's ArmaLib ScriptLink-feature. You can send messages between your program and Arma and this library also helps you detect and parse the different types in Arma (arrays, numbers, strings...)

Some examples of usages for this library:
- Monitor and control your mission progress from another program
- Write a wrapper program so you can connect ARMA with your favorite database-engine (MySQL, MSSQL, Postgre...)
- Create AI-enhancments like neural-networks (example included)
- Create a program that photographs the Sahrani-terrain
- Control your house-robot from within ARMA
and so on...

Features of this library:
- Simple methods to connect and disconnect, read and write to the named pipe (the message stream)
- Asynchronous operation with a message loop that monitors the pipe for new messages and fires an event (example included)
- Parse or create ARMA-types: arrays, strings, numbers, code and objects.

Download:
http://files.filefront.com/ArmaLibToNetrar/;11780401;/fileinfo.html (http://files.filefront.com/ArmaLibToNetrar/;11780401;/fileinfo.html)

A quick example code (in C#):

Code: [Select]
Code Sample 
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ArmaLibToNet;

namespace SimpleScriptLinkDemo
{
   class Program
   {
       static void Main(string[] args)
       {
           ScriptLink sl = new ScriptLink(); // Create the connection object

           sl.Connect("my_pipe"); // Wait for a connection

           sl.Write("Hello!"); // Write to the pipe

           Console.WriteLine(sl.ReadString()); // Read from the pipe and print it out

           sl.Disconnect(); // Disconnect the pipe

           Console.ReadLine();
       }
   }
}

Init.sqf:

Code: [Select]
 
call compile preprocessfile "armalib\alibinterface.sqf"; // Compile the ArmaLib wrapper

THEPIPENAME = "my_pipe"; // Set a name for the connection

_sl = THEPIPENAME call slInit; // Initialize the connection

waitUntil{_sl call slIsConnected}; // Wait for it to connect

sleep 1; // Sleep a little while to wait for a new message

_data = _sl call slReadData; // Read new messges

player sideChat format["%1", _data select 0]; // Print out the first message

"sl_WriteData" extCall [THEPIPENAME, "Hi!"]; // Write to the pipe

Outputs "Hello" in ARMA and "Hi" in your program.

Links:
Kegety's Homepage - Creator of ArmaLib (required)
http://www.kegetys.net/arma/ (http://www.kegetys.net/arma/)

Microsoft Visual Studio Express Editions
http://www.microsoft.com/express (http://www.microsoft.com/express)

Please tell me if you find this useful!
Title: Re: ArmaLib To .Net - library
Post by: Mandoble on 14 Sep 2008, 22:49:57
This seems most interesting  :clap:
May the pipe you use have a network path (You run ArmA in a computer and run your client in another)?
Title: Re: ArmaLib To .Net - library
Post by: Ragnar_Darude on 14 Sep 2008, 23:21:30
Thank you! No, not currently. Did'nt think of that but i will fix that as soon as i can...



#removed unnecessary quote - bedges
Title: Re: ArmaLib To .Net - library
Post by: i0n0s on 06 Oct 2008, 22:18:47
Hi, I finally took a look at it.
Nice work on that lib!

But there are some bad points:
Title: Re: ArmaLib To .Net - library
Post by: Spooner on 07 Oct 2008, 02:32:28
Can't really complain about this being for .NET since it is a .NET library :scratch:. Still, .NET is sadly a bit obscure and/or unattainable for most people (Though I'm ashamed to admit it, I've worked with it a fair bit when I was last working, but that doesn't mean I own a copy myself).

Any chance this might work with Mono (http://www.mono-project.com/Main_Page)?