Random number in range

I’m trying to generate a random number in a range like say from 16 to 350 in Lua, I’ve tried:

inv_x = random.randint(16, 350)
inv_x=flr(rnd(350)) + 16

Neither of these are working each one is from a different Lua program that I have used successfully but not working in the Playdate SDK.

Add this to the entry point of your app

Thanks! I’ll try that ASAP!


That alone won’t do it. Neither of your original examples are native Lua or present in the SDK. You want to use Lua’s native math.random().

Thanks! That seemed to work!