[MOD 0.12.x] Spawn Belt 0.1.1

Topics and discussion about specific mods
Sunnova
Fast Inserter
Fast Inserter
Posts: 169
Joined: Mon May 16, 2016 12:10 pm
Contact:

Re: [MOD 0.12.x] Spawn Belt 0.1.1

Post by Sunnova »

Small change to get it to work, I'm sure I didn't do it the best way.

Old

Code: Select all

        -- On a lower interval rate, look for chests behind the belt to copy item type
        if tick.tick % chest_detection_rate == 0 then
          x = belt.entity.position.x;
          y = belt.entity.position.y;
          if belt.entity.direction == 0 then
            y = y + 1;
          elseif belt.entity.direction == 2 then
            x = x - 1;
          elseif belt.entity.direction == 4 then
            y = y - 1;
          elseif belt.entity.direction == 6 then
            x = x + 1;
          end

          chests = belt.entity.surface.find_entities_filtered({area = {{x,y},{x,y}}, type="container"});
          if #chests > 0 then
            inventory = chests[1].get_inventory(defines.inventory.chest);
            if inventory ~= nil
            and inventory.valid == true 
            and inventory.is_empty() == false 
            and inventory[1].valid == true
            and inventory[1].valid_for_read == true then
              belt.item = inventory[1].name;
            end
          end
        end
New

Code: Select all


        -- On a lower interval rate, look for chests behind the belt to copy item type
        if tick.tick % chest_detection_rate == 0 then
          x = belt.entity.position.x;
          y = belt.entity.position.y;
          if belt.entity.direction == 0 then
            chests = belt.entity.surface.find_entities_filtered{area = {{x,y},{x,y+1}}, type="container"};
          elseif belt.entity.direction == 2 then
            chests = belt.entity.surface.find_entities_filtered{area = {{x-1,y},{x,y}}, type="container"};
        elseif belt.entity.direction == 4 then
            chests = belt.entity.surface.find_entities_filtered{area = {{x,y-1},{x,y}}, type="container"};
          elseif belt.entity.direction == 6 then
            chests = belt.entity.surface.find_entities_filtered{area = {{x,y},{x+1,y}}, type="container"};
          end

          if #chests > 0 then
            inventory = chests[1].get_inventory(defines.inventory.chest);
            if inventory ~= nil
            and inventory.valid == true 
            and inventory.is_empty() == false 
            and inventory[1].valid == true
            and inventory[1].valid_for_read == true then
              belt.item = inventory[1].name;
            end
          end
        end

barrykun
Inserter
Inserter
Posts: 27
Joined: Tue Jun 07, 2016 7:42 pm
Contact:

Re: [MOD 0.12.x] Spawn Belt 0.1.1

Post by barrykun »

charmead wrote:Small change to get it to work, I'm sure I didn't do it the best way.


Thanks for that, I havnt been able to test 0.13.10 because the version is unplayable in Linux. I'll have to wait for 0.13.11 where it's gonna be fixed. I'll update this mod then

winkieman
Burner Inserter
Burner Inserter
Posts: 17
Joined: Fri Apr 01, 2016 10:55 pm
Contact:

Re: [MOD 0.12.x] Spawn Belt 0.1.1

Post by winkieman »

This is the message I get
Error while running the eventhandler__spawn-belt__/control.lua:116:An area of zero size is not supported. Either don't define area to seach the entrire surface or use 'position'.
No idea what it means but crashes the game.

barrykun
Inserter
Inserter
Posts: 27
Joined: Tue Jun 07, 2016 7:42 pm
Contact:

Re: [MOD 0.12.x] Spawn Belt 0.1.1

Post by barrykun »

winkieman wrote:This is the message I get
Error while running the eventhandler__spawn-belt__/control.lua:116:An area of zero size is not supported. Either don't define area to seach the entrire surface or use 'position'.
No idea what it means but crashes the game.
Its one of the scripting changes in the lua api, i saw it documented in the changelog. I'll update this mod asap when I get a chance to play 0.13.11 thanks for reporting the error!

barrykun
Inserter
Inserter
Posts: 27
Joined: Tue Jun 07, 2016 7:42 pm
Contact:

Re: [MOD 0.12.x] Spawn Belt 0.1.1

Post by barrykun »

Alright I've updated the mod to 1.0.2 and fixed the error caused by 0.13.11

I did not run into any lag or freezing issues while testing so I did not implement what charmead posted as a fix, if anyone noticed the lag/freeezing still in 0.13.11+ please let me know

User avatar
DeadPlanet
Burner Inserter
Burner Inserter
Posts: 10
Joined: Sat Nov 05, 2016 11:25 am
Contact:

Re: [MOD 0.12.x] Spawn Belt 0.1.1

Post by DeadPlanet »

First post on the forums and it a necro. Nice way to make an entrance, Planet!

That being said... Does this mod work in 0.14?
I wanna do some testing with set-ups and this would be a marvellous tool.

barrykun
Inserter
Inserter
Posts: 27
Joined: Tue Jun 07, 2016 7:42 pm
Contact:

Re: [MOD 0.12.x] Spawn Belt 0.1.1

Post by barrykun »

It should work fine yes. It's available in the ingame mod portal.

User avatar
DeadPlanet
Burner Inserter
Burner Inserter
Posts: 10
Joined: Sat Nov 05, 2016 11:25 am
Contact:

Re: [MOD 0.12.x] Spawn Belt 0.1.1

Post by DeadPlanet »

I found it, thnx!

The only thing that I found that might be bugged, if you set a spawnbelt to spawn anything but Iron Ore and send out construction robots to demolish it, it'll keep grabbing the spawned items and leave the belt spawning stuff.
You have to manually go and pick it up.

Also, when using blueprints both spawn and vanish belts will do nothing after being placed by robots. They just sit there. Being belts. Acting like 'regular' belts. d;

I'll do some further testing and report back.

barrykun
Inserter
Inserter
Posts: 27
Joined: Tue Jun 07, 2016 7:42 pm
Contact:

Re: [MOD 0.12.x] Spawn Belt 0.1.1

Post by barrykun »

I am aware of the behaviour of having them placed by robots. Didn't think of the demolishing thing to be honest. I suppose it should stop spawning when marked as deconstruct.

Thanks for the feedback.

User avatar
DeadPlanet
Burner Inserter
Burner Inserter
Posts: 10
Joined: Sat Nov 05, 2016 11:25 am
Contact:

Re: [MOD 0.12.x] Spawn Belt 0.1.1

Post by DeadPlanet »

When you get a mail that something was posted in this thread and you find there's nothing new there... Now that is some weird stuff.

Sunnova
Fast Inserter
Fast Inserter
Posts: 169
Joined: Mon May 16, 2016 12:10 pm
Contact:

Re: [MOD 0.12.x] Spawn Belt 0.1.1

Post by Sunnova »

DeadPlanet wrote:When you get a mail that something was posted in this thread and you find there's nothing new there... Now that is some weird stuff.
My fault, I had posted a question about using red wires in version 1.0.5 to control what is spawned on the belt, figured it out and deleted my post. Sorry about that.

Post Reply

Return to “Mods”