macro_rules! byond {
( $n:ident ; $c:block ) => { ... };
( $n:ident : $( $p:ident ),* ; $c:block ) => { ... };
}
Expand description
Define a function that BYOND can call into.
The list of arguments is always &str
, and the code block must return an impl AsRef<[u8]>
.
If you want finer control over the arguments and return value,
consider using from_byond_args
and return_to_byond()
directly.
§Examples
// Define a function called "test", taking two arguments.
byond!(thing: one, two; {
format!("{} + {}", one, two)
});
The above code can be called with the following DM code:
// Produces "a + b" without quotes.
world.log << call("test.dll", "thing")("a", "b")
§Panics
Panics if the amount of arguments supplied by BYOND is too small. Note that extra arguments are ignored. Also panics if a NUL byte is attempted to be returned.