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
-
*** 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 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:
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!
-
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)?
-
Thank you! No, not currently. Did'nt think of that but i will fix that as soon as i can...
#removed unnecessary quote - bedges
-
Hi, I finally took a look at it.
Nice work on that lib!
But there are some bad points:
- The ArmaTypesDemo crashes with an unhandled exception when starting them without .net 3.5. And you need to start it via the console to see the exact exception to find out what happens. When I finally "uninstalled" .net 3.5 (that's what the setup told :blink: ), the demos work fine.
- No documentation on those demo. You have to find out yourself what they should show and what they should do.
- Your lib has no licence. Please add a licence to it.
- .net, so I can't use it easily without coding in .net.
-
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)?