[0.11.11+] FARL 0.2.8 (Rail Layer)

The raillayer; must have, if you want to play with railway.

Moderator: Choumiko

Locked
Choumiko
Smart Inserter
Smart Inserter
Posts: 1278
Joined: Fri Mar 21, 2014 10:51 pm
Contact:

Re: [0.11.11+] FARL 0.2.2 (Rail Layer)

Post by Choumiko » Mon Mar 09, 2015 11:08 am

Cheata wrote:um just a quick guess here but shouldnt the "farl" be "FARL" script is case sensitive isnt it?
Nope, its lowercase, in the beginning of the mod i used console commands quite often and was too lazy to press shift :D
@ Airat: FARL does not work with Factorio 0.11.6 no matter what version of FARL you are using. The old Automatic Rail Layer should work though (link in first post)

Thanks Cheata for sharing. I quickly looked over your changes and i couldn't see any obvious things that would break FARL. Might be able to integrate it in the next days.
Since the changes are in places where i more or less would have put them too, i assume my code is understandable to a certain degree :D

User avatar
Cheata
Long Handed Inserter
Long Handed Inserter
Posts: 78
Joined: Sun Aug 17, 2014 6:46 am
Contact:

Re: [0.11.11+] FARL 0.2.2 (Rail Layer)

Post by Cheata » Mon Mar 09, 2015 12:22 pm

Choumiko wrote: i assume my code is understandable to a certain degree :D
Certinaly more understandable than a lot of the code I usually reverse engineer. I also found it to be fairly logicly laid out, i particularly like the way uv got the removetrees function designed so it can be used with every object placed by the FARL ;)

Airat9000
Smart Inserter
Smart Inserter
Posts: 1317
Joined: Fri Mar 28, 2014 12:32 am
Contact:

Re: [0.11.11+] FARL 0.2.2 (Rail Layer)

Post by Airat9000 » Mon Mar 09, 2015 12:48 pm

Choumiko wrote:
Cheata wrote:um just a quick guess here but shouldnt the "farl" be "FARL" script is case sensitive isnt it?
Nope, its lowercase, in the beginning of the mod i used console commands quite often and was too lazy to press shift :D
@ Airat: FARL does not work with Factorio 0.11.6 no matter what version of FARL you are using. The old Automatic Rail Layer should work though (link in first post)

Thanks Cheata for sharing. I quickly looked over your changes and i couldn't see any obvious things that would break FARL. Might be able to integrate it in the next days.
Since the changes are in places where i more or less would have put them too, i assume my code is understandable to a certain degree :D

I installed version 2.2 but did not see it in the new in the old game.

Image

waduk
Filter Inserter
Filter Inserter
Posts: 362
Joined: Tue Feb 10, 2015 5:44 pm
Contact:

Re: [0.11.11+] FARL 0.2.2 (Rail Layer)

Post by waduk » Mon Mar 09, 2015 1:26 pm

@Choumiko:
The dude probably didn't understand english very well..

@Airat:
This mod ONLY work in Factorio 0.11.11 or above
Your version is 11.6, therefore it WON'T work.

If you want automatic rail, you can use ANOTHER MOD that SIMILAR with FARL.

n9103
Smart Inserter
Smart Inserter
Posts: 1067
Joined: Wed Feb 20, 2013 12:09 am
Contact:

Re: [0.11.11+] FARL 0.2.2 (Rail Layer)

Post by n9103 » Mon Mar 09, 2015 5:22 pm

Contrary to popular opinion, being louder doesn't make words translate better.

KZ:
Factorio осы түрлендіру пайдалануға нұсқасы 11.11 немесе одан жоғары болуы тиіс.
Сіз нұсқасын 11,6 пайдаланып отырсыз. Бұл жұмыс істемейді.
RU:
Factorio должен быть версии 11.11 или выше, чтобы использовать эту модификацию.
Вы используете версию 11.6. Это не будет работать.
Colonel Failure wrote:You can lose your Ecologist Badge quite quickly once you get to the point of just being able to murder them willy-nilly without a second care in the world.

waduk
Filter Inserter
Filter Inserter
Posts: 362
Joined: Tue Feb 10, 2015 5:44 pm
Contact:

Re: [0.11.11+] FARL 0.2.2 (Rail Layer)

Post by waduk » Mon Mar 09, 2015 5:37 pm

n9103 wrote:Contrary to popular opinion, being louder doesn't make words translate better.

KZ:
Factorio осы түрлендіру пайдалануға нұсқасы 11.11 немесе одан жоғары болуы тиіс.
Сіз нұсқасын 11,6 пайдаланып отырсыз. Бұл жұмыс істемейді.
RU:
Factorio должен быть версии 11.11 или выше, чтобы использовать эту модификацию.
Вы используете версию 11.6. Это не будет работать.
I'm not yelling, just making some words bigger to grab his attention.
Originally i post that with a footnote, that literally said i'm not yelling.
But i deleted the original words, since the dude probably getting more confused. I try to keep it simple.
Sorry if i seems to offend someone.

Kane
Filter Inserter
Filter Inserter
Posts: 654
Joined: Fri Sep 05, 2014 7:34 pm
Contact:

Re: [0.11.11+] FARL 0.2.2 (Rail Layer)

Post by Kane » Thu Mar 12, 2015 7:42 pm

Sadly will not start in 18 update.
Image

Code: Select all

Moved the player hit tint color into the player prototype.

Choumiko
Smart Inserter
Smart Inserter
Posts: 1278
Joined: Fri Mar 21, 2014 10:51 pm
Contact:

Re: [0.11.11+] FARL 0.2.2 (Rail Layer)

Post by Choumiko » Thu Mar 12, 2015 8:23 pm

New Version: FARL 0.2.3
Changes
  • Fix for Factorio 0.11.18
    added support for Landfill mod
Landfill support:
The checkbox only shows when you have landfill installed. Landfill is used for rails, poles, signals, lamps.
Used all the changes kindly provided by Cheata with a few tweaks. For curved rails it uses too much, will change that once i have the time.

@Kane: that was a quick report, according to the forums the report came before the release :D

Kane
Filter Inserter
Filter Inserter
Posts: 654
Joined: Fri Sep 05, 2014 7:34 pm
Contact:

Re: [0.11.11+] FARL 0.2.2 (Rail Layer)

Post by Kane » Thu Mar 12, 2015 8:42 pm

Choumiko wrote:New Version: FARL 0.2.3
Changes
  • Fix for Factorio 0.11.18
    added support for Landfill mod
Landfill support:
The checkbox only shows when you have landfill installed. Landfill is used for rails, poles, signals, lamps.
Used all the changes kindly provided by Cheata with a few tweaks. For curved rails it uses too much, will change that once i have the time.

@Kane: that was a quick report, according to the forums the report came before the release :D
Image

Thanks for the quick update :)

User avatar
Cheata
Long Handed Inserter
Long Handed Inserter
Posts: 78
Joined: Sun Aug 17, 2014 6:46 am
Contact:

Re: [0.11.11+] FARL 0.2.3 (Rail Layer)

Post by Cheata » Sat Mar 14, 2015 2:10 am

Hi all,
so its the weekend and i got board as i result i decided to play with the FARL mod again.

When i play factorio i like to play death-world like maps. This causes problems with large rail networks as the biters tend to go after the rails and power poles, or even the trains themselves.

my normal solution to this is to place some laser turrets and wall around each pole... so iv tweaked the blueprint system in FARL to allow this. Code changes as follows for those who are interested.


using FARL 0.2.3

first lets modify the default pole placement blueprints to allow for some changes made later in the code
Control.lua

Code: Select all

--poleDistance = 1, side = right
  defaultsDiagonal = {
      direction = 3,
-- add label for position values and a name for the item placed repeat for other 3 blueprints below start ~line 76
      lamps = {{pos = {x = -1.5, y = 1.5},name = "small-lamp"}},
--end mod
      pole = {name = "big-electric-pole", position = {x = 2.5, y = 2.5}}
  }
 
  defaultsStraight = {
      direction = 0,
--mod
      lamps = {{pos = {x = -0.5, y = 1.5},name = "small-lamp"}},
--end mod
      pole = {name = "big-electric-pole", position = {x = 3, y = 0}}
  }
  
  defaultsMediumDiagonal = { 
    direction = 7,
--mod
    lamps = {{pos = {x = -1, y = 1},name = "small-lamp"}},
--end mod
    pole = {name = "medium-electric-pole", position = {x = 2, y = 1}}
  }
  
  defaultsMediumStraight = {
    direction = 0,
--mod
    lamps = {{pos = {x = 0,y = 1},name = "small-lamp"}},
--end mod
    pole = {name = "medium-electric-pole", position = {x = 2.5,y = -0.5}}
  }
Lots of small changes in the next file most notably is the modification of the "lamps" table passed to the global blueprints variable, lamps now has 2 properties instead of just being the position, lamps.pos now contains the position and lamps.name contains the name of the item to be placed

FARL.lua

Code: Select all

-- add stone-wall and laser-turret to the cargo manifest update function ~line 439
updateCargo = function(self)
    local types = { "straight-rail", "curved-rail","rail-signal",
      "big-electric-pole", "medium-electric-pole", "small-lamp",
      "green-wire", "red-wire","laser-turret","stone-wall"
    }
-- end mod

*************

 self.lastCheckPole = addPos(lastrail.position, offset)
-----------------------><-------------------------------
        end
--~line 763
-- remove if godmod or self:["small-lamp"] which would limit the placement to work only if lamps were in the cargo manifest,  this well be added elsewhere to allow for items other than lamps
          self:placeLamp(traveldir, tmp)
-- remove end for above if
--end mod
        self:removeItemFromCargo(name, 1)

**********************************

-- tweak blueprint parsing to read lasers and walls as well as small lamps
 parseBlueprints = function(self, bp)
    for j=1,#bp do
      local e = bp[j].getblueprintentities()
      local offsets = {pole=false, lamps={}}
      local rail

      for i=1,#e do
        if not rail and e[i].name == "straight-rail" then
          rail = {direction = e[i].direction, name = e[i].name, position = e[i].position}
        end
        if e[i].name == "big-electric-pole" or e[i].name == "medium-electric-pole" then
          offsets.pole = {name = e[i].name, direction = e[i].direction, position = e[i].position}
        end
-- add checks for "laser-turret" and "stone-wall"
        if e[i].name == "small-lamp" or e[i].name == "laser-turret" or e[i].name == "stone-wall" then
-- end mod
          table.insert(offsets.lamps, {name = e[i].name, direction = e[i].direction, position = e[i].position})
        end
   end
      if rail and offsets.pole then
        local type = rail.direction == 0 and "straight" or "diagonal"
        local lamps = {}
        for _, l in ipairs(offsets.lamps) do
-- change the passed out lamps table to include the name of the item placed
          table.insert(lamps, {pos=subPos(l.position, offsets.pole.position),name=l.name})
-- end mod
        end

********************************

-- modify the place lamp function to allow for other entitys ~line 662
   placeLamp = function(self,traveldir,pole)
    local lamps = traveldir % 2 == 0 and glob.activeBP.straight.lamps or glob.activeBP.diagonal.lamps
    local diff = traveldir % 2 == 0 and traveldir or traveldir-1
    local rad = diff * (math.pi/4)
    for i=1,#lamps do
-- add the if statement we removed from self.checklastpole modified to check multiple entity's
      if godmode or self[lamps[i].name] > 0 then
-- add the .pos to lamps to allow for extra variables stored in the blueprint
        local offset = rotate(lamps[i].pos, rad)
        local pos = addPos(pole, offset)
        --debugDump(pos, true)
-- added a remove trees here to allow for landfill mod and in-case new blueprint is larger than normally checked area
        self:removeTrees(pos)
-- change the hard coded canplace for "small-lamps" with variable name of new entity
        local canplace = game.canplaceentity{name = lamps[i].name, position = pos}
-- remove and (self["small-lamp"] > 1 as we already checked for this at the start of the loop and would need to modify with variable name of new entity besides (lamps[i].name)
        if canplace or godmode) then
-- change "small-lamp" to varaible name of new entity
          game.createentity{name = lamps[i].name, position = pos, direction=0,force = game.forces.player}
-- change "small-lamp" to varaible name of new entity
          self:removeItemFromCargo(lamps[i].name, 1)
        end
      end
    end
  end,

Thats all for now but ill probably have something else tweaked before the end of the day.

TBC

ps forgot to mention, because of the way I have modified the blueprint varaible you will either need to clear or re read your blueprints when loading a save where farl was alrwady active. otherwise you will get an error at the first powerpole it places
Last edited by Cheata on Sat Mar 14, 2015 1:13 pm, edited 1 time in total.

User avatar
Cheata
Long Handed Inserter
Long Handed Inserter
Posts: 78
Joined: Sun Aug 17, 2014 6:46 am
Contact:

Re: [0.11.11+] FARL 0.2.3 (Rail Layer)

Post by Cheata » Sat Mar 14, 2015 5:42 am

Part 2 :P

I also like to use the Dytec Warfare mod, this adds 11 new laser turrets and 3 new wall types

thats a lot of additions to a couple of already large if statements, in addition we only want them active when the dytech warfare mod is .. so in addition to my last post here is the code iv used to integrate Dytech Warfare into the previous tweak. It should also be expandable to just about any entity or mod people want to integrate to the FARL blueprint system.

using FARL version 0.2.3
control.lua

Code: Select all

glob.cruiseSpeed = glob.cruiseSpeed or 0.4

--create a global variable (table) for all entity to be recognized in blueprints ~line 200
    glob.bpentitys = {"small-lamp","laser-turret","stone-wall"}
-- add to the above table the additional entity's to be recognized from dytech using laserturret2 because dytech no longer has a warfare interface and the dytech-core to make sure its dytech installed and not another mod
    if game.interfaces["DyTech-Core"] and game.entityprototypes["laser-turret-2"] then
      table.insert(glob.bpentitys, "laser-turret-2")
      table.insert(glob.bpentitys, "laser-turret-3")
      table.insert(glob.bpentitys, "laser-turret-4")
      table.insert(glob.bpentitys, "laser-turret-5")
      table.insert(glob.bpentitys, "laser-turret-6")
      table.insert(glob.bpentitys, "laser-turret-7")
      table.insert(glob.bpentitys, "laser-turret-8")
      table.insert(glob.bpentitys, "laser-turret-9")
      table.insert(glob.bpentitys, "laser-turret-sniper-1")
      table.insert(glob.bpentitys, "laser-turret-sniper-2")
      table.insert(glob.bpentitys, "laser-turret-sniper-3")
      table.insert(glob.bpentitys, "tungsten-wall")
      table.insert(glob.bpentitys, "chitin-wall")
      table.insert(glob.bpentitys, "sandwall")
    end
-- end mod
    for i,farl in ipairs(glob.farl) do
perhaps some of the above should be extracted to the config.lua file for ease of adjustment ... not sure

FARL.lua

Code: Select all

--change cargo manifest update to add the pre-approved entity's from the blueprints ~line 436
updateCargo = function(self)
-- removed all blueprint related entity's from the existing list
    local types = { "straight-rail", "curved-rail","rail-signal",
      "big-electric-pole", "medium-electric-pole", "green-wire", "red-wire"
    }
-- create loop to add entity's from global blueprint list to types table
    for _,bpentity in pairs(glob.bpentitys) do
      table.insert(types, bpentity)
    end
-- end mod

****************

-- added new function just before the parseBlueprints function to check entity names against the preset list ~line 488
checkbpentity = function(self,entity)
   for _,ventity in ipairs(glob.bpentitys) do
     if entity == ventity then
      return true
     end
   end
   return false
  end,
-- end mod

**************************
-- change if statement from multiple and's to a call to the previously created function, if the name of the entity is on the pre-approved list then the entity will be inserted into the lamps table as per original design
-- ~line 510
if self:checkbpentity(e[i].name) == true then
 -- end mod
          table.insert(offsets.lamps, {name = e[i].name, direction = e[i].direction, position = e[i].position})
end

Im fairly sure some of this code could be neater but it works. If someone (or Choumiko) wants to take it further feel free.

Choumiko
Smart Inserter
Smart Inserter
Posts: 1278
Joined: Fri Mar 21, 2014 10:51 pm
Contact:

Re: [0.11.11+] FARL 0.2.3 (Rail Layer)

Post by Choumiko » Sat Mar 14, 2015 11:07 pm

New Version: FARL 0.2.4

Changes
  • option to disable collecting/droping wood
    place any entity stored in blueprints
I got annoyed by FARL leaving behind hundreds of wood logs when plowing through a forest, so you can now disable it.
Cheata wrote:Im fairly sure some of this code could be neater but it works. If someone (or Choumiko) wants to take it further feel free.
I did :D Instead of whitelisting items i simply ignored poles/rails and saved every other blueprintentity. Should now work with every mod-item, though i only tested it with vanilla laser turrets, walls, chests, inserters and radars
FARL now saves every entity of a blueprint, and tries to place it whenever it places a pole.
Edit: Doesn't work properly for 2x1 entities (gun turrets, splitters) and rail-signals. But at least using splitters at every pole seems silly ;)

User avatar
Cheata
Long Handed Inserter
Long Handed Inserter
Posts: 78
Joined: Sun Aug 17, 2014 6:46 am
Contact:

Re: [0.11.11+] FARL 0.2.3 (Rail Layer)

Post by Cheata » Sun Mar 15, 2015 5:21 am

Choumiko wrote:New Version: FARL 0.2.4

Edit: Doesn't work properly for 2x1 entities (gun turrets, splitters) and rail-signals. But at least using splitters at every pole seems silly ;)
not silly if you setup normal gun turrets and and auto ammo feed......... XD

n9103
Smart Inserter
Smart Inserter
Posts: 1067
Joined: Wed Feb 20, 2013 12:09 am
Contact:

Re: [0.11.11+] FARL 0.2.4 (Rail Layer)

Post by n9103 » Sun Mar 15, 2015 5:38 am

Which isn't a problem since you can't setup turrets anyway :P
Colonel Failure wrote:You can lose your Ecologist Badge quite quickly once you get to the point of just being able to murder them willy-nilly without a second care in the world.

Kane
Filter Inserter
Filter Inserter
Posts: 654
Joined: Fri Sep 05, 2014 7:34 pm
Contact:

Re: [0.11.11+] FARL 0.2.4 (Rail Layer)

Post by Kane » Sun Mar 15, 2015 8:13 pm

Found a new little cute crash. I thought at first this resulted in saving and then loading while in the train and starting up. The old annoying bug where you gotta get in and out I assume the way it enables the script was now causing the crash. But when I got out without starting moved back then forward and then started I was still getting this crash. I wonder if it's a range issue something going derpy because of the amount of signals in the general area.

Screenshot:
http://i.imgur.com/I2hY3LD.jpg

I went ahead and placed more track down the line assuming it would stop crashing and that it did.

Thanks :)

n9103
Smart Inserter
Smart Inserter
Posts: 1067
Joined: Wed Feb 20, 2013 12:09 am
Contact:

Re: [0.11.11+] FARL 0.2.4 (Rail Layer)

Post by n9103 » Sun Mar 15, 2015 8:22 pm

If it's that exact spot only, then I would guess it had something to do with the pathfinding, since the direction you're building (south) is against the allowed traffic direction, and one of your engines isn't past that one-way signal yet.
Colonel Failure wrote:You can lose your Ecologist Badge quite quickly once you get to the point of just being able to murder them willy-nilly without a second care in the world.

Kane
Filter Inserter
Filter Inserter
Posts: 654
Joined: Fri Sep 05, 2014 7:34 pm
Contact:

Re: [0.11.11+] FARL 0.2.4 (Rail Layer)

Post by Kane » Sun Mar 15, 2015 8:58 pm

n9103 wrote:If it's that exact spot only, then I would guess it had something to do with the pathfinding, since the direction you're building (south) is against the allowed traffic direction, and one of your engines isn't past that one-way signal yet.
You say against traffic direction. This is a Canadian designed Rail system :P

User avatar
Cheata
Long Handed Inserter
Long Handed Inserter
Posts: 78
Joined: Sun Aug 17, 2014 6:46 am
Contact:

Re: [0.11.11+] FARL 0.2.4 (Rail Layer)

Post by Cheata » Sun Mar 15, 2015 9:28 pm

That error is usually caused by trying to do arithmetic on a non numerical value.

Last time i saw it i was trying to divide a table by 4 (strangely enough that was while i was playing with the FARL mod the other day, not related to this instance though)

If possible see if you can replicate the error and upload a save where it still occurs so someone can try and debug it.

Choumiko
Smart Inserter
Smart Inserter
Posts: 1278
Joined: Fri Mar 21, 2014 10:51 pm
Contact:

Re: [0.11.11+] FARL 0.2.4 (Rail Layer)

Post by Choumiko » Sun Mar 15, 2015 10:26 pm

It looks like the issue could be the curved rail connecting to the straight ones under the FARL. Though FARL ignores curved rails when trying to find a start (or at least it should..).
Signals or pathfinding isn't the reason, signals are ignored, pathfinding is not implemented (yet)
I'll look into it

n9103
Smart Inserter
Smart Inserter
Posts: 1067
Joined: Wed Feb 20, 2013 12:09 am
Contact:

Re: [0.11.11+] FARL 0.2.4 (Rail Layer)

Post by n9103 » Sun Mar 15, 2015 10:29 pm

Kane wrote:
n9103 wrote:If it's that exact spot only, then I would guess it had something to do with the pathfinding, since the direction you're building (south) is against the allowed traffic direction, and one of your engines isn't past that one-way signal yet.
You say against traffic direction. This is a Canadian designed Rail system :P
So... Trains in Canada are signaled after they pass, instead of before? You lost me there.
Colonel Failure wrote:You can lose your Ecologist Badge quite quickly once you get to the point of just being able to murder them willy-nilly without a second care in the world.

Locked

Return to “F.A.R.L”

Who is online

Users browsing this forum: No registered users