Page 4 of 19
Re: [Mod 0.11.x] Rail Tanker - Liquid transport
Posted: Wed Dec 10, 2014 4:22 am
by JamesOFarrell
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.
Re: [Mod 0.11.x] Rail Tanker - Liquid transport
Posted: Wed Dec 10, 2014 6:01 am
by n9103
I do believe you mis-attributed that 1st quote
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.
Re: [Mod 0.11.x] Rail Tanker - Liquid transport
Posted: Wed Dec 10, 2014 6:28 am
by JamesOFarrell
n9103 wrote:I do believe you mis-attributed that 1st quote
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.
Re: [Mod 0.11.x] Rail Tanker - Liquid transport
Posted: Wed Dec 10, 2014 8:47 am
by berni1212
JamesOFarrell wrote:n9103 wrote:I do believe you mis-attributed that 1st quote
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 :=)
Re: [Mod 0.11.x] Rail Tanker - Liquid transport
Posted: Wed Dec 10, 2014 10:38 am
by MasterBuilder
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()
Re: [Mod 0.11.x] Rail Tanker - Liquid transport
Posted: Wed Dec 10, 2014 7:27 pm
by JamesOFarrell
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
Re: [Mod 0.11.x] Rail Tanker - Liquid transport
Posted: Wed Dec 10, 2014 7:32 pm
by berni1212
Re: [Mod 0.11.x] Rail Tanker - Liquid transport
Posted: Wed Dec 10, 2014 7:36 pm
by JamesOFarrell
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.
Re: [Mod 0.11.x] Rail Tanker - Liquid transport
Posted: Wed Dec 10, 2014 8:32 pm
by berni1212
JamesOFarrell wrote:
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
? because they are so cheap
Re: [Mod 0.11.x] Rail Tanker - Liquid transport
Posted: Mon Dec 15, 2014 1:45 pm
by Lambert2191
(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)
Re: [Mod 0.11.x] Rail Tanker - Liquid transport
Posted: Mon Dec 15, 2014 7:09 pm
by JamesOFarrell
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
Re: [Mod 0.11.x] Rail Tanker - Liquid transport
Posted: Wed Dec 17, 2014 11:39 am
by AlphaRaptor
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
Re: [Mod 0.11.x] Rail Tanker - Liquid transport
Posted: Wed Dec 17, 2014 11:57 am
by JamesOFarrell
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.
Re: [Mod 0.11.x] Rail Tanker - Liquid transport
Posted: Wed Dec 17, 2014 12:01 pm
by AlphaRaptor
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
Re: Request for interface
Posted: Mon Dec 22, 2014 4:40 pm
by Choumiko
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
Re: [Mod 0.11.x] Rail Tanker - Liquid transport
Posted: Wed Dec 24, 2014 12:32 pm
by Narc
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.
Re: [Mod 0.11.x] Rail Tanker - Liquid transport
Posted: Wed Dec 24, 2014 2:44 pm
by Choumiko
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
Re: Request for interface
Posted: Thu Jan 01, 2015 8:53 pm
by JamesOFarrell
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.
Re: Request for interface
Posted: Sun Jan 04, 2015 3:18 pm
by Choumiko
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?
Re: Request for interface
Posted: Sun Jan 04, 2015 6:46 pm
by JamesOFarrell
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.