Placing objects in random rooms

R2T1
I'm currently rewriting an old Commodore C64 game in Quest5 and have hit a snag. ( I find this is the best way to learn a new language as I know what currently happens and can check that I have it right)

At the start of the game, there are 4 objects that are placed in one of 7 random rooms (rooms 4 - 10) but never in the same room as each other. The BASIC code (its actually a Quickbasic port of the C64 code) for this is...
5000     FOR x = 1 TO 4
5010 t = INT(RND(1) * 7) + 3
FOR y = 1 TO x - 1
IF VAL(ob$(y, 1)) = t THEN GOTO 5010
NEXT y
ob$(x, 1) = STR$(t)
NEXT x

I have tried various ways using scripts for each object but haven't had any success as yet. I think I may need to code a function for this and then call it from the game startup script. Can anybody give me any pointers as to whether this is the right approach or should I be doing something different (and probably simple)?
Thanks.

Pertex
Have a look at this file. It's all in the startscript of the game.

R2T1
Many thanks Pertex.
I have successfully added your code to my game script changing the objects & rooms to their real names of course.
Part of my problem was (is) I haven't got to know all the inbuilt functions, scripts, attributes, etc.
I guess there's a bit more reading to do yet but I'll keep at it.
...now on to the next bit.

This topic is now closed. Topics are closed after 60 days of inactivity.

Support

Forums