[ Solved ]An item fuel that uses energy stored on equipment grid to power vehicles
Re: An item fuel that uses energy stored on equipment grid to power vehicles
Yep it's buffering
Energy: 1.0MJ/1.0MJ
Energy: 1.0MJ/1.0MJ
Re: An item fuel that uses energy stored on equipment grid to power vehicles
Okay, let's try some debugging.
Inside the "onBuilt", just before the "end", insert:
Likewise inside "onMined", add:
This should cause a chat message to appear when you place or remove vehicles. If this works, then the registration part is working fine and the problem lies in the onTick part, so this is a great way to divide up the debugging problem!
Inside the "onBuilt", just before the "end", insert:
Code: Select all
game.print("Registered vehicle "..entity.unit_number)
Code: Select all
game.print("Unregistered vehicle "..entity.unit_number)
Re: An item fuel that uses energy stored on equipment grid to power vehicles
Sir, it's unregistering the vehicles ( I can c their IDs ) but not registering, I think it's something with onBuilt.
Re: An item fuel that uses energy stored on equipment grid to power vehicles
If I remove this line do to a test:
if not (entity and entity.valid and isVehicle(entity)) then return end ( it's in control.lua )
And place a vehicle, I get an error:
O mod ZElectricEngine (0.0.1) causou um erro não recuperável.
Por favor, reporte este erro ao autor do mod.
Error while running event ZElectricEngine::on_built_entity (ID 6)
__ZElectricEngine__/control.lua:21: attempt to index local 'entity' (a nil value)
stack traceback:
__ZElectricEngine__/control.lua:21: in function 'handler'
__core__/lualib/event_handler.lua:47: in function <__core__/lualib/event_handler.lua:45>
if not (entity and entity.valid and isVehicle(entity)) then return end ( it's in control.lua )
And place a vehicle, I get an error:
O mod ZElectricEngine (0.0.1) causou um erro não recuperável.
Por favor, reporte este erro ao autor do mod.
Error while running event ZElectricEngine::on_built_entity (ID 6)
__ZElectricEngine__/control.lua:21: attempt to index local 'entity' (a nil value)
stack traceback:
__ZElectricEngine__/control.lua:21: in function 'handler'
__core__/lualib/event_handler.lua:47: in function <__core__/lualib/event_handler.lua:45>
Re: An item fuel that uses energy stored on equipment grid to power vehicles
Aha, I see.
This line is wrong. It should be:
Whoops!
Code: Select all
local entity = event.entity or event.built_entity
Code: Select all
local entity = event.entity or event.created_entity
Re: An item fuel that uses energy stored on equipment grid to power vehicles
Some good News, It's working perfectly fine as I wanted, I will remove the debugging and change somethings then release it, bro thanks a lot for the help, I'll put your name there haha
Re: An item fuel that uses energy stored on equipment grid to power vehicles
Only one thing I notice is that it drains power while the vehicle isn't used, Is there a way to add a check if player is inside then debit the energy ?
Re: An item fuel that uses energy stored on equipment grid to power vehicles
It's supposed to drain power to fill up the fuel bar. Once the fuel bar is full, "missing" should be 0 so it shouldn't be draining any power.
Might be worth adding this debug line after the "local missing = CAPACITY - ..." line:
That number should start out at a million (1MJ) and gradually drop to 0 as the generator fills the fuel bar. Can you test that?
Might be worth adding this debug line after the "local missing = CAPACITY - ..." line:
Code: Select all
game.print("Vehicle "..car.unit_number.." is missing "..missing.." energy")
Re: An item fuel that uses energy stored on equipment grid to power vehicles
Oh I c, it was my fault sorry, I checked it again and I changed a wrong value, so now it's fully working.
Last edited by N0TZ3R0 on Tue Dec 26, 2023 11:06 pm, edited 1 time in total.
Re: An item fuel that uses energy stored on equipment grid to power vehicles
I feel like I've just accidentally written an entire mod without having Factorio available XD
Re: An item fuel that uses energy stored on equipment grid to power vehicles
Yep sir haha, I'll give u credit when I post it.