That will create one message.
In order to create further messages, some sort of custom message handler and a
dsb_msg with a random delay will be the kind of thing you want. However, there are multiple ways to do it so it's difficult for me to suggest one absolutely "correct" approach. In
base/msg_handlers.lua there are numerous examples of writing message handlers, so that might be a useful file to look into.
Here is simple code for a message loop. Note that it is missing important features like any way to deactivate it or, if it's to be used as an item, detect if the item is equipped/worn/whatever, but it should provide a good basis for your experimentation.
Code: Select all
function message_loop(id, data)
dsb_write(system_color, "MESSAGE RECEIVED.")
dsb_msg(dsb_rand(5, 60), id, M_NEXTTICK, 0)
end
simple_looping_msg_handler = {
[M_NEXTTICK] = message_loop
}
Now, all you have to do is set the
msg_handler of whatever archetype you want to use as your looping message generator to
simple_looping_msg_handler in your custom dungeon's
objects.lua, and send an instance of that archetype a "Next Tick" (i.e.,
M_NEXTTICK) message. This will start the whole loop going.
If this seems a little complex, well, that's because it kind of is, if you're just getting into DSB editing. However, it will make sense as you learn more about how messages work.
