Rockbox.org home
Downloads
Release release
Dev builds dev builds
Extras extras
themes themes
Documentation
Manual manual
Wiki wiki
Device Status device status
Support
Forums forums
Mailing lists mailing lists
IRC IRC
Development
Bugs bugs
Patches patches
Dev Guide dev guide
Search




Rockbox Technical Forums


Login with username, password and session length
Home Help Search Staff List Login Register
News:

Thank You for your continued support and contributions!

+  Rockbox Technical Forums
|-+  Rockbox Development
| |-+  Starting Development and Compiling
| | |-+  Want to create a random generator for RPGs, how should I start?
« previous next »
  • Print
Pages: [1]

Author Topic: Want to create a random generator for RPGs, how should I start?  (Read 631 times)

Offline HolyRoller

  • Member
  • *
  • Posts: 10
Want to create a random generator for RPGs, how should I start?
« on: March 20, 2019, 02: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!
Logged

Offline Bilgus

  • Developer
  • Member
  • *
  • Posts: 460
Re: Want to create a random generator for RPGs, how should I start?
« Reply #1 on: March 20, 2019, 05:16:14 PM »
Lua would be the easiest way to do this in Rockbox

https://www.rockbox.org/wiki/PluginLua
Logged

Offline HolyRoller

  • Member
  • *
  • Posts: 10
Re: Want to create a random generator for RPGs, how should I start?
« Reply #2 on: March 22, 2019, 10:24:36 PM »
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?
Logged

Offline HolyRoller

  • Member
  • *
  • Posts: 10
Re: Want to create a random generator for RPGs, how should I start?
« Reply #3 on: March 22, 2019, 11:36:06 PM »
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?
Logged

Offline Bilgus

  • Developer
  • Member
  • *
  • Posts: 460
Re: Want to create a random generator for RPGs, how should I start?
« Reply #4 on: March 23, 2019, 09:33:29 AM »
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
Logged

Offline HolyRoller

  • Member
  • *
  • Posts: 10
Re: Want to create a random generator for RPGs, how should I start?
« Reply #5 on: March 23, 2019, 12:33:55 PM »
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?
Logged

  • Print
Pages: [1]
« previous next »
+  Rockbox Technical Forums
|-+  Rockbox Development
| |-+  Starting Development and Compiling
| | |-+  Want to create a random generator for RPGs, how should I start?
 

  • SMF 2.0.6 | SMF © 2013, Simple Machines
  • XHTML
  • RSS
  • WAP2

Page created in 0.06 seconds with 44 queries.