[Solved] Need help pls - Creatin ore on position

Place to get help with not working mods / modding interface.
Post Reply
Factorian85
Burner Inserter
Burner Inserter
Posts: 8
Joined: Wed Aug 15, 2018 10:01 pm
Contact:

[Solved] Need help pls - Creatin ore on position

Post 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
Last edited by Factorian85 on Tue Apr 27, 2021 11:52 am, edited 1 time in total.

User avatar
ickputzdirwech
Filter Inserter
Filter Inserter
Posts: 768
Joined: Sun May 07, 2017 10:16 am
Contact:

Re: Need help pls - Creatin ore on position

Post by ickputzdirwech »

I think changing “-size, size” to “-size, 0” should do the trick. Same for “-sizel, 0”.
Mods: Shortcuts for 1.1, ick's Sea Block, ick's vanilla tweaks
Tools: Atom language pack
Text quickly seems cold and unfriendly. Be careful how you write and interpret what others have written.
- A reminder for me and all who read what I write

Factorian85
Burner Inserter
Burner Inserter
Posts: 8
Joined: Wed Aug 15, 2018 10:01 pm
Contact:

Re: Need help pls - Creatin ore on position

Post 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.

User avatar
ickputzdirwech
Filter Inserter
Filter Inserter
Posts: 768
Joined: Sun May 07, 2017 10:16 am
Contact:

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

Post by ickputzdirwech »

Sorry, didn’t read your post properly. Remove the minuses and it should be line you wanted it.

Glad I could help.
Mods: Shortcuts for 1.1, ick's Sea Block, ick's vanilla tweaks
Tools: Atom language pack
Text quickly seems cold and unfriendly. Be careful how you write and interpret what others have written.
- A reminder for me and all who read what I write

Post Reply

Return to “Modding help”