Rockbox Technical Forums
Rockbox Development => Starting Development and Compiling => Topic started by: HolyRoller on March 20, 2019, 03:18:50 PM
-
Hey guys! I'm thinking what I want to do shouldn't be too difficult. I simply want to program some random table generators for use with tabletop RPGs. For example, when I click on Monster Generator, it will pick a number from 1-100, and then list the name for the corresponding monster to that number. That's pretty much it, just a list of tables, I click on one, and it spits out the name. Where should I start? Is there something similar I can build on top of? Let me know if you need more info, thanks!
-
Lua would be the easiest way to do this in Rockbox
https://www.rockbox.org/wiki/PluginLua
-
Alright so I wrote a simple LUA script to print a random number, and my Clip freaks out when I try to open it. This is the code:
math.randomseed(os.time())
print("Challenge Die: " .. math.random(1,10))
Am I missing formatting?
-
Update: I was able to sort of get it to work, here is my code:
function print(message, seconds)
rb.splash(seconds, message)
end
print(("Challenge Dice: %d"):format(math.random(1,10)), 5)
So it shows me the result of a die roll, but it flashes on the screen for a split second and closes. Is there a way I can keep the result on the screen until I back out?
-
sleep(rb.HZ*Seconds) would be the easiest way
I have quite a bit of sample code in the plugins section that will probably help
http://forums.rockbox.org/index.php/board,27.0.html
Print API list:
http://forums.rockbox.org/index.php/topic,51935.0.html
-
function print(message, seconds)
rb.splash(seconds * rb.HZ, message) -- rb.HZ == 100
end
print(("Challenge Dice: %d"):format(math.random(1,10)), 5)
Ok I have made some progress, this code works. Now I just want to show the result of multiple dice rolls in the same splash screen. How would I go about doing that? Do you recommend a similar plugin I could view?