[MOD 0.14.2] Electric vehicles

Topics and discussion about specific mods
User avatar
Philip017
Filter Inserter
Filter Inserter
Posts: 355
Joined: Thu Sep 01, 2016 11:21 pm
Contact:

Re: [MOD 0.14.2] Electric vehicles

Post by Philip017 »

hello, i would like to try the mod, but i have made a train and put 2x mk2 batteries and 1 fusion reactor in and still shows no fuel icon, batteries charge very fast and even added the HF coil and i don't understand why it doesn't move? might i recommend some ideas on what is happening in the no fuel icon showing on any tips somewhere in your top postings?

seems there is alot of comments on how these should be implemented, but i just want to play with my new toys and they aren't working?

EDIT:

seriously you have to add a transformer to make it go? gheeze this makes it unnecessarily complicated imo

EDIT 2:

after finally setting up my train and playing with it for a bit, i found it faster (with use of exoskeletons) free to maintain (fusion core, battery combo) and once set i never have to touch it or try and fuel it again. so despite the expense, at first, it is a no maintenance system.

but for those complaining about expense if you are using for personal use, simply change the recipes.lua file to suite whatever cost you feel is appropriate to you. if playing with a friend, share the modified mod, hopefully this isn't gona cause a major issue, but to me i have found if i don't like the cost of the technology, or to craft something, i change it, and go on and enjoy my game.
Last edited by Philip017 on Mon Oct 10, 2016 7:17 pm, edited 1 time in total.

DRT99
Inserter
Inserter
Posts: 25
Joined: Mon Jul 11, 2016 5:11 pm
Contact:

Re: [MOD 0.14.2] Electric vehicles

Post by DRT99 »

Philip017 wrote:hello, i would like to try the mod, but i have made a train and put 2x mk2 batteries and 1 fusion reactor in and still shows no fuel icon, batteries charge very fast and even added the HF coil and i don't understand why it doesn't move? might i recommend some ideas on what is happening in the no fuel icon showing on any tips somewhere in your top postings?

seems there is alot of comments on how these should be implemented, but i just want to play with my new toys and they aren't working?
You need to equip a 'high voltage transformer' on your locomotive

User avatar
Philip017
Filter Inserter
Filter Inserter
Posts: 355
Joined: Thu Sep 01, 2016 11:21 pm
Contact:

Re: [MOD 0.14.2] Electric vehicles

Post by Philip017 »

RE: speed of electric car and tank,

i have found that the car and tank, especially compared to using exoskeletons, to be quite slow,

i have tried to add exoskeletons to my tank and found that it makes it turn faster, but not move faster.

can anyone give me a tip on how to change this function so i can have my tank move a bit faster?

ps i found out how to change the top speed of my locomotive, and now it FLYS! wohoo!

Darloth
Fast Inserter
Fast Inserter
Posts: 117
Joined: Sun Jun 08, 2014 3:57 pm
Contact:

Re: [MOD 0.14.2] Electric vehicles

Post by Darloth »

Is there any chance that these vehicles could, if Bob's vehicle equipment mod is installed, also accept bob's vehicle equipment please?

Supercheese
Filter Inserter
Filter Inserter
Posts: 841
Joined: Mon Sep 14, 2015 7:40 am
Contact:

Re: [MOD 0.14.2] Electric vehicles

Post by Supercheese »

Hello, I'm the author of the Vehicle Wagon mod, and I & some users have noticed bugs when using both Electric Vehicles and Vehicle Wagon together.

Since my mod uses the entity.destroy() method for deleting vehicles, I believe it isn't detected by the tests for invalid entities in your Electric Vehicles Lib code. As such, the next tick after winching a powered electric vehicle onto a wagon, the on_tick function crashes since the electric vehicle no longer exists.

Furthermore, it also seems that if a completely empty electric vehicle is winched onto a wagon, the game won't crash, but when it's winched off again and one goes to try and edit the equipment grid, the script crashes again, presumably because it still believes the old, pre-winch car is still a valid entity, which it is not.

It seems an extra test for invalid entities needs to be performed in your on_tick function before entering the fuel_tick() routine (or perhaps during on_train_changed_state, because the process of winching vehicles inevitable causes train state changes since wagons are deleted and re-attached).

Steps to reproduce:
  • Start a new Sandbox game with Vehicle Wagon, Electric Vehicles, and Electric Vehicles Lib loaded.
  • Accept all the cheats/freebies that pop up
  • Build some rails, a Vehicle Wagon, an Electric Car/Tank, and a winch
  • Craft a fusion reactor and transformer and put them in the Electric Car/Tank
  • Attempt to winch the car/tank onto the wagon
The Electric Vehicles Lib script should now crash on the fuel_tick() function.

mknejp
Fast Inserter
Fast Inserter
Posts: 154
Joined: Wed Apr 27, 2016 8:29 pm
Contact:

Re: [MOD 0.14.2] Electric vehicles

Post by mknejp »

Sigh. I wish there were events for when entities get destroyed or created by mods so we don't have to check for validity all the frickin' time. I'll have a look into this. Thanks for letting me know.

User avatar
aubergine18
Smart Inserter
Smart Inserter
Posts: 1264
Joined: Fri Jul 22, 2016 8:51 pm
Contact:

Re: [MOD 0.14.2] Electric vehicles

Post by aubergine18 »

An alternative would be to raise events inside the mod that's destroying/creating the entities. For example:

Destroy:

Code: Select all

local _died = defines.events.entity_died

local data = {
  entity = entity,
  tick = game.tick,
  name = _died
}

game.raise_event( _died, data )

entity.destroy()
Create:

Code: Select all

local _built = defines.events.entity_built

local entity = someSurface.create_entity { .... }

local data = {
  created_entity = entity,
  player_index = <playerId>, -- ?
  tick = game.tick,
  name = _built
}

game.raise_event( _built, data )
Assuming you store a bunch of infos about destroyed entity, in order to recreate it, just add the .last_user to that store and use that for <playerId>...?
Last edited by aubergine18 on Fri Oct 21, 2016 11:49 am, edited 1 time in total.
Better forum search for modders: Enclose your search term in quotes, eg. "font_color" or "custom-input" - it prevents the forum search from splitting on hypens and underscores, resulting in much more accurate results.

mknejp
Fast Inserter
Fast Inserter
Posts: 154
Joined: Wed Apr 27, 2016 8:29 pm
Contact:

Re: [MOD 0.14.2] Electric vehicles

Post by mknejp »

It's no so straight forward because there are assumptions around these events, like the player having a free slot in their inventory after building an entity, so you know you can put the item back and so on. And if a mod tracks killed entities than calling these events can skew with statistics and all kinds of hilarious things. It's generally a bad idea to raise built-in events triggered by the game logic.

User avatar
Optera
Smart Inserter
Smart Inserter
Posts: 2915
Joined: Sat Jun 11, 2016 6:41 am
Contact:

Re: [MOD 0.14.2] Electric vehicles

Post by Optera »

Can't lua throw on_pre_mined and on_build events when destroying or creating things?
Last edited by Optera on Fri Oct 21, 2016 12:55 pm, edited 2 times in total.

User avatar
aubergine18
Smart Inserter
Smart Inserter
Posts: 1264
Joined: Fri Jul 22, 2016 8:51 pm
Contact:

Re: [MOD 0.14.2] Electric vehicles

Post by aubergine18 »

Optera wrote:Can't lua throw on_pre_mined and on_build events when destroying or creating things?
Yes, but only if the mod specifically raises the events.

The vanilla events aren't triggered when mods do create/destroy, as that could easily create recursive loops and is just generally messy. So if mod wants to let other mods know something happened, it has to manually game.raise_event() or remote.call()
Better forum search for modders: Enclose your search term in quotes, eg. "font_color" or "custom-input" - it prevents the forum search from splitting on hypens and underscores, resulting in much more accurate results.

User avatar
Optera
Smart Inserter
Smart Inserter
Posts: 2915
Joined: Sat Jun 11, 2016 6:41 am
Contact:

Re: [MOD 0.14.2] Electric vehicles

Post by Optera »

If game.raise_event() or remote.call() can trigger built in events for destroy/building we should start using them more so we don't have to do valid checks all time.

User avatar
aubergine18
Smart Inserter
Smart Inserter
Posts: 1264
Joined: Fri Jul 22, 2016 8:51 pm
Contact:

Re: [MOD 0.14.2] Electric vehicles

Post by aubergine18 »

Optera wrote:If game.raise_event() or remote.call() can trigger built in events for destroy/building we should start using them more so we don't have to do valid checks all time.
First, not without something like this so mods know whether the event is vanilla or modded.

Also, even if mods did start raising the normal game events, there are still myriad of issues:

1. Not all mods will do it
2. They might do it wrong
3. There's often multiple ways for something to happen

You'd have to be 100% sure that all other mods were working perfectly *and* that your mod is handing all situations properly.

For example, if a player disconnects from an MP game, you get an event aobut that, but might not realise it affects the entities your mod provides. Or what about forces merging? There's a whole bunch of things that at first might seem unrelated, but they can all affect entities in unexpected ways. The .valid flag (and .connected for player) is the most reliable way to know if something is actually still valid.

That being said, it would still be useful if mods raised events when they did stuff (even just custom events, doesn't have to be vanilla clones) :)
Better forum search for modders: Enclose your search term in quotes, eg. "font_color" or "custom-input" - it prevents the forum search from splitting on hypens and underscores, resulting in much more accurate results.

User avatar
Optera
Smart Inserter
Smart Inserter
Posts: 2915
Joined: Sat Jun 11, 2016 6:41 am
Contact:

Re: [MOD 0.14.2] Electric vehicles

Post by Optera »

aubergine18 wrote:
Optera wrote:If game.raise_event() or remote.call() can trigger built in events for destroy/building we should start using them more so we don't have to do valid checks all time.
First, not without something like this so mods know whether the event is vanilla or modded.

Also, even if mods did start raising the normal game events, there are still myriad of issues:

1. Not all mods will do it
2. They might do it wrong
3. There's often multiple ways for something to happen

You'd have to be 100% sure that all other mods were working perfectly *and* that your mod is handing all situations properly.

For example, if a player disconnects from an MP game, you get an event aobut that, but might not realise it affects the entities your mod provides. Or what about forces merging? There's a whole bunch of things that at first might seem unrelated, but they can all affect entities in unexpected ways. The .valid flag (and .connected for player) is the most reliable way to know if something is actually still valid.

That being said, it would still be useful if mods raised events when they did stuff (even just custom events, doesn't have to be vanilla clones) :)
I like the idea. Hope it will find it's way into the api.
There is no such a thing as 100% perfect code. Being able to sort out base and by mod name we could however make sure to handle only events from mods we know to work well enough.

mknejp
Fast Inserter
Fast Inserter
Posts: 154
Joined: Wed Apr 27, 2016 8:29 pm
Contact:

Re: [MOD 0.14.2] Electric vehicles

Post by mknejp »

Supercheese wrote:Hello, I'm the author of the Vehicle Wagon mod, and I & some users have noticed bugs when using both Electric Vehicles and Vehicle Wagon together.

Since my mod uses the entity.destroy() method for deleting vehicles, I believe it isn't detected by the tests for invalid entities in your Electric Vehicles Lib code. As such, the next tick after winching a powered electric vehicle onto a wagon, the on_tick function crashes since the electric vehicle no longer exists.

Furthermore, it also seems that if a completely empty electric vehicle is winched onto a wagon, the game won't crash, but when it's winched off again and one goes to try and edit the equipment grid, the script crashes again, presumably because it still believes the old, pre-winch car is still a valid entity, which it is not.

It seems an extra test for invalid entities needs to be performed in your on_tick function before entering the fuel_tick() routine (or perhaps during on_train_changed_state, because the process of winching vehicles inevitable causes train state changes since wagons are deleted and re-attached).

Steps to reproduce:
  • Start a new Sandbox game with Vehicle Wagon, Electric Vehicles, and Electric Vehicles Lib loaded.
  • Accept all the cheats/freebies that pop up
  • Build some rails, a Vehicle Wagon, an Electric Car/Tank, and a winch
  • Craft a fusion reactor and transformer and put them in the Electric Car/Tank
  • Attempt to winch the car/tank onto the wagon
The Electric Vehicles Lib script should now crash on the fuel_tick() function.
Hmm this brings up a new problem though. When you re-create the vehicle using surface.create_entity() the car won't work because it is dependent on on_built_entity to associate the entity with the equipment grid and there's no way I'm aware of to find the entity containing the grid if you only know about the grid.

User avatar
aubergine18
Smart Inserter
Smart Inserter
Posts: 1264
Joined: Fri Jul 22, 2016 8:51 pm
Contact:

Re: [MOD 0.14.2] Electric vehicles

Post by aubergine18 »

Concocted a possible solution that mods can use when creating/destroying external entities: https://github.com/aubergine10/lifecycle-events
Better forum search for modders: Enclose your search term in quotes, eg. "font_color" or "custom-input" - it prevents the forum search from splitting on hypens and underscores, resulting in much more accurate results.

mknejp
Fast Inserter
Fast Inserter
Posts: 154
Joined: Wed Apr 27, 2016 8:29 pm
Contact:

Re: [MOD 0.14.2] Electric vehicles

Post by mknejp »

The errors related to Vehicle Wagons should be fixed in 0.3.5

GotLag
Filter Inserter
Filter Inserter
Posts: 532
Joined: Sat May 03, 2014 3:32 pm
Contact:

Re: [MOD 0.14.2] Electric vehicles

Post by GotLag »

The regenerative braking module seems to produce far more energy than is required to accelerate. After providing some initial energy I can "charge" the regen and transformer modules by spamming W and S while driving the train. All aboard for free energy!

Apart from that I am loving this mod - by installing 14 radioisotope thermoelectric generators from Reactors, I have nuclear trains!

Edit, more feedaback: In my opinion the sound idle1.ogg is less intrusive and more fitting for an electric locomotive. Also, why'd you remove the air brake puffs on stopping?

mknejp
Fast Inserter
Fast Inserter
Posts: 154
Joined: Wed Apr 27, 2016 8:29 pm
Contact:

Re: [MOD 0.14.2] Electric vehicles

Post by mknejp »

GotLag wrote:The regenerative braking module seems to produce far more energy than is required to accelerate. After providing some initial energy I can "charge" the regen and transformer modules by spamming W and S while driving the train. All aboard for free energy!
Blame Factorio's weird physics. The brake works the way it does to balance against the ridiculous consumption maths and meant for automatic trains. If you're dedicated enough to drive like that you deserve the free energy.
GotLag wrote:Edit, more feedaback: In my opinion the sound idle1.ogg is less intrusive and more fitting for an electric locomotive. Also, why'd you remove the air brake puffs on stopping?
I don't want it to look "steamy". Besides air is invisible :)

Iorek
Inserter
Inserter
Posts: 41
Joined: Wed Sep 07, 2016 4:09 pm
Contact:

Re: [MOD 0.14.2] Electric vehicles

Post by Iorek »

to make "bobs mods" modules work on your electric car/train/tank do I need to add his equipment categories to each vehicle?


Any chance you can give the tank a nice "Clean" "Green" "environmentally friendly" electric LASER BEAM OF DOOM, to replace those dirty cannon shells and polluting bullets? :)

User avatar
hitzu
Filter Inserter
Filter Inserter
Posts: 530
Joined: Tue Sep 09, 2014 5:55 pm
Contact:

Re: [MOD 0.14.2] Electric vehicles

Post by hitzu »

So you want an envorenmentally friendly way of the species extermination, don't you?

Post Reply

Return to “Mods”