Simple World Gen

Place to get help with not working mods / modding interface.
User avatar
FreeER
Smart Inserter
Smart Inserter
Posts: 1266
Joined: Mon Feb 18, 2013 4:26 am
Contact:

Simple World Gen

Post 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
<I'm really not active any more so these may not be up to date>
~FreeER=Factorio Modding
- Factorio Wiki
- My Factorio Modding Guide
- Wiki Modding Guide
Feel free to pm me :)
Or drop into #factorio on irc.esper.net

kovarex
Factorio Staff
Factorio Staff
Posts: 8194
Joined: Wed Feb 06, 2013 12:00 am
Contact:

Re: Simple World Gen

Post 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?)

ficolas
Smart Inserter
Smart Inserter
Posts: 1068
Joined: Sun Feb 24, 2013 10:24 am
Contact:

Re: Simple World Gen

Post by ficolas »

I used topleft.x + math.random(32) and topleft.y + math.random(32) instead, because that didnt work for me

User avatar
FreeER
Smart Inserter
Smart Inserter
Posts: 1266
Joined: Mon Feb 18, 2013 4:26 am
Contact:

Re: Simple World Gen

Post 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
<I'm really not active any more so these may not be up to date>
~FreeER=Factorio Modding
- Factorio Wiki
- My Factorio Modding Guide
- Wiki Modding Guide
Feel free to pm me :)
Or drop into #factorio on irc.esper.net

Post Reply

Return to “Modding help”