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.

DarkBASIC Professional Discussion / Random Card Picker [noob]

Author
Message
mad computer user
17
Years of Service
User Offline
Joined: 9th Nov 2008
Location: New Zealand
Posted: 24th Jul 2011 14:04 Edited at: 26th Jul 2011 11:48
Hey, im just a bit of a noob when it comes to DBP so this is probably really simple

Im trying to make a card picker to test a card game im developing, basically you get a certain number of resources which you type in, and the it displays that number of cards, but each card is a random pick of three.

This means that if you have ten cards, it could have 3 fuel, 3 ore and 4 lasers or whatever, but for each card its a randomly generated one.

This is my code and i have it working without the For and Next and the stuff in between but with them its not working.



Any help appreciated
Max P
16
Years of Service
User Offline
Joined: 23rd Jan 2010
Location:
Posted: 24th Jul 2011 14:18
Your code works fine if you change
to

and

to


However I suggest to use one of the methods below, they look a bit cleaner

Hodgey
16
Years of Service
User Offline
Joined: 10th Oct 2009
Location: Australia
Posted: 24th Jul 2011 14:19 Edited at: 24th Jul 2011 14:21
Max P beat me to it.

mad computer user
17
Years of Service
User Offline
Joined: 9th Nov 2008
Location: New Zealand
Posted: 24th Jul 2011 14:24
now i get a "Command out of place at line 25" error

on
mad computer user
17
Years of Service
User Offline
Joined: 9th Nov 2008
Location: New Zealand
Posted: 24th Jul 2011 14:27
though thats using method 1 your new method works beautifully so thanks
Hodgey
16
Years of Service
User Offline
Joined: 10th Oct 2009
Location: Australia
Posted: 24th Jul 2011 14:28 Edited at: 24th Jul 2011 14:28
Quote: "now i get a "Command out of place at line 25" error"

I got that with your original code. Change the if statements either to individual if statements and not else ifs or use the select statement like Max P.

Edit
It appears everyone posts 2 seconds before I do.

mad computer user
17
Years of Service
User Offline
Joined: 9th Nov 2008
Location: New Zealand
Posted: 24th Jul 2011 14:38
any ideas if it could instead of listing all the cards, it would say:

you have
3 x fuel
4 x ore
2 x laser

or is that not possible with this kind of code?
Max P
16
Years of Service
User Offline
Joined: 23rd Jan 2010
Location:
Posted: 24th Jul 2011 16:41 Edited at: 24th Jul 2011 16:42
You can replace


With something like:


edit
Or even better:
mad computer user
17
Years of Service
User Offline
Joined: 9th Nov 2008
Location: New Zealand
Posted: 24th Jul 2011 16:44
i cant find what your saying to replace

this is my current code


and

isnt in it
Max P
16
Years of Service
User Offline
Joined: 23rd Jan 2010
Location:
Posted: 24th Jul 2011 16:45 Edited at: 24th Jul 2011 16:48
Ow, your using method 2

You can create a user defined type for that, I'll give an example in a few min

edit

Use this :
mad computer user
17
Years of Service
User Offline
Joined: 9th Nov 2008
Location: New Zealand
Posted: 24th Jul 2011 16:47
thanks so much, i was really stumped but this is teaching me allot
mad computer user
17
Years of Service
User Offline
Joined: 9th Nov 2008
Location: New Zealand
Posted: 24th Jul 2011 17:10
works perfectly, and i learnt a bit so THANK YOU SO MUCH
mad computer user
17
Years of Service
User Offline
Joined: 9th Nov 2008
Location: New Zealand
Posted: 26th Jul 2011 11:48 Edited at: 26th Jul 2011 11:52
hey one more problem, we need certain cards more common then others, infact we need there to be 4 ore and 2 fuel for each laser. I thought by increasing the resources in the array like so:


itd do it, and it kind does but it prints it like so:


how would i make it so that it prints it all on just 3 lines but includes the more common code?

heres the full code with the modded array:


and heres how it was when unmodded:


any help appreciated
Max P
16
Years of Service
User Offline
Joined: 23rd Jan 2010
Location:
Posted: 26th Jul 2011 13:09
I added a new var in the type called percent
For now, giving this var a value isn't quite straitforward, I'll try making it easier
mad computer user
17
Years of Service
User Offline
Joined: 9th Nov 2008
Location: New Zealand
Posted: 26th Jul 2011 13:19
that is absolute genius, i never would have guessed to do something like that.
mad computer user
17
Years of Service
User Offline
Joined: 9th Nov 2008
Location: New Zealand
Posted: 26th Jul 2011 13:23
worked out i think how the percentages work, now its this:


pretty sure thats right
Max P
16
Years of Service
User Offline
Joined: 23rd Jan 2010
Location:
Posted: 26th Jul 2011 13:31
Added a sort function so the percentages are easier to work with
Now you can just say: Fuel = 29%, Ore = 57%, laser = 14%
mad computer user
17
Years of Service
User Offline
Joined: 9th Nov 2008
Location: New Zealand
Posted: 26th Jul 2011 14:09
when i test in DBP it says not responding and when i compile it just opens and closes...
Max P
16
Years of Service
User Offline
Joined: 23rd Jan 2010
Location:
Posted: 26th Jul 2011 14:24
weird..
Quote: "when i test in DBP it says not responding "

What exactly do you mean with that? What is not responding?
mad computer user
17
Years of Service
User Offline
Joined: 9th Nov 2008
Location: New Zealand
Posted: 26th Jul 2011 14:52
im running windows 7 and when it opens it pops up with te standard windows "not responding" box, basically means a program has stopped working.
Max P
16
Years of Service
User Offline
Joined: 23rd Jan 2010
Location:
Posted: 26th Jul 2011 15:52
Everything is working fine here (windows xp), so I think it is a windows 7 problem. Do you have the latest version of dbpro?
mad computer user
17
Years of Service
User Offline
Joined: 9th Nov 2008
Location: New Zealand
Posted: 27th Jul 2011 01:00
yup

Login to post a reply

Server time is: 2026-07-11 07:05:47
Your offset time is: 2026-07-11 07:05:47