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 / Trees and plants instance problem

Author
Message
tokyomage
14
Years of Service
User Offline
Joined: 26th Sep 2010
Location: on your roof
Posted: 31st Aug 2011 02:00
My problem: my problem is that whenever I make the code an instance it gives me the problem :runtime error cannot duplicate object. Other than that heres the code:::


Quote: "Rem Project: forest
Rem Created: Sunday, August 28, 2011

Rem ***** Main Source File *****
global camheight as integer
camheight = 15

sync on
sync rate 60
backdrop on
autocam off
set camera range 1, 20000




load object "tree1.dbo",1
set object transparency 1, 6
set alpha mapping on 1, 99
position object 1, rnd(100),0, rnd(100)

load object "tree2.dbo",2
set object transparency 2, 6
set alpha mapping on 2, 99
position object 2, rnd(100),0, rnd(100)

load object "tree3.dbo",3
set object transparency 3, 6
set alpha mapping on 3, 99
position object 3, rnd(100),0, rnd(100)

load object "tree4.dbo",4
set object transparency 4, 6
set alpha mapping on 4, 99
position object 4, rnd(100),0, rnd(100)

load object "tree5.dbo",5
set object transparency 5, 6
set alpha mapping on 5, 99
position object 5, rnd(100),0, rnd(100)

load object "plant1.dbo",1007
set object transparency 1007, 6
set alpha mapping on 1007, 99
position object 1007, rnd(100),0, rnd(100)
scale object 1007,13,19,16

load object "plant2.dbo",1008
set object transparency 1008, 6
set alpha mapping on 1008, 99
position object 1008, rnd(100),0, rnd(100)
scale object 1008,13,19,16

load object "plant3.dbo",1009
set object transparency 1009, 6
set alpha mapping on 1009, 99
position object 1009, rnd(100),0, rnd(100)
scale object 1009,13,19,16

load object "plant4.dbo",1010
set object transparency 1010, 6
set alpha mapping on 1010, 99
position object 1010, rnd(100),0, rnd(100)
scale object 1010,13,19,16

load image "groundskin.jpg",1

make matrix 1, 2000, 2000, 25, 25
position matrix 1, -1000, 0, -1000
randomize matrix 1, rnd(10)
set matrix wireframe off 1
prepare matrix texture 1 ,1, 1, 1
update matrix 1

position camera 0,camheight, -250
set camera range 1,20000


for x = 5 to 1005
Instance object x, rnd(4)+1
position object x, rnd(2000)-1000, 0, rnd(2000)-1000
scale object x, 80+rnd(40), 80+rnd(40), 80+rnd(40)
turn object right x, rnd(359)
NEXT x

for z = 1007 to 2007
Instance object z, rnd(1006)+1
position object z, rnd(2000)-1000, 0, rnd(2000)-1000
scale object z, 18+rnd(9), 18+rnd(9), 18+rnd(9)
turn object right z, rnd(359)
NEXT z

load image "test.png",2

texture object 6,2

load image "plant2.png",3

texture object 7,3

load image "plant3.png",4

texture object 8,4

load image "plant4.png",5

texture object 9,5

do

control camera using arrowkeys 0, 2, 0.5



if keystate(17) = 1 rem w
inc camheight
position camera camera position x(0), camheight, camera position z(0)

ENDIF

if keystate (31) = 1
dec camheight
position camera camera position x(0), camheight , camera position z(0)

ENDIF

sync
LOOP"





Thanks, Tokyomage

.....the feel of solitude hurts inside....
tokyomage
14
Years of Service
User Offline
Joined: 26th Sep 2010
Location: on your roof
Posted: 31st Aug 2011 02:01
(the problem is under the for x= and for z= part of the code)

.....the feel of solitude hurts inside....
revenant chaos
Valued Member
17
Years of Service
User Offline
Joined: 21st Mar 2007
Location: Robbinsdale, MN
Posted: 31st Aug 2011 16:28 Edited at: 31st Aug 2011 16:30
well objects 1007-1010 already exist (you loaded them) when you try create them. another thing is that rnd(1006)+1 will equal a number between 1 and 1007. I think what you were looking for was:

for z = 1011 to 2011
Instance object z, 1007+rnd(3)
...
...
next z

Note: Please use the "code" tags for snippets (rather than the "quote" tags)
tokyomage
14
Years of Service
User Offline
Joined: 26th Sep 2010
Location: on your roof
Posted: 31st Aug 2011 23:47
odd, no diffrence, heres th enew code (now with code tags insted of quote)


.....the feel of solitude hurts inside....
revenant chaos
Valued Member
17
Years of Service
User Offline
Joined: 21st Mar 2007
Location: Robbinsdale, MN
Posted: 1st Sep 2011 03:55
Ok, now change
To
. Same problem as before, you already have an object number 5 ("tree5.dbo"), but then that loop tries to create another object number 5.

Login to post a reply

Server time is: 2024-11-24 01:24:30
Your offset time is: 2024-11-24 01:24:30