ID:116069
 
Applies to:DM Language
Status: Open

Issue hasn't been assigned a status value.
Although the current system for external library functionality is adequate for most situations, it would be very nice if we could call BYOND procs from within out external libraries.

I see this as looking something like the following: the external library calls some function (e.g. BYOND_call_function("byond_world", "function name", "arg1",...)) which then queues a call to that function in the specified world. The world would essentially be the PID or some such of the target world.

So, an example usage would look something like this:

DM World:

proc/do_long_operation()
call("library.dll","long_op_start")(world_id,"arg1","arg2")

proc/long_op_done(result1,result2)
world << "long op returned [result1] [result2]"


C Lib:


#include

char byond_world_id[32];

void long_op_start(int argc, char **argv)
{
    strcpy(byond_world_id, argv[0]);

    //create a new thread running long_op_function
    create_op_thread(long_op_function, argv[1], argv[2]);
}

void long_op_function(char *val1, char *val2)
{
    //do lots of work
    byond_call("long_op_done",result1, result2);
}


Now technically similar functionality can already be done using world/Topic(), however this requires that you set up an http connection in your C lib which is a fairly complex solution. Additionally this can present a security threat if not implemented correctly.

As an extension, functions to get (and possibly set) BYOND global (or even datum specific, if a tag or ref is provided) variables.