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 events

Author
Message
ReD_eYe
21
Years of Service
User Offline
Joined: 9th Mar 2003
Location: United Kingdom
Posted: 15th Mar 2003 18:21
hi, i'm making a text based rpg type thing, i've written some events that can happen to the player eg. a big monster attacks etc
the problem i am having is that in my main loop i'd like to use a gosub command to randomly pick an event to happen
for instance

do
gosub rnd(10) 'or however many events i have
cls
loop

i would probably also use the randomize command to reseed the random number.
i have named my events as numbers so i thought this would work but it hasn't, i get an error saying it isn't a valid label name.
any suggestions?????
'You were born crying while people around you smiled'
ReD_eYe
21
Years of Service
User Offline
Joined: 9th Mar 2003
Location: United Kingdom
Posted: 15th Mar 2003 18:26
i'm working in db classic version 1.12 by the way
thanks

'You were born crying while people around you smiled'
Kentaree
22
Years of Service
User Offline
Joined: 5th Oct 2002
Location: Clonmel, Ireland
Posted: 15th Mar 2003 18:57
Your problem is that rnd is a darkbasic keyword. Just change the name of the subroutine to something like random and it should work.

Whatever I did I didn't do it!
Kentaree
22
Years of Service
User Offline
Joined: 5th Oct 2002
Location: Clonmel, Ireland
Posted: 15th Mar 2003 19:03
Uhm sorry, I just re-read the question. I get what your problem is now. What would work is to get a random number, then use if's or case statements on a random number. i.e

randomize timer()
sub=rnd(10)
if sub=1 then gosub Sub1
if sub=2 then gosub Sub2
*etc*

Whatever I did I didn't do it!
ReD_eYe
21
Years of Service
User Offline
Joined: 9th Mar 2003
Location: United Kingdom
Posted: 15th Mar 2003 19:25
thanks i'll try it

'You were born crying while people around you smiled'
ReD_eYe
21
Years of Service
User Offline
Joined: 9th Mar 2003
Location: United Kingdom
Posted: 15th Mar 2003 19:30
woohoo it does work thank you so much.

'You were born crying while people around you smiled'

Login to post a reply

Server time is: 2024-11-24 06:11:17
Your offset time is: 2024-11-24 06:11:17