Autoplace entities and map

Place to get help with not working mods / modding interface.
User avatar
Dysoch
Filter Inserter
Filter Inserter
Posts: 445
Joined: Fri Oct 18, 2013 2:27 pm
Contact:

Autoplace entities and map

Post by Dysoch »

I noticed the problem with f-mod (small scale) and now with my own mod.

I added a rubber tree. Placed ingame by the autoplace group forest. But they show up as red dots on the minimap. Its quite annoying because the autoplace adds alot of them. So the map is quite filled with red dots, and thus not showing correctly if they ar enemys.
screen:
Image

How to change this?
Creator of:
- DyTech
- DyWorld
- DyWorld-Dynamics
- DyWorld-Dynamics 2
Active since Factorio 0.6
User avatar
ssilk
Global Moderator
Global Moderator
Posts: 12889
Joined: Tue Apr 16, 2013 10:35 pm
Contact:

Re: Autoplace entities and map

Post by ssilk »

Naive answer: the trees are shown as enemy, because they are enemies?
Cool suggestion: Eatable MOUSE-pointers.
Have you used the Advanced Search today?
Need help, question? FAQ - Wiki - Forum help
I still like small signatures...
User avatar
Dysoch
Filter Inserter
Filter Inserter
Posts: 445
Joined: Fri Oct 18, 2013 2:27 pm
Contact:

Re: Autoplace entities and map

Post by Dysoch »

Code: Select all

data:extend(
{
  {
    type = "container",
	inventory_size = 1,
    name = "rubber-tree",
    icon = "__base__/graphics/icons/dry-tree.png",
    flags = {"placeable-neutral", "placeable-off-grid", "breaths-air"},
	emissions_per_tick = -0.0010,
    minable = {
      mining_particle = "wooden-particle",
      mining_time = 1,
      result = "raw-wood",
      count = 1,
    },
    max_health = 10,
    collision_box = {{-0.7, -0.8}, {0.7, 0.8}},
    selection_box = {{-0.8, -2.2}, {0.8, 0.8}},
	drawing_box = {{-0.8, -2.8}, {0.8, 0.8}},
    picture ={
        filename = "__DyTech__/graphics/entity/rubber-tree/big-tree-01.png",
        priority = "extra-high",
        width = 155,
        height = 118,
        shift = {1.1, -1}
    },
	autoplace =
    {
      sharpness = 0.5,
      control = "forest",
      peaks =
      {
        {
          influence = 0.2,
          water_optimal = 0.3,
          water_range = 0.2,
          water_max_range = 0.4
        },
        {
          influence = 0.9,
          noise_layer = "trees",
          noise_persistence = 0.5,
        }
      }
    }
  },
}
)
this it the entity code. i cant change it to tree, because then it wont load.
and its flagged as neutral
Creator of:
- DyTech
- DyWorld
- DyWorld-Dynamics
- DyWorld-Dynamics 2
Active since Factorio 0.6
User avatar
rk84
Filter Inserter
Filter Inserter
Posts: 556
Joined: Wed Feb 13, 2013 9:15 am
Contact:

Re: Autoplace entities and map

Post by rk84 »

I believe "placeable-neutral" -flag is used just for map editor. So it is listed in neutral entity list.
Dysoch wrote:I cant change it to tree, because then it wont load.
:?
Test mode
Searching Flashlight
[WIP]Fluid handling expansion
[WIP]PvP gamescript
[WIP]Rocket Express
Autofill: The torch has been pass to Nexela
User avatar
FreeER
Smart Inserter
Smart Inserter
Posts: 1266
Joined: Mon Feb 18, 2013 4:26 am
Contact:

Re: Autoplace entities and map

Post by FreeER »

rk84 wrote:I believe "placeable-neutral" -flag is used just for map editor. So it is listed in neutral entity list.
This is correct
Dysoch wrote:I cant change it to tree, because then it wont load.
Why won't it load? I know trees have a 'pictures' rather than 'picture' field but...

As to the initial question, perhaps try adding map_color = {r=0, g=0, b=0} or making sure that you didn't give it a map_color somehow elsewhere...
<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
drs9999
Filter Inserter
Filter Inserter
Posts: 831
Joined: Wed Mar 06, 2013 11:16 pm
Contact:

Re: Autoplace entities and map

Post by drs9999 »

I am not sure if this still exist, but if you use game.createentity in previous versions and do not specify the force the default is enemy, maybe the same happens here when they are autoplaced. So the red color on the map is correct, because actually this trees are your enemy :D
User avatar
FreeER
Smart Inserter
Smart Inserter
Posts: 1266
Joined: Mon Feb 18, 2013 4:26 am
Contact:

Re: Autoplace entities and map

Post by FreeER »

drs9999 wrote:I am not sure if this still exist, but if you use game.createentity in previous versions and do not specify the force the default is enemy, maybe the same happens here when they are autoplaced. So the red color on the map is correct, because actually this trees are your enemy :D
Yes this still exists. Easy test is to hover over tree and use "game.player.print(game.player.selected.force.name)", though it seems unlikely that autoplace would create entities as enemy (especially for the forest control...).

Would be interesting to have trees that are actually your enemy though (like creating vines to trap you when you get too close or something) lol

edit: just tested and no the force is still neutral, but every tree has turned red...not just the rubber trees lol
edit2: well, the rubber trees are enemy force but every tree has turned red on mine lol (and all regular trees are still neutral)
edit3: SOLVED change the type to tree and the picture node to pictures (surround the picture data inside of another table) and it works as expected, though using the tree-a01 image the selection/collision boxes are off. lol Wonder why containers are assumed to be enemies? And why it made every tree (including neutral) red for me... Devs?

Code: Select all

data:extend(
{
  {
    type = "tree",
    inventory_size = 1,
    name = "rubber-tree",
    icon = "__base__/graphics/icons/dry-tree.png",
    flags = {"placeable-neutral", "placeable-off-grid", "breaths-air"},
    emissions_per_tick = -0.0010,
    minable = {
      mining_particle = "wooden-particle",
      mining_time = 1,
      result = "raw-wood",
      count = 1,
    },
    max_health = 10,
    collision_box = {{-0.7, -0.8}, {0.7, 0.8}},
    selection_box = {{-0.8, -2.2}, {0.8, 0.8}},
    drawing_box = {{-0.8, -2.8}, {0.8, 0.8}},
    pictures = {
        {
          filename = "__base__/graphics/entity/tree/tree-a01.png",
          priority = "extra-high",
          width = 155,
          height = 118,
          shift = {1.1, -1}
        }
    },
    autoplace =
    {
      sharpness = 0.5,
      control = "forest",
      peaks =
      {
        {
          influence = 0.2,
          water_optimal = 0.3,
          water_range = 0.2,
          water_max_range = 0.4
        },
        {
          influence = 0.9,
          noise_layer = "trees",
          noise_persistence = 0.5,
        }
      }
    }
  },
}
)
<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
ficolas
Smart Inserter
Smart Inserter
Posts: 1068
Joined: Sun Feb 24, 2013 10:24 am
Contact:

Re: Autoplace entities and map

Post by ficolas »

Maybe since containers dont naturally spawn as neutral entities, the game uses the red color.
But making all trees red doesnt fit with my theory.

But if you want to insert rubber into the tree, you cant if its entity type is tree, since it doesmt have inventory.
drs9999
Filter Inserter
Filter Inserter
Posts: 831
Joined: Wed Mar 06, 2013 11:16 pm
Contact:

Re: Autoplace entities and map

Post by drs9999 »

ficolas wrote:Maybe since containers dont naturally spawn as neutral entities, the game uses the red color.
I think that too.

Anyway a (not that bad) workaround could be to use the tree-type, but if you harvest them you will get a different kind of wood. This can be processed into rubber.
kovarex
Factorio Staff
Factorio Staff
Posts: 8293
Joined: Wed Feb 06, 2013 12:00 am
Contact:

Re: Autoplace entities and map

Post by kovarex »

drs9999 wrote:
ficolas wrote:Maybe since containers dont naturally spawn as neutral entities, the game uses the red color.
I think that too.

Anyway a (not that bad) workaround could be to use the tree-type, but if you harvest them you will get a different kind of wood. This can be processed into rubber.
Exactly, just change the minable properties, this is the most natural way to do it.

To clear the speculations:
  • Container is EntityWithOwner (unlike entity with force, it has the force of the owner, like furnace), this is to have the owner in logistic containers.
  • The default force in autoplacer is enemy, but it isn't used when the entity type isn't based on EntityWithOwner or EntityWith force (resources/trees etc).
  • The autoplacer should provide way to specify the force of the entity created, I added this to issues for 0.8
User avatar
Dysoch
Filter Inserter
Filter Inserter
Posts: 445
Joined: Fri Oct 18, 2013 2:27 pm
Contact:

Re: Autoplace entities and map

Post by Dysoch »

Great kovarex, ill hold of until 0.8 for rubber trees. Have a few more things planned for my next update, so work enough.
Thx all for helping, appreciate it!
Creator of:
- DyTech
- DyWorld
- DyWorld-Dynamics
- DyWorld-Dynamics 2
Active since Factorio 0.6
User avatar
Dysoch
Filter Inserter
Filter Inserter
Posts: 445
Joined: Fri Oct 18, 2013 2:27 pm
Contact:

Re: Autoplace entities and map

Post by Dysoch »

is it possible to add a random chance to the richness base of a resource?

something like this:

Code: Select all

autoplace =
		{
		  control = "gemstones",
		  sharpness = 0,
		  richness_multiplier = 1000,
		  richness_base = math.random(32),
		  peaks = {
			{
that way we never have the same amount of resources to small resource deposits.
(i dont want to make the multiplier higher, because then the deposit would have far to much :P)
Creator of:
- DyTech
- DyWorld
- DyWorld-Dynamics
- DyWorld-Dynamics 2
Active since Factorio 0.6
User avatar
Dysoch
Filter Inserter
Filter Inserter
Posts: 445
Joined: Fri Oct 18, 2013 2:27 pm
Contact:

Re: Autoplace entities and map

Post by Dysoch »

Code: Select all

		autoplace =
		{
		  control = "gemstones",
		  sharpness = 0,
		  richness_multiplier = math.random(1500),
		  richness_base = math.random(32),
		  peaks = {
this is what i use now, but i want to have it so that every resource tile placed is calculated differently. right now it calculates a number at the start of a map, and it sticks with that the entire map.
how to change this?
Creator of:
- DyTech
- DyWorld
- DyWorld-Dynamics
- DyWorld-Dynamics 2
Active since Factorio 0.6
User avatar
cube
Former Staff
Former Staff
Posts: 1111
Joined: Tue Mar 05, 2013 8:14 pm
Contact:

Re: Autoplace entities and map

Post by cube »

Well ... in general you can't, but you can do something simillar.

Try to add a new peak that has zero influence, but nonzero richness_influence and a set noise_layer. This way you won't change how the deposits are placed, only change their richness. For every tile already containing a resource this will add (noise value) * richness_influence * richness_multiplier units of the resource.
Value of the noise has approximately gaussian distribution centered around zero and a range approximately from -1.5 to 1.5.

Code: Select all

autoplace =
      {
        control = "gemstones",
        sharpness = 0,
        richness_multiplier = 12345,
        richness_base = 12345,
        peaks = {
            {
              influence = 0,
              richness_influence = 1.2,
              noise_layer = "gemstones-richness"
            }, --- ....
.... The autoplace mechanism is pretty strong,but tuning the parameters is hard. Good luck :-)
I have no idea what I'm talking about.
User avatar
Dysoch
Filter Inserter
Filter Inserter
Posts: 445
Joined: Fri Oct 18, 2013 2:27 pm
Contact:

Re: Autoplace entities and map

Post by Dysoch »

cube wrote:Well ... in general you can't, but you can do something simillar.

Try to add a new peak that has zero influence, but nonzero richness_influence and a set noise_layer. This way you won't change how the deposits are placed, only change their richness. For every tile already containing a resource this will add (noise value) * richness_influence * richness_multiplier units of the resource.
Value of the noise has approximately gaussian distribution centered around zero and a range approximately from -1.5 to 1.5.

Code: Select all

autoplace =
      {
        control = "gemstones",
        sharpness = 0,
        richness_multiplier = 12345,
        richness_base = 12345,
        peaks = {
            {
              influence = 0,
              richness_influence = 1.2,
              noise_layer = "gemstones-richness"
            }, --- ....
.... The autoplace mechanism is pretty strong,but tuning the parameters is hard. Good luck :-)
hahaha thx.
im now getting some pretty awesome results :P
im getting everything between 100 and 100.000 randomly chosen :P I LIKE IT!!!!

thx very much

edit: i tried this:

Code: Select all

{
		  control = "sand",
		  sharpness = 0.8,
		  richness_multiplier = math.random(75000),
		  richness_base = math.random(5000,15000),
		  peaks = {
			{
              influence = 0,
              richness_influence = 1.2,
              noise_layer = "random"
            }, --rest
edit2: its just awesome to see a resource of 40.000 something and only a few meters away there is 1 with only 900 :P
Creator of:
- DyTech
- DyWorld
- DyWorld-Dynamics
- DyWorld-Dynamics 2
Active since Factorio 0.6
kovarex
Factorio Staff
Factorio Staff
Posts: 8293
Joined: Wed Feb 06, 2013 12:00 am
Contact:

Re: Autoplace entities and map

Post by kovarex »

P.S. Using math.random in the prototype definition should be forbidden for obvious reasons (determinism->multiplayer + replays).
User avatar
Dysoch
Filter Inserter
Filter Inserter
Posts: 445
Joined: Fri Oct 18, 2013 2:27 pm
Contact:

Re: Autoplace entities and map

Post by Dysoch »

kovarex wrote:P.S. Using math.random in the prototype definition should be forbidden for obvious reasons (determinism->multiplayer + replays).
well i think it adds a great function.

by never having the same amount in a deposit, the replay value of the game just went up (my opinion.)
what was around 40.000 sand in a deposit could now be 500 or 50.000, thus you having to adapt to the situation.

the same goes for multiplayer, you always have to adapt to the situation.


(this and i had to test for around 4-6 hours yesterday to get it right xD)
Creator of:
- DyTech
- DyWorld
- DyWorld-Dynamics
- DyWorld-Dynamics 2
Active since Factorio 0.6
ficolas
Smart Inserter
Smart Inserter
Posts: 1068
Joined: Sun Feb 24, 2013 10:24 am
Contact:

Re: Autoplace entities and map

Post by ficolas »

Wont using math.random decide how deposits will be when loading the game?
User avatar
Dysoch
Filter Inserter
Filter Inserter
Posts: 445
Joined: Fri Oct 18, 2013 2:27 pm
Contact:

Re: Autoplace entities and map

Post by Dysoch »

ficolas wrote:Wont using math.random decide how deposits will be when loading the game?
True, but by adding another peak, you get completly random numbers everywhere. It calculates every resource differently, but keeps a chunk of resources near the same levels.
Creator of:
- DyTech
- DyWorld
- DyWorld-Dynamics
- DyWorld-Dynamics 2
Active since Factorio 0.6
Post Reply

Return to “Modding help”