[MOD 0.15|0.14] Rail Tanker - Liquid transport 1.4.1

Topics and discussion about specific mods
Post Reply
JamesOFarrell
Filter Inserter
Filter Inserter
Posts: 402
Joined: Fri May 23, 2014 8:54 am
Contact:

Re: [Mod 0.11.x] Rail Tanker - Liquid transport

Post by JamesOFarrell » Wed Dec 10, 2014 4:22 am

The Lone Wolfling wrote:Two things - for quick-and-dirty "I need oil now so I'm just going to use a car" (liquid transport by car, please?), and for the nuclear power mod.

If it weren't for nuclear power requiring it, I'd try to remove the item altogether.

(On a related note - a modular car / tank would be awesome. Especially if it added the ability to have liquid storage parts in it, either for fuel or for tankage.)

Also, is there any way you can indicate in some way the amount that is in a tanker car when it is moving?
Someone is making a modular tank I think. The car would be cool but I woudl never use it. I rarely find myself moving things manually.

I was thinking about that problem and there is no easy solution. I could teleport the storage tanker instead of deleting it but the game would slow down quite a lot once you got a few tankers in use. The other option is to add support to TheFatController so it can display how much liquid is in it. I'll probably do that at some point anyway, when I get motivated enough to work on it.
n9103 wrote:Why wouldn't an OnEntityDied call work to remove the associated storage tank?
Ok,I responded to this but managed to delete it some how. The storage tanker never dies so it doesn't fire the event. There were other ways to fix the issue but this seem to have sorted it out. Someone pointed out that it should should have worked the way I had it so now I'm not sure whats going on.
Last edited by JamesOFarrell on Wed Dec 10, 2014 6:26 am, edited 1 time in total.

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

Re: [Mod 0.11.x] Rail Tanker - Liquid transport

Post by n9103 » Wed Dec 10, 2014 6:01 am

I do believe you mis-attributed that 1st quote :shock:

As for the call, I was referring to when the RailTanker dies, to use the OnEntityDied event to trigger deleting the associated storage tank.
If that's what you responded to, then I guess nevermind.
Sorry to hear that the script's not behaving as documented. Seems a few things have been changing since the devs last API documentation.
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.

JamesOFarrell
Filter Inserter
Filter Inserter
Posts: 402
Joined: Fri May 23, 2014 8:54 am
Contact:

Re: [Mod 0.11.x] Rail Tanker - Liquid transport

Post by JamesOFarrell » Wed Dec 10, 2014 6:28 am

n9103 wrote:I do believe you mis-attributed that 1st quote :shock:

As for the call, I was referring to when the RailTanker dies, to use the OnEntityDied event to trigger deleting the associated storage tank.
If that's what you responded to, then I guess nevermind.
Sorry to hear that the script's not behaving as documented. Seems a few things have been changing since the devs last API documentation.
i did indeed. Not sure what happened there. That's where the issue came from. The entity passed to OnEntitiDIed was valid but not the references I stored to it in the lua table.

As for the lua docs, they need someone to go through them. FreeER used to keep them up to date but no one has spent time to put in all the 0.11 changes.

User avatar
berni1212
Fast Inserter
Fast Inserter
Posts: 137
Joined: Sun Dec 07, 2014 8:52 am
Contact:

Re: [Mod 0.11.x] Rail Tanker - Liquid transport

Post by berni1212 » Wed Dec 10, 2014 8:47 am

JamesOFarrell wrote:
n9103 wrote:I do believe you mis-attributed that 1st quote :shock:

As for the call, I was referring to when the RailTanker dies, to use the OnEntityDied event to trigger deleting the associated storage tank.
If that's what you responded to, then I guess nevermind.
Sorry to hear that the script's not behaving as documented. Seems a few things have been changing since the devs last API documentation.
i did indeed. Not sure what happened there. That's where the issue came from. The entity passed to OnEntitiDIed was valid but not the references I stored to it in the lua table.

As for the lua docs, they need someone to go through them. FreeER used to keep them up to date but no one has spent time to put in all the 0.11 changes.

I don't understand anything from that LOL :(

Btw your mod works with other Fluids too like LAVA :=)
Sorry for my bad English ! i will not remove it !
WIP Test MODS
RailTanker [MP WIP]

User avatar
MasterBuilder
Filter Inserter
Filter Inserter
Posts: 292
Joined: Sun Nov 23, 2014 1:22 am
Contact:

Re: [Mod 0.11.x] Rail Tanker - Liquid transport

Post by MasterBuilder » Wed Dec 10, 2014 10:38 am

JamesOFarrell wrote:i did indeed. Not sure what happened there. That's where the issue came from. The entity passed to OnEntitiDIed was valid but not the references I stored to it in the lua table.

As for the lua docs, they need someone to go through them. FreeER used to keep them up to date but no one has spent time to put in all the 0.11 changes.
My two cents as a programmer: (I haven't really touched lua since homeworld2 and I haven't had to do anything for factorio so I could be completely wrong.

Given that the event is 'OnEntityDied' and not 'OnEntityDying' I would hazard a guess that the entity would already have whatever changes 'death' would apply to them. This might cause the entity to already be invalid.
Now I don't know how the game threads things so the event may update the actual entity then use a cached, valid, copy of that entity for the event so used can actually get info from the entity that was destroyed.

Since the .equals method in the wiki has this "The only method that can be called on non-valid entity object."
I would imaging looping through and using .equals() should be able to find the proper entry.
(Or maybe if your list is storing a copy and not a reference to the entity these changes might be enough for the .equals() method to consider them different objects?)

If not, wouldn't looping though the whole entity array and removing any invalid reference work?

PS: It's times like this that I wish lua could so things like .indexOf()
Give a man fire and he'll be warm for a day. Set a man on fire and he'll be warm for the rest of his life.

JamesOFarrell
Filter Inserter
Filter Inserter
Posts: 402
Joined: Fri May 23, 2014 8:54 am
Contact:

Re: [Mod 0.11.x] Rail Tanker - Liquid transport

Post by JamesOFarrell » Wed Dec 10, 2014 7:27 pm

MasterBuilder wrote:
JamesOFarrell wrote:i did indeed. Not sure what happened there. That's where the issue came from. The entity passed to OnEntitiDIed was valid but not the references I stored to it in the lua table.

As for the lua docs, they need someone to go through them. FreeER used to keep them up to date but no one has spent time to put in all the 0.11 changes.
My two cents as a programmer: (I haven't really touched lua since homeworld2 and I haven't had to do anything for factorio so I could be completely wrong.

Given that the event is 'OnEntityDied' and not 'OnEntityDying' I would hazard a guess that the entity would already have whatever changes 'death' would apply to them. This might cause the entity to already be invalid.
Now I don't know how the game threads things so the event may update the actual entity then use a cached, valid, copy of that entity for the event so used can actually get info from the entity that was destroyed.

Since the .equals method in the wiki has this "The only method that can be called on non-valid entity object."
I would imaging looping through and using .equals() should be able to find the proper entry.
(Or maybe if your list is storing a copy and not a reference to the entity these changes might be enough for the .equals() method to consider them different objects?)

If not, wouldn't looping though the whole entity array and removing any invalid reference work?

PS: It's times like this that I wish lua could so things like .indexOf()
So this is how rail tankers works. The issue was that if I called validentity.equals(invalidentity) it errored out. Changing this to invalidentity.equals(validentity) fixed the issue. Someone has since pointed out that it shouldn't matter which way around they are but apparently it does.

indexOf() would be really handy as would ordered non-index lists but we cant have everything :D

User avatar
berni1212
Fast Inserter
Fast Inserter
Posts: 137
Joined: Sun Dec 07, 2014 8:52 am
Contact:

Re: [Mod 0.11.x] Rail Tanker - Liquid transport

Post by berni1212 » Wed Dec 10, 2014 7:32 pm

I don't know what you Guys Talk LOL :D

I am Happy that the mod Works we have it now in use on an 20H map with about 30 mods or so and it works Perfect no Problems at all :mrgreen: :mrgreen: :mrgreen: :mrgreen:



Thanks for that Great Mod :)

I hope you Continoue with this mod and could add more to it :) like Bigger RailTanker or something else :)
Sorry for my bad English ! i will not remove it !
WIP Test MODS
RailTanker [MP WIP]

JamesOFarrell
Filter Inserter
Filter Inserter
Posts: 402
Joined: Fri May 23, 2014 8:54 am
Contact:

Re: [Mod 0.11.x] Rail Tanker - Liquid transport

Post by JamesOFarrell » Wed Dec 10, 2014 7:36 pm

berni1212 wrote:I don't know what you Guys Talk LOL :D

I am Happy that the mod Works we have it now in use on an 20H map with about 30 mods or so and it works Perfect no Problems at all :mrgreen: :mrgreen: :mrgreen: :mrgreen:



Thanks for that Great Mod :)

I hope you Continoue with this mod and could add more to it :) like Bigger RailTanker or something else :)

I think I'll release a stainless steal version (based on the stainless steal wagons mod) as a separate download that will have 5000 liquid in it. That way people like myself who don't use dytech can keep their game uncluttered.

User avatar
berni1212
Fast Inserter
Fast Inserter
Posts: 137
Joined: Sun Dec 07, 2014 8:52 am
Contact:

Re: [Mod 0.11.x] Rail Tanker - Liquid transport

Post by berni1212 » Wed Dec 10, 2014 8:32 pm

JamesOFarrell wrote:
berni1212 wrote:I don't know what you Guys Talk LOL :D

I am Happy that the mod Works we have it now in use on an 20H map with about 30 mods or so and it works Perfect no Problems at all :mrgreen: :mrgreen: :mrgreen: :mrgreen:



Thanks for that Great Mod :)

I hope you Continoue with this mod and could add more to it :) like Bigger RailTanker or something else :)

I think I'll release a stainless steal version (based on the stainless steal wagons mod) as a separate download that will have 5000 liquid in it. That way people like myself who don't use dytech can keep their game uncluttered.
That would be cool :) can u make it so that u need something else too not only the Steel :D ? because they are so cheap :D :mrgreen: :mrgreen:
Sorry for my bad English ! i will not remove it !
WIP Test MODS
RailTanker [MP WIP]

Lambert2191
Manual Inserter
Manual Inserter
Posts: 1
Joined: Thu Nov 20, 2014 4:22 pm
Contact:

Re: [Mod 0.11.x] Rail Tanker - Liquid transport

Post by Lambert2191 » Mon Dec 15, 2014 1:45 pm

(X/Post from factorio subreddit)

I'm using the Railtanker mod (amongst others) and I have run into a problem. I had a train with 1 engine, and 2 tankers, I used V to cut the link between them all and then some time later tried to remove them. The engine and the centre tanker were removed with no problem, but on the last tanker I keep getting [this error](http://steamcommunity.com/sharedfiles/f ... =356590060)

JamesOFarrell
Filter Inserter
Filter Inserter
Posts: 402
Joined: Fri May 23, 2014 8:54 am
Contact:

Re: [Mod 0.11.x] Rail Tanker - Liquid transport

Post by JamesOFarrell » Mon Dec 15, 2014 7:09 pm

Lambert2191 wrote:(X/Post from factorio subreddit)

I'm using the Railtanker mod (amongst others) and I have run into a problem. I had a train with 1 engine, and 2 tankers, I used V to cut the link between them all and then some time later tried to remove them. The engine and the centre tanker were removed with no problem, but on the last tanker I keep getting [this error](http://steamcommunity.com/sharedfiles/f ... =356590060)
This is fixed in 0.0.7

User avatar
AlphaRaptor
Fast Inserter
Fast Inserter
Posts: 102
Joined: Wed Dec 03, 2014 6:58 pm
Contact:

Re: [Mod 0.11.x] Rail Tanker - Liquid transport

Post by AlphaRaptor » Wed Dec 17, 2014 11:39 am

Hello JamesOFarrell

Since ssilk posted this, and i thank him for doing it , i have a Question.

Am I allowed to use your Mod in my Modpack.
Its a Simple Question with a Simply Answer , "Yes" or "no" , If you say "no" then give me Please a Reason like (: i dont want my mod in a modpack with other Mods) thats enough.

Thanks for Reading :)
Live your life like you want.
Mods are still Awesome , and i love Mods , for every Game.

Lov'in it.

JamesOFarrell
Filter Inserter
Filter Inserter
Posts: 402
Joined: Fri May 23, 2014 8:54 am
Contact:

Re: [Mod 0.11.x] Rail Tanker - Liquid transport

Post by JamesOFarrell » Wed Dec 17, 2014 11:57 am

AlphaRaptor wrote:Hello JamesOFarrell

Since ssilk posted this, and i thank him for doing it , i have a Question.

Am I allowed to use your Mod in my Modpack.
Its a Simple Question with a Simply Answer , "Yes" or "no" , If you say "no" then give me Please a Reason like (: i dont want my mod in a modpack with other Mods) thats enough.

Thanks for Reading :)
Sure, it is MIT licensed so you can use it how ever you want.

User avatar
AlphaRaptor
Fast Inserter
Fast Inserter
Posts: 102
Joined: Wed Dec 03, 2014 6:58 pm
Contact:

Re: [Mod 0.11.x] Rail Tanker - Liquid transport

Post by AlphaRaptor » Wed Dec 17, 2014 12:01 pm

JamesOFarrell wrote:
AlphaRaptor wrote:Hello JamesOFarrell

Since ssilk posted this, and i thank him for doing it , i have a Question.

Am I allowed to use your Mod in my Modpack.
Its a Simple Question with a Simply Answer , "Yes" or "no" , If you say "no" then give me Please a Reason like (: i dont want my mod in a modpack with other Mods) thats enough.

Thanks for Reading :)
Sure, it is MIT licensed so you can use it how ever you want.
Thank you :D
Live your life like you want.
Mods are still Awesome , and i love Mods , for every Game.

Lov'in it.

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

Re: Request for interface

Post by Choumiko » Mon Dec 22, 2014 4:40 pm

Could you add an interface for other mods to get the stored liquid when the train is stopped? I managed to get the following to work: (added at the end of control.lua)

Code: Select all

remote.addinterface("railtanker",
{
  getLiquidByWagon = function(wagon)
    local tanker = getTankerFromEntity(glob.tankers, wagon)
    local res = nil
    reattachProxy(tanker)
    if tanker.entity.name == "rail-tanker" then
        if tanker.proxy ~= nil then
            if tanker.proxy.fluidbox[1] ~= nil then
                res = {amount = tanker.proxy.fluidbox[1].amount, type = tanker.proxy.fluidbox[1].type}
            else
                res = {amount = 0, type = nil}
            end
        else
            if tanker.fluidbox ~= nil then
                res = {amount = tanker.fluidbox.amount, type = tanker.fluidbox.type}
            else
                res = {amount = 0, type = nil}
            end
        end
    end
    return res
  end
}
Should even work when the train is moving, not sure though, i simply tried until it worked
While looking at your code i think i found a typo: Line 42 is tanker.proxy = bil should be nil i guess ;)

User avatar
Narc
Filter Inserter
Filter Inserter
Posts: 278
Joined: Mon Feb 11, 2013 7:25 am
Contact:

Re: [Mod 0.11.x] Rail Tanker - Liquid transport

Post by Narc » Wed Dec 24, 2014 12:32 pm

I noticed v0.0.7 restored the tiny size of the invisible tank -- problem is, I rather liked the larger one, as it made it easier to check on the tanker car's contents.

Also, is there any way to force the invisible tank to align to grid? I haven't looked into Factorio modding at all, but it really should be feasible.

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

Re: [Mod 0.11.x] Rail Tanker - Liquid transport

Post by Choumiko » Wed Dec 24, 2014 2:44 pm

Narc wrote:Also, is there any way to force the invisible tank to align to grid? I haven't looked into Factorio modding at all, but it really should be feasible.
There is a way, but i think he doesn't use it because of the whole "Wagons have different length depending on their direction" thing: https://forums.factorio.com/forum/vie ... =23&t=4083
or it's just because rails are 2 tiles wide and the tank needs to be centered to be accesible from both sides?To sum up: I'm sure there is a reason ;)

JamesOFarrell
Filter Inserter
Filter Inserter
Posts: 402
Joined: Fri May 23, 2014 8:54 am
Contact:

Re: Request for interface

Post by JamesOFarrell » Thu Jan 01, 2015 8:53 pm

Choumiko wrote:Could you add an interface for other mods to get the stored liquid when the train is stopped?
Sorry, I was away for xmas. This has been added in v0.0.8.
Narc wrote:I noticed v0.0.7 restored the tiny size of the invisible tank -- problem is, I rather liked the larger one, as it made it easier to check on the tanker car's contents.
You can change this by editing prototypes\entity\entities.lua. Lines 59 and 119 need to be uncommentated and you need to comment line 60 and 118
Narc wrote:Also, is there any way to force the invisible tank to align to grid? I haven't looked into Factorio modding at all, but it really should be feasible.
Nothing good comes from aligning the thing to the grid, as trains can move less than a tiles space things go funky. There are better solutions than the one I've chosen and I'll eventually change it but for the moment it works.

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

Re: Request for interface

Post by Choumiko » Sun Jan 04, 2015 3:18 pm

No worries, that's what i assumed.
Thanks for adding the interface. As you are also the dev of FatController: Have you already considered using it to show the liquid in your Traininfo like it does for items? ;)

JamesOFarrell
Filter Inserter
Filter Inserter
Posts: 402
Joined: Fri May 23, 2014 8:54 am
Contact:

Re: Request for interface

Post by JamesOFarrell » Sun Jan 04, 2015 6:46 pm

Choumiko wrote:No worries, that's what i assumed.
Thanks for adding the interface. As you are also the dev of FatController: Have you already considered using it to show the liquid in your Traininfo like it does for items? ;)
Indeed I have. That was the plan but I lost motivation to mod when all my saves became corrupted. Hopefully I'll get to it soon.

Post Reply

Return to “Mods”

Who is online

Users browsing this forum: Aerropagus, ruy222