Fuel that increase acceleration

Place to get help with not working mods / modding interface.
Post Reply
User avatar
cpy
Filter Inserter
Filter Inserter
Posts: 839
Joined: Thu Jul 31, 2014 5:34 am
Contact:

Fuel that increase acceleration

Post by cpy »

Any idea if there is a way to make fuel that will increase acceleration of trains/cars/tank and perhaps increase max speed?

BurnHard
Filter Inserter
Filter Inserter
Posts: 519
Joined: Mon Oct 21, 2013 5:08 pm
Contact:

Re: Fuel that increase acceleration

Post by BurnHard »

Are you looking for something like the "Back to the Future" Presto-Logs perhaps? :D

http://vignette3.wikia.nocookie.net/btt ... 1005034604
Image
http://vignette1.wikia.nocookie.net/btt ... 0211084131
Image

User avatar
cpy
Filter Inserter
Filter Inserter
Posts: 839
Joined: Thu Jul 31, 2014 5:34 am
Contact:

Re: Fuel that increase acceleration

Post by cpy »

More like nitrous oxide and hydrazine. I have everything prepared, items, recipes and tech. Now i need help how to make them work with trains and cars to give them better acceleration/max speed and not being just fuel.

Xyfi
Inserter
Inserter
Posts: 40
Joined: Tue May 20, 2014 7:10 am
Contact:

Re: Fuel that increase acceleration

Post by Xyfi »

You can use the following Lua/Entity variables to influence speed / fuel consumption:

effectivity_modifier
consumption_modifier
friction_modifier

So you wan't to consume some item (i.e. nitrous oxide) on a button press of something?

User avatar
cpy
Filter Inserter
Filter Inserter
Posts: 839
Joined: Thu Jul 31, 2014 5:34 am
Contact:

Re: Fuel that increase acceleration

Post by cpy »

I would like that but, i absolutely have no idea how to code special fuel slot for trains and cars and bind some buttons to it and work in multiplayer.

Baby steps with just better fuel and then maybe if someone knows how to do it i would, hey maybe someone else would find this useful too then. Thanks for parameter info!

So where do i put this friction_modifier? When I put vehicle_friction_modifier or friction_modifier to my new fuel item it does not seem to do anything.

Xyfi
Inserter
Inserter
Posts: 40
Joined: Tue May 20, 2014 7:10 am
Contact:

Re: Fuel that increase acceleration

Post by Xyfi »

Friction is used to calculate the speed/acceleration (and deceleration?) of a car based on the terrain it's driving on. You can access it for instance by:

Control.lua

Code: Select all

game.on_event(defines.events.on_built_entity, function(event)
   local entity = event.built_entity
   if entity.name == "car" then
     entity.friction_modifier = 0.5
   end
end)
The above code will make a car much faster by reducing friction on all terrains.

It should be possible to access the fuel-inventory of a car, but you can't add an additional inventory. What you could do is access the regular inventory of the car and see if it has a stack of "Nitrous boosts" and consume one and temporarily reduce friction in game.on_tick.

You can access the cars inventories through Lua/Entity.get_inventory(index), but I don't know what inventory is on what index, so you'll have to do some digging.
Last edited by Xyfi on Fri Jul 31, 2015 10:45 am, edited 1 time in total.

User avatar
cpy
Filter Inserter
Filter Inserter
Posts: 839
Joined: Thu Jul 31, 2014 5:34 am
Contact:

Re: Fuel that increase acceleration

Post by cpy »

Wouldn't this modify speed at all times no matter what fuel is used? I want cars and trains to go different speeds depending on fuel used.

I need effect based on fuel type, i can modify car speed once, but that is not point of all this.

Xyfi
Inserter
Inserter
Posts: 40
Joined: Tue May 20, 2014 7:10 am
Contact:

Re: Fuel that increase acceleration

Post by Xyfi »

cpy wrote:Wouldn't this modify speed at all times no matter what fuel is used? I want cars and trains to go different speeds depending on fuel used.

I need effect based on fuel type, i can modify car speed once, but that is not point of all this.
I moddified the post a bit with some extra information.

The problem with making the car go a certain speed for a certain fuel is that you can't access what type of fuel the car is using at the moment.

User avatar
cpy
Filter Inserter
Filter Inserter
Posts: 839
Joined: Thu Jul 31, 2014 5:34 am
Contact:

Re: Fuel that increase acceleration

Post by cpy »

I'll just use old roadworks script for that now. I was hoping there is new mod api for that or something that does not require use of scripts.

Xyfi
Inserter
Inserter
Posts: 40
Joined: Tue May 20, 2014 7:10 am
Contact:

Re: Fuel that increase acceleration

Post by Xyfi »

cpy wrote:I'll just use old roadworks script for that now. I was hoping there is new mod api for that or something that does not require use of scripts.
Hmm, neven seen that mod before, I'll check out it's code for sure.

Update
He pretty much uses what I summed up above, checking the fuel-inventory and adjusting the car's parameters accoringly and rechecking every few ticks. So the speed of the car is based on whatever is in the fuel-inventory rather than the actual fuel it is using.
Last edited by Xyfi on Fri Jul 31, 2015 11:26 am, edited 1 time in total.

User avatar
cpy
Filter Inserter
Filter Inserter
Posts: 839
Joined: Thu Jul 31, 2014 5:34 am
Contact:

Re: Fuel that increase acceleration

Post by cpy »

Looks like game does not know what is game.find_entities_filtered crap.

When roadworks try to call

local entities = game.find_entities_filtered{area = {{carPosition.x - 0.75, carPosition.y - 0.75}, {carPosition.x + 0.75, carPosition.y + 0.75}}, type="simple-entity"}

Xyfi
Inserter
Inserter
Posts: 40
Joined: Tue May 20, 2014 7:10 am
Contact:

Re: Fuel that increase acceleration

Post by Xyfi »

cpy wrote:Looks like game does not know what is game.find_entities_filtered crap.

When roadworks try to call

local entities = game.find_entities_filtered{area = {{carPosition.x - 0.75, carPosition.y - 0.75}, {carPosition.x + 0.75, carPosition.y + 0.75}}, type="simple-entity"}
It has been changed (assuming you mod for .12.1), you have to call find_entities_filtered now on Lua/Surface. You can get the surface via game.surface[1](.find_entities_filtered).

By the way I posted a modding API request for your perticular needs here, let's hope kovarex picks up on it.

User avatar
cpy
Filter Inserter
Filter Inserter
Posts: 839
Joined: Thu Jul 31, 2014 5:34 am
Contact:

Re: Fuel that increase acceleration

Post by cpy »

Where did you read all about those surface changes? Anyway i decided to remove that part of script since factorio now handles surfaces internally and it probably is faster way to do it than use custom script now.

Xyfi
Inserter
Inserter
Posts: 40
Joined: Tue May 20, 2014 7:10 am
Contact:

Re: Fuel that increase acceleration

Post by Xyfi »

I search find_entities_filtered on the wiki and was lead to Lua/Surface.

Post Reply

Return to “Modding help”