Page 1 of 1

[Solved] Need help pls - Creatin ore on position

Posted: Mon Apr 26, 2021 11:31 pm
by Factorian85
Hello,

i need help please.

I created a mod that adds an ore field (rectangle) by placing an item. That works fine. Problem is that the item is in the center of the field.

I want that the the item is on the upper left side.

Most code is from Console Wiki

Code: Select all

local function on_stone ( entity )
   local ore=nil
   local size=28
   local size1=45
   local density=10000
   for y=-size, size do
	   for x=-size1, size1 do
		aaa=0
		a=(size1+1-math.abs(x))*10
		b=(size+1-math.abs(y))*10
		if a<b then
			ore=math.random(a*density-a*(density-8), a*density+a*(density-8))
		end
		if b<a then
			ore=math.random(b*density-b*(density-8), b*density+b*(density-8))
		end
   stoneore = entity.surface.create_entity{name="stone",amount=ore, position={entity.position.x+x, entity.position.y+y}, force=entity.force}
    
   end
   end
   end
THANKS

Re: Need help pls - Creatin ore on position

Posted: Tue Apr 27, 2021 6:34 am
by ickputzdirwech
I think changing “-size, size” to “-size, 0” should do the trick. Same for “-sizel, 0”.

Re: Need help pls - Creatin ore on position

Posted: Tue Apr 27, 2021 11:50 am
by Factorian85
ickputzdirwech wrote: Tue Apr 27, 2021 6:34 am I think changing “-size, size” to “-size, 0” should do the trick. Same for “-sizel, 0”.
Thanks!!!

It's on the lower right, but thats no problem.

Re: [Solved] Need help pls - Creatin ore on position

Posted: Tue Apr 27, 2021 11:58 am
by ickputzdirwech
Sorry, didn’t read your post properly. Remove the minuses and it should be line you wanted it.

Glad I could help.