Making a Watermill?

Place to get help with not working mods / modding interface.
Post Reply
TheLastRonin
Inserter
Inserter
Posts: 23
Joined: Thu Jan 22, 2015 8:22 pm
Contact:

Making a Watermill?

Post by TheLastRonin »

I wanted to make a watermill to generate power but I'm not sure how do replicate all the functions of the steam engine with just one building? The steam engine needs a pump, pipes, boiler and the steam engine to create power. Is there a way to do all of that with just the one building and have it only placeable along a coast like the off-shore pump?

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

Re: Making a Watermill?

Post by FreeER »

Well the offshore pump is hard coded to only be placeable on a water tile, so unless you want to manually check the tile after it's been built (game.gettile(x, y).name:match("water"), or something similar) you'd need to use that as your entity type, which of course means that you'd have to manually implement the energy generation since offshore pumps don't. Or vice versa, use a generator and when a player tries to place it (it fails on water tiles, but you can detect it with onputitem, though you'll have to use a loop 'hack' to get the closest player to check/remove the item, or game.findentitiesfiltered, since no playerindex is given. It's not exactly optimal) use game.createentity to place it for them, of course then you have to manually add the water (and set the temperature) using fluidboxes so that it can generate energy.

Unless you really want it as one building, It'd probably be easier to create a 'super' boiler (so you only need one of them, maybe for the other components as well), and using game.createentity to place the other required components down (you can use entity.direction in onbuiltentity/onrobotbuiltentity to find out how you should alter the x,y position for the other components, defines.direction is a table of directions) after the player places the base (I'm assuming you'd use the offshore pump or a variation based on it so that the tile checks are done for you). The extra components can be new prototypes so they are just a tile big and can't be mined (add a couple checks for the base entity being mined/destroyed and destroy the extra ones when it is, or make them minable but not return anything?).

edit: note game.createentity takes a force parameter which defaults to game.forces.enemy when not given (you'd really want to pass the force of the player that placed it though, I saw in one post that the next major release might have separate forces for players and I know there are some mods which make every other player on the enemy's force, like the one FishSandwich and Xterminator are using in their PvP let's play)

TheLastRonin
Inserter
Inserter
Posts: 23
Joined: Thu Jan 22, 2015 8:22 pm
Contact:

Re: Making a Watermill?

Post by TheLastRonin »

Sounds complicated :(.

Post Reply

Return to “Modding help”