[SOLVED] Train cruise control

Place to get help with not working mods / modding interface.
User avatar
pandapurpletail
Burner Inserter
Burner Inserter
Posts: 5
Joined: Mon Aug 29, 2016 9:23 am
Contact:

[SOLVED] Train cruise control

Post by pandapurpletail »

I tryed to find any usefull information to how make it correct using .acceleration etc. But can't understood how it works.
So I want to make the train with player inside going by itself on cruise speed, which can be add by button "W" to max and "S" to min. Any ideas or suggestions please. Thanks. Or simply how to set the train.acceleration.whatever

P.S. Yeah, thanks guys for a huge help and useful tips! (NO). So i figuered it out by myself. If someone or somehow will need it for future here is a tip. This makes train automatically goes on certain level of speed in a set direction (1 is for none forward direction)

Code: Select all

script.on_event(defines.events.on_tick, function(event) 
for _, player in pairs(game.players) do
-- do it every tick (i mean how often.. aka speed)
if game.tick % 10 == 0 then
player.riding_state = {direction=1, acceleration=1};
end
end
end)
Last edited by pandapurpletail on Tue Aug 30, 2016 2:38 pm, edited 9 times in total.
Nexela
Smart Inserter
Smart Inserter
Posts: 1828
Joined: Wed May 25, 2016 11:09 am
Contact:

Re: Train cruise control

Post by Nexela »

take a look at how farl does it in farl.lua (search for cruise to get all the relevant stuff)
User avatar
pandapurpletail
Burner Inserter
Burner Inserter
Posts: 5
Joined: Mon Aug 29, 2016 9:23 am
Contact:

Re: Train cruise control

Post by pandapurpletail »

Nexela wrote:take a look at how farl does it in farl.lua (search for cruise to get all the relevant stuff)
I did! But can't understand that, too complicated. I thought maybe i can make it easier, from some simple event, not going crazy-hard-coding way
User avatar
LuziferSenpai
Filter Inserter
Filter Inserter
Posts: 386
Joined: Tue Jul 08, 2014 10:06 am
Contact:

Re: Train cruise control

Post by LuziferSenpai »

pandapurpletail wrote:
Nexela wrote:take a look at how farl does it in farl.lua (search for cruise to get all the relevant stuff)
I did! But can't understand that, too complicated. I thought maybe i can make it easier, from some simple event, not going crazy-hard-coding way
Choumiko makes the easyer ways ;)

If its too complicated for you, than first learn more about functions, and Lua than look in to that ;)
Coding is awesome!
Animes are love!
Factorio is life!

My MODs:
Click

Greetz,

Senpai
User avatar
pandapurpletail
Burner Inserter
Burner Inserter
Posts: 5
Joined: Mon Aug 29, 2016 9:23 am
Contact:

Re: Train cruise control

Post by pandapurpletail »

If its too complicated for you, than first learn more about functions, and Lua than look in to that ;)
Yeah.. I guess... I dont know how other people scripting, but factorio lua wiki has some outdated articles.
User avatar
pandapurpletail
Burner Inserter
Burner Inserter
Posts: 5
Joined: Mon Aug 29, 2016 9:23 am
Contact:

Re: [SOLVED] Train cruise control

Post by pandapurpletail »

Thanks guys, problem sovled!
Post Reply

Return to “Modding help”