ID:260727
 
Is there a way for a DLL file to respond back to BYOND? Like, call a proc or Topic()? If so, could you show a snippet of how one may achieve this? If not, could I request this as a feature?
Android Data wrote:
Is there a way for a DLL file to respond back to BYOND?
Like, call a proc

I would assume not directly. Byond would have to allow you to pass a function-pointer to the function in the DLL so that the DLL knew where the function was. Not only does Byond not support function pointers, but as far as I have read Byond only allows you to send text strings as DLL function arguments.

However, you could probably set something up to accomplish what you want in a not-nearly-as-easy-as-you-want method.

Either have the DLL function return a text string, then you can use call() a second time to call the appropriate function, or do something similarly crafty.

or Topic()?

If you mean open communications with the world as opposed to calling Topic() from inside the world directly (opening communications to talk the same way another world would, for example), then yes, that is something you can do. Just open a normal TCP socket to the running world's address and talk to it using the format that Byond worlds use to talk to each other. That would be the more difficult part, but, fortunately, I recall someone posted the format a long time ago. I don't remember who though, sorry, but it might be something you could dig up.

If so, could you show a snippet of how one may achieve this? If not, could I request this as a feature?

For having it call a Byond function (this is the easy and obvious one)...
var/callMe = call("mydll.dll","myfunc")("myargs")
call(text2path(callMe))

As for making something more complicated, you could have the world and the function in the DLL file talk to each other with an open socket, and you could make functions for handling your own "callback" system.
proc/myProc()
call("myDll.dll","myfunc")("callMePlease")

proc/callMePlease()
world << "I was called from the DLL"

world/Topic(T)
if(copytext(T, 1, 9) == "callback")
call(text2path(copytext(T, 9)))

And the DLL function would open a socket and send the appropriate message.

But then this goes right back to your question about using Topic()...

(edit)
This is not the post I was thinking of specifically, but it is basically the same thing. Someone constructing a message in PHP to send to a Byond world that will cause the Byond world to call Topic() and process a message.

It's not C, but it still demonstrates the message format. This should solve your problem.

(edit of the edit)
OOPS! Would help if I put in the id.
ID:394116

(edit2)
Even better yet...
[link]