Page 1 of 1

Simple World Gen

Posted: Wed May 08, 2013 3:28 am
by FreeER
I'm trying to use the onchunkgenerated event and having slight issues lol.
Also I find it a bit strange that instead of topleft and bottomright it uses lefttop and rightbottom lol. Anyways, I am/was trying to use

Code: Select all

game.createentity{name="creeper-spawner-2", position={math.random(event.area.lefttop.x,event.area.rightbottom.x),math.random(event.area.lefttop.y,event.area.rightbottom.y)}}
so that it places a spawner randomly within the loaded chunk...and keep getting a "bad argument #2 to 'random' (interval is empty)" error.

This

Code: Select all

game.player.print(event.area.lefttop.x.." "..event.area.lefttop.y.." "..event.area.rightbottom.x.." "..event.area.rightbottom.y)
shows what I would expect to see, so i'm not sure what's going on lol
typing it into the console using the numbers printed from the print statement like so

Code: Select all

game.createentity{name="creeper-spawner-2", position={math.random(704,736),math.random(96,128)}}
works perfectly

Re: Simple World Gen

Posted: Wed May 08, 2013 11:31 am
by kovarex
This is really strange, are you 100 sure you wrote it in the same way as in the example? (that you didn't use rightbottom or lefttop twice?)

Re: Simple World Gen

Posted: Wed May 08, 2013 1:26 pm
by ficolas
I used topleft.x + math.random(32) and topleft.y + math.random(32) instead, because that didnt work for me

Re: Simple World Gen

Posted: Wed May 08, 2013 5:30 pm
by FreeER
kovarex wrote:This is really strange, are you 100 sure you wrote it in the same way as in the example? (that you didn't use rightbottom or lefttop twice?)
Yep, I copied it but I went ahead and checked again for you. Exactly as I have in the control.lua. I thought it was strange as well so I posted here.
ficolas wrote:I used topleft.x + math.random(32) and topleft.y + math.random(32) instead, because that didnt work for me
OK, I'll use something similar until things are working as expected :D