Closed Column01 closed 2 years ago
Wow, that was incredibly easy to implement. Events already had a way to serialize it so it was just a matter of ensuring all values are strings and then using a custom safe dict to ensure missing keys are just returned as {key}
instead of raising a ValueError
Added in https://github.com/gsand/mark2/commit/2a5a7ee4da775b474e7e8c80314a4b7da47b1a58
Right now, scripts can be run using mark2 events. I'd like to support formatting properties from certain events into the commands that get executed.
For example:
msg {username} I saw you sent a chat message!
{username}
to be whatever thePlayerChat
event had for the username.As far as I know, it should just be adding something to the args for the
execute
function that passes the event to it? Then we can just format thecmd
with python to fill in placeholders. https://github.com/gsand/mark2/blob/8419151405cb16427371f256f3662a9370a55e0e/mk2/plugins/script.py#L29Would probably become
self.plugin.register(lambda e: self.execute(command, e), event)
because AFAIK,e
in this instance is the event. Then we'd just need code to format the event properties into the command string