Jump to content
Sign in to follow this  
Ragnar_Darude

ArmaLib To .Net - library

Recommended Posts

*** 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 <---

A quick example code (in C#):

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">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:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">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)

Microsoft Visual Studio Express Editions

Share this post


Link to post
Share on other sites

Impressive work Ragnar_Darude thumbs-up.gif

Forwarded the news to some people most likely very interested in it. smile_o.gif

Share this post


Link to post
Share on other sites

Wow Ragnar .... thats so awesome ..... so much so that its intimidating ! notworthy.gif

It just scarely the amount of possible applications that I can't think of any lol !

Share this post


Link to post
Share on other sites

impressive work!

but i have a question about it..

Quote[/b] ]

Features of this library:

....

Parse or create ARMA-types: arrays, strings, numbers, code and objects.

for what i see. you would be able to send and array back to arma right?

i tried this.. it only does strings..

so i read up a bit on the documentation

Quote[/b] ]

ScriptLink

All communcation is done with null-terminated strings. When the client writes a null character into the pipe all the data before it will be available to the script to be read using slReadData. The client is free to write multiple messages into the pipe, they will be read as separate strings by the script.

ok so from this it seams its only sending strings to the pipe.

so how could i turn an list "array" sendt on the pipe to arma as string back to and array in arma?

eks.. im sending a list like ["foo","bar","moo"] to arma

anyone know of a function to split a string into an array?

eks.. split the string @ each "," chars

i checked out kronz script.. but it does split the hole string into a big array- "not want i need"

i tried to make a function like

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

SpltToArray = {

private["_input","_i","_array","_out"];

_input=_this select 0;

_array = toArray(str(_input));

_word="";

_splitpos=[];

_out=[];

_siz=0;

for "_i" from 0 to (count _array)-1 do

{

_a=(_arr select _i);

               // 44 = ,

if (_a == 44) then

{

_splitpos set[_siz,_word];

_siz = _siz + 1;

_word="";

}else{

_word = _word+toString([_a]);

};

};

//clear all empty indexes?? alot of "" in there!

      // fill new array as out

_csp=count _splitpos;

_oi=0;

for [{_i=0},{_i < _csp},{_i=_i+1}] do

{

if !((_splitpos select _i) == "") then

{

_out set[_oi,_splitpos select _i];

_oi=_oi+1;

};

};

_out

};

but its way is a big mess and not a good way. it needs a big fix

anyone willing to give and helping hand here?

Share this post


Link to post
Share on other sites
so how could i turn an list "array" sendt on the pipe to arma as string back to and array in arma?

eks.. im sending a list like ["foo","bar","moo"] to arma

Just execute it, for example if _str contains "[123, 456, 789]" do '_array = call compile _str'. It's not the most optimal way but propably good enough for most uses

Share this post


Link to post
Share on other sites

Oh.. quick & easy solution smile_o.gif

its not perfect. but its a start.

Thanks Kegetys.

Share this post


Link to post
Share on other sites

any one have an exsample where it reads and writes to a file with vars e.g

"sl_WriteData" extCall [THEPIPENAME, "W", "Filepath", "Var1","Value"]; // Write to the file

[THEPIPENAME, "R", "Filepath", "Var1","Value"]; // Load from the file

my C+ skills are forgetful

Share this post


Link to post
Share on other sites

i would suggetst useing the scriptlink helper.

the scriptlinke helper make it verry easy to implement your own stuff,,

the scriptlink helper is in python tho. so you would need python, and py2exe if you want to make an external app.. making python scripts/appps to dll is verry hard afik.

oh btw.. Kegety's scriptlink helper doesnt allows you to send back to arma.. only read the pipe.. i modified it a bit to make it send data on the pipe aswell. you can check out armapods sourcecode 0.93.

but ingame.. you can not read/write to a file directly by using armalibs

maybe he will update armalib soon whistle.gif

i can prolly give you an example later.. "at work atm,"

Share this post


Link to post
Share on other sites

I do not know if this can be answered but is it likely that this cool library can be ported to Arma2?

I mean, does it use official script functionalities, which might be also compatible with Arma2?

Share this post


Link to post
Share on other sites
I do not know if this can be answered but is it likely that this cool library can be ported to Arma2?

I mean, does it use official script functionalities, which might be also compatible with Arma2?

I'm not the original author of ArmAlib, but I can make some educated guesses.

Whether this will be available in ArmA 2 depends on:

- whether BIS implements some kind of IPC-interface (inter process communication) or even provides a SDK for creating DLLs

- time and motivation of Kegetys

- what kind of copy-protection and anti-cheat system is built into the game (basically ArmAlib is manipulating ArmA's process space and thus can be considered a 'cheat' or malicious software)

Hopefully, there will be something built into the engine.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×