Hi to any who may View this post. My question: is RnG Dice even possible? Could it become a Chat CMD /roll or maybe a hand held item you can activate, eat, throw. bring up a speech bubble, or the use of wiring logic gates to act as random 1 to 6. After of long look at the forums i could not find any thread on this topic or a mod that includes such a feature. i'm by no means a modder wouldn't know where to begin, just help me play snakes n ladders with composite Rail. Thanks
Should actually be kinda easy. I'd have to go back and look, but I remember seeing a lua somewhere in there for simple random number generation. I believe in one of the files in the root of unpacked asset files. I'll double check. Correction: Looks like scripts directory and it's in the util scripts. A few util.random functions there. Even weighted options. I should definitely scan this file more....
You can do a random number generator with lua math.random(min,max) http://lua-users.org/wiki/MathLibraryTutorial
Thank you Midramble & The | Suit for your Replys, Now iv'e gotta find A wonderful Modder to take this on
You know the best way to handle dice would be a thrown projectile. math.random(min, max) is all you need for dice. You wouldn't need weight options unless you're making cheater's dice math.random(1, 6) for six sided dice, etc Then you just have different image frames for the dice to choose from. You COULD go the extra mile and add a radio message(like what SAIL does and others in missions) to add the dice results to the messaging window if you found that desirable. And you know, I sort of like the idea of someone adding gambling machines to SB so long as they're realistic. Statistically the house comes out on top. edit: yeah you could even simulate the physics of the dice roll to respond to bouncing off walls, rolling, etc in the determination of what number comes up top - but there isn't a lot of point to doing so, and implementation gets more complicated pretty fast.
Thank you for the input bk3k. For the sake of the modder who is willing to make this a reality for my i would suggest the simplistic form where you need no pixel art/animation/physics, just a message with a random number would do.
If pixelart is required, I'm quite willing to provide some. Given starbound's feel, I'd imagine the dice would display the number via hologram, which would basically just be recoloring the preexisting number signs and pasting them into the same image as a die.
Here's a command mod I quickly threw together with nothing fancy added to it. Feel free to reuse code or add to it. http://www.mediafire.com/file/phj2fuc5o6qzdv5/ServerDice.zip The mod only has to be installed on the server, though may require asset mismatching to be allowed for other players to join. It will work fine in singleplayer as well. Usage /roll [amount] [faces] [broadcast] Amount: Value between 1 and 100, determining how many dice to roll. Faces: Value between 1 and 1000, determining the amount of faces per die. Broadcast: If any value is entered, the results will be broadcast to everyone. Examples /roll Rolls 1 die with 6 faces. /roll 5 Rolls 5 dice with 6 faces each. /roll 5 20 Rolls 5 dice with 20 faces each. /roll 5 20 t Rolls 5 dice with 20 faces each, and broadcasts the results to everyone online.