Page 1 of 1

Newb question about character control

Posted: Fri May 07, 2021 12:42 pm
by regoarrarr
I am exploring creating a mod to control the character and possibly TAS / speedrun. I am aware of

https://github.com/gotyoke/Factorio-AnyPct-TAS

Which did this for version 0.18. I am looking through that mod to see how it works, and running into an issue

it has a section


script.on_event(defines.events.on_tick, function(event)
local p = game.players[1]
....
p.begin_crafting(...)

On my 1.1 copy, this fails with an error

Error while running event tas-speedrun::on_tick (ID 0)
No manual crafter.

After reading a bit, I believe that this is because it starts when the cutscene is running (see viewtopic.php?f=25&t=87938&p=507525 ), so the player is not necessarily a character. I looked to check the controller_type of the player but when I print it out, it's just nil

Can anyone point me to a simple mod that does something like this, or help me know what to check?

Re: Newb question about character control

Posted: Fri May 07, 2021 1:12 pm
by regoarrarr
Okay - I figured out one way to do it - I set up a cutscene_cancelled variable and In the method listening to on_tick, I return out of it if that variable is set to 0. Then I listen to on_cutscene_cancelled and set that variable to 1