Page 1 of 1

Need help turning a biter-spawner into an assembler

Posted: Wed Sep 21, 2016 12:09 pm
by doktorstick
Howdy. I need an assist.

I've successfully turned a biter-spawner into an assembler. The main change I had to do was change the animations to animation and pick one of the spawner_idle_animations.

However, I'm running into a problem with pipe connections. I can't seem to get fluid-boxes definition correct. Fiddling with collision_box, selection_box and pipe_connections, I can only ever seem to get an input pipe to connect from one direction (usually the west, but sometimes the east). North/south are misaligned.

What am I missing? Thanks!

Re: Need help turning a biter-spawner into an assembler

Posted: Wed Sep 21, 2016 12:39 pm
by aubergine18
Is your current code posted anywhere (github) so people can download and experiment with it to find out what the issue with pipe connections is?

Re: Need help turning a biter-spawner into an assembler

Posted: Wed Sep 21, 2016 2:10 pm
by doktorstick
I don't. It's not even a mod per se--i'm tinkering/exploring. I'll see about packaging a zip together, but it won't be for a long while. Busy day today.

Re: Need help turning a biter-spawner into an assembler

Posted: Wed Sep 21, 2016 6:34 pm
by Adil
You can't make entity of one kind to behave like another. Spawner type doesn't support the pipe connections, if you want to make those visible, you'll have to write them in sprite definitions. If you wan them to behave like pipes, you'll have to hack new entity and place it beside the spawner.
Actually it seems easier to make assembler to look like spawner and create units around it with lua.

Re: Need help turning a biter-spawner into an assembler

Posted: Wed Sep 21, 2016 7:09 pm
by DedlySpyder
Adil wrote:Actually it seems easier to make assembler to look like spawner and create units around it with lua.
Or make an extra entity under the assembler that is a spawner (I have to imagine that the spawning logic is better than what a mod can do easily)

Re: Need help turning a biter-spawner into an assembler

Posted: Wed Sep 21, 2016 8:25 pm
by doktorstick
Adil wrote:You can't make entity of one kind to behave like another. Spawner type doesn't support the pipe connections, if you want to make those visible, you'll have to write them in sprite definitions. If you wan them to behave like pipes, you'll have to hack new entity and place it beside the spawner.
Actually it seems easier to make assembler to look like spawner and create units around it with lua.
That's basically what I've done. I set the type as "assembing-machine" and updated the "animations" tag to be "animation" because using what was defined in the spawner entity caused an empty sprite. What I thought was happening with the pipe (because it shows up and rotates on the "R" key) is that the spawner's collision/selection box is rectangular--not square.

Here's the test definition I have. You'll notice most are from assembler 3 IIRC. I'm not sure what the base_area and base_level do; I've tried various values to (seemingly) no effect.

Code: Select all

{
   type = "assembling-machine",
   name = "test-spawner-assembler"
   icon = moddir.."/graphics/icons/biter-spawner.png",  -- just copied from base/; did this before I realized "animations" didn't work
   flags = {"placeable-neutral","placeable-player", "player-creation"},
   minable = {hardness = 0.2, mining_time = 0.5, result = "test-spawner-assembler"}
   max_health = 300,
   corpse = "big-remnants",
   dying_explosion = "medium-explosion",
   resistances =
      {
         {
            type = "fire",
            percent = 70
         }
      },
   fluid_boxes =
      {
         {
            production_type = "input",
            pipe_picture = assembler3pipepictures(),
            pipe_covers = pipecoverspictures(),
            --base_area = 10,
            --base_level = -1,
            pipe_connections = {{ type="input", position = {0, -2.2}}}
         },
         off_when_no_fluid_recipe = true
      },
   open_sound = { filename = "__base__/sound/machine-open.ogg", volume = 0.85 },
   close_sound = { filename = "__base__/sound/machine-close.ogg", volume = 0.75 },
   vehicle_impact_sound =  { filename = "__base__/sound/car-metal-impact.ogg", volume =
 0.65 },
   working_sound =
      {
         sound = {
            {
               filename = "__base__/sound/assembling-machine-t3-1.ogg",
               volume = 0.8
            },
            {
               filename = "__base__/sound/assembling-machine-t3-2.ogg",
               volume = 0.8
            },
         },
         idle_sound = { filename = "__base__/sound/idle1.ogg", volume = 0.6 },
         apparent_volume = 1.5,
      },

   -- Assembler 3
   --collision_box = {{-1.2, -1.2}, {1.2, 1.2}},
   --selection_box = {{-1.5, -1.5}, {1.5, 1.5}},

   collision_box = {{-3.2, -2.2}, {2.2, 2.2}},
   selection_box = {{-3.5, -2.5}, {2.5, 2.5}},

   fast_replaceable_group = "assembling-machine",
   animation = spawner_idle_animation (0, {r=0.92, g=0.54, b=0, a=0.5}),

   crafting_categories = {"test-recipes"},
   crafting_speed = 1.25,
   energy_source =
      {
         type = "electric",
         usage_priority = "secondary-input",
         emissions = 0.03 / 3.5
      },
   energy_usage = "210kW",
   ingredient_count = 6,
   module_specification =
      {
         module_slots = 4
      },
   allowed_effects = {"consumption"}
}

Re: Need help turning a biter-spawner into an assembler

Posted: Wed Sep 21, 2016 8:27 pm
by doktorstick
DedlySpyder wrote:
Adil wrote:Actually it seems easier to make assembler to look like spawner and create units around it with lua.
Or make an extra entity under the assembler that is a spawner (I have to imagine that the spawning logic is better than what a mod can do easily)
Oh, hah, yeah, that's not what I want. It isn't spawning units. It's an "otherworldly" goods producer. It should function like a normal assembler, but has a different skin--that of the spawner. I'll pick different sounds and stuff later to match the theme.

Re: Need help turning a biter-spawner into an assembler

Posted: Thu Sep 22, 2016 5:43 pm
by DedlySpyder
I think you need to find "assembler3pipepictures()" and "pipecoverspictures()" and make your own replacements. It's been a while since I touched fluid boxes though.

If you check my Avatars mod (in my signature, though check the github because I haven't touched the thread in a while) I use fluid boxes to display a door on my avatar assembling machine.

Edit: ok, I checked it real fast, pipe connections is the pipe, and pipe covers is the cap on the pipes if it's not connected (I didn't use the covers). Relevant github link: https://github.com/DedlySpyder/Avatars/ ... sembly.lua

Re: Need help turning a biter-spawner into an assembler

Posted: Fri Sep 23, 2016 3:55 pm
by anarchyinc
Base_area = size of the storage for pipe/tank (1 equals 10, 10 equals 100)
Base_level = location of the fluid box relative to 0 (ground level) +1 will push out -1 will pull into.
viewtopic.php?f=25&t=2442&start=10

Your fluid boxes should be
Fluid box
The selection/collision boxes should be... (This will maintain a 3x3 footprint with the correct connections to the pipes, I have no idea why you made it into a rectangle)
collision
And lastly, you left the animation size undefined. The assembler and spawner sprite sheets are different sizes so you need to adjust accordingly. This should be the proper math, but you might need to play with the shift to get it perfect.
base animation
Edit: Ah, I see what you did wrong. You tried to use all the code from the spawner and turn it into an assembly machine instead of just using the assembler code with a new graphic. I was wondering why the collision box was so wrong. Wrong collision = pipes will never connect.

Re: Need help turning a biter-spawner into an assembler

Posted: Fri Sep 23, 2016 4:31 pm
by doktorstick
I'll give this a try on Saturday! Thanks for the detailed look.

Re: Need help turning a biter-spawner into an assembler

Posted: Fri Sep 23, 2016 4:34 pm
by anarchyinc
I did a bit of testing and got it to work fine with my code on the first try. You might want to add scale = 0.75 or so to the base animation but it's good enough to play with. Also, when using the game's default spawner the thing rotates when it is running as part of the animation so I made you a new sprite sheet.
working spawner-assember
working spawner-assember
spawner.png (419.72 KiB) Viewed 4168 times
base animation
base animation
spawner-idle.png (360.99 KiB) Viewed 4168 times
test.lua
prototype file
(3.22 KiB) Downloaded 85 times

Re: Need help turning a biter-spawner into an assembler

Posted: Fri Sep 23, 2016 10:07 pm
by Nexela
I never realized how disgusting those spawners looked until see thing post.........

Re: Need help turning a biter-spawner into an assembler

Posted: Sat Sep 24, 2016 3:29 pm
by doktorstick
:D Works great, thank you kindly. You've gotten me over my hurdle and I appreciate the extra effort you went through.