Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / Random range problem and definitive lists.

Author
Message
Somarl
13
Years of Service
User Offline
Joined: 11th Feb 2011
Location: UK
Posted: 12th Feb 2011 13:40
Hi folks, just started using DB and to learn i am trying to find as many tutorials as i can and steadily go through them, every now and then i am playing around with my own values to see what they do and trying to create a problem for myself to solve to prove to myself that i understand how something works. This is probably the best way to learn but i am finding some definitive lists for commands and whatnot missing. For example when looking on the net or through DB command help list i couldnt find anythnig that helped me solve (or prove that it is or is not possible) a little problem i had with randomising.

Here goes: the rnd command will randomise a number between 1 and 'whatever number you put in the range'. so rnd(20) is simple enough, it will randomise a number between 1 and 20. By this i figured out that if you wanted to get it to randomise between 0 and 20 you would do rnd(20)-1. Perfect, i love it. But what if i wanted to randomise a number between 10 and 20. I dont think you can put a range into the rnd statement like rnd(10-20) because that just returns a 0 value.

As well as that problem (my mind just goes blank sometimes and i am not the best problem solver even if something is blatantly obvious i am very good at overlooking things but i try) i was also looking for definitive lists for things for example mouse codes. I found a couple of snippets on the net that tell you what mouse code means youve clicked what buttons and i figured out one on my own as well furthering the list that i found (it was button 4 that was missing) but cant seem to find button 5. Where is the list that says 'here is the list of everything you can do with a mouse, every button every command etc'. Has one been done and im just too daft to find it.

Sorry for the long first post and trying to cram 2 probs into 1 thread. Its just finding a good tutorial and experimenting is provnig to be more difficult (mainly cause of my lack of intelligence but also lack of resources).
Kezzla
16
Years of Service
User Offline
Joined: 21st Aug 2008
Location: Where beer does flow and men chunder
Posted: 12th Feb 2011 14:56
hi somarl, welcome to the DB community
the rnd() command randomizes a value between 0 and the value defined.
to randomize between 10 and 20 I would use the following...
variable = rnd(10) + 10

so far as the mouse commands go do you have a standard mouse setup?

If you look up the mouseclick() command in the help file under help you will find some answers on how to utilize the mouse buttons, as for mouses with extended buttons, eg 6 button mouse with scroll wheel, I do not know about special mice, but basic mouse config should be answered by looking up mouseclick() and if that doesnt help, there are many more advanced programmers in this forum who can help you.

hope this was some help
kezzla

Sometimes I like to use words out of contents
Somarl
13
Years of Service
User Offline
Joined: 11th Feb 2011
Location: UK
Posted: 12th Feb 2011 15:07
Many thanks for the welcome Kezzla.

Your post clears up the range problem with rnd. I get it, thats great. Its so damn obvious but sometimes my mind just wont figure it out. I feel a bit daft now.

As for my mouse, its a 5 button effort with a wheel.
Thats 2 standard buttons left and right click, scroll wheel, scroll wheel click and 2 side buttons (but one on each side, i love mice like that but no one seems to make them anymore)

I managed to find the code for the forth button (i.e my left side button) and a combination of the other buttons when pressed together with it just by experimenting after i found an imcomplete or not up to date list, but could not find anything to make the right side button work, i wonder if it is supported.

Sorry i just read what i put above and it doesnt make much sense even to me, i hope someone can understand this.
CodemanV
19
Years of Service
User Offline
Joined: 25th Aug 2005
Location: South Wales Valleys, UK
Posted: 12th Feb 2011 15:18 Edited at: 12th Feb 2011 15:32
Hello

A common function for getting a random value between two ranged values is



e.g.
10 is lowest value
20 is highest value

20-10 = 10
Rnd(10) = 0 to 10
min + 0 to 10 = 10 to 20

Also worth noting that when using the Rnd() function, the "Randomize" function needs to be called before using it, once is enough.

Otherwise, the program will use the same seed to generate numbers and output the same results every time.

Here's a quick demo of Rnd() and Randomize



All the best
Grog Grueslayer
Valued Member
19
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 12th Feb 2011 18:54
The MOUSECLICK() output depends on how many buttons you have on your mouse. I just use a standard two button mouse with a mouse wheel so I only wrote code for that. But the general rule is each button has a number assigned to it and if you want two or more buttons to be pressed at the same time you add each button number.



Somarl
13
Years of Service
User Offline
Joined: 11th Feb 2011
Location: UK
Posted: 13th Feb 2011 01:56
Grog - I found a mouseclick reference somewhere that went through the 2 main buttons and the scroll wheel click, plus obviously the combinations of those buttons.
I managed to work out from that list what my right side button (side button 1) would be but no matter what number i tried i cannot seem to make it see the second side button.

Because of this i was wondering if DB pro supports that 5th mousebutton at all. Not a great deal as i may never even use it but it was just one of the things as a noob i experimented with to get a feel for the program and was pleased with myself for finding the forth button but frustrated at not finding the fifth so wondered if there was a definitive list (like your awesome keystate helper chart http://forum.thegamecreators.com/?m=forum_view&t=176826&b=1 ) that would help me with not only mouseclicks but many other things as the list i have seems to be incomplete (at least for want of a button 4)
Grog Grueslayer
Valued Member
19
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 13th Feb 2011 17:24
Quote: "Because of this i was wondering if DB pro supports that 5th mousebutton at all."


Well, if you run the code snip I posted and you hold down the 5th mouse button and MOUSECLICK() returns a zero then sadly it's not supported... if it shows a higher number though that's the one you use for the button. But fret not if it doesn't work right now. We could always ask TGC to add support for more advanced mice.

Quote: "like your awesome keystate helper chart"


Thanks

Somarl
13
Years of Service
User Offline
Joined: 11th Feb 2011
Location: UK
Posted: 13th Feb 2011 17:29
Yes it did return 0 so button 5 is not yet supported so it seems. Oh well, im not fussed i just wanted to know for the sake of insight really.

Thanks everyone for your help. Us noobs cant progress without it

Login to post a reply

Server time is: 2024-11-23 02:48:28
Your offset time is: 2024-11-23 02:48:28