how do i use the random actuator?

the title is what i need, what i want to do is something like this, for my game im working on, i got this rock that i want to mine and if you click on it for so how many clicks, you will get the rock. i basicly want a random act something like, you will get the rock out of a 1:10 chance. any help would be nice. thanks.

forgot to mention this, i just dont want to be able to click on it. i want the character like right next to it, and with a pick axe., like if you click on the rock with out the pick axe in your hands, or invintory i dont want it to mine it. and i want it to add the rock once you mine it, like add it to your invintory.

Use a py function getRandomFloat(). It’s better than the random actuator.


rdm = int(GameLogic.getRandomFloat() * 10) + 1

if rdm == 1:
   #get rock

The 10 determines the range, and the 1 determines the starting number from which the range begins. So, in the above example, at every script pass any one number from 1 to 10 could be generated. Setting your “get rock” action to happen when one specific number out of those 10 is generated will give you a 1 in 10 chance of the action happening.

Oh dear, you’re not trying to recreate Runescape are you ;)? Judging by your last 2 posts, you’d of had me fooled. The cleanest way would be through Python using a random function. I’m also assuming you already have your inventory script done? That would be the first step before you can have something be added to it. The rest would be simple conditions in the python script ex MainhandItem = Pickaxe.
Edit Social beat me to it

ok sorry for the long wait, i was working on the inventory lol. well ok,i got it all working except i dont know how to make it where when i get stuff from the game lets say for exsample, when i mine the rock and get it. where would it go? what i kinda did was that i stuck 15 emptys in the inventory part. ok now how can i make it where when i mine the rock, it can start to fill up the inventory? becasuse i think this will need py scripts for this part. any help is apriceated. thanks.

one more question socail, where it says #get rock at the bottem of the script, would that be like adding the object? and one more lol, where do i put this at? on the rock or the human or both? sorry im downright pretty new to py scripts.

I think there are some links for inventories if you do a search. Your getting into territory where you can’t ask people to program things like that for you, though. If you want to do games of that complexity, it’s really getting time to learn python. What I’d do is send a message to an overlay to move an item from off screen to on screen.

#get rock

all lines that starts with a # is a comment and won’t do anything.

nitrofreak06>

As Sim88 already pointed out, “#get rock” is a comment (simply saying that the code which adds the rock to the inventory would go there). I assumed since you were already making a game with an inventory and all, you would know a good deal of py scripting already (starting a full game without any significant experience is not a good idea, I suggest sticking to making a few demos for the time being, until you get a better grasp on things)

Fireside is right, you need to learn python. I wrote a python tutorial not too long ago, maybe it can help you start out: http://blenderartists.org/forum/showthread.php?t=80826

Use a py function getRandomFloat(). It’s better than the random actuator.

OMG! cool, thanks Social
I learn lots from snippletts :slight_smile: the logic brick method i have beenuseing dose not seem to be verry random, I see a definate pattern.

Unfortunately, in computing there is no such thing as a truely random generator. What I like to do is take from the only thing in the game that is random: the user.
If you set a property to cycle very quickly through a set of numbers based on a trigger that is unknown to the user and have it stop based on a trigger that is unknown to a user, if you do it right you can control the probability without sacrificing randomness. Since the user would have to stop the cycling timer twice at the exact same millisecond unknowingly to get the same result, you get an extremely random outcome within a chosen range. This can be done without python scripting if you want, but the python script is probably easiest. I wrote this more as food for thought.