Coder Social home page Coder Social logo

factorio-tas-playback's Introduction

factorio-tas-playback

TAS playback mod for factorio

Installing the mod

  • If using git : clone to factorio/mods/tas_playback_0.0.2
  • If using an archive : Unpack the mod's contents into factorio/mods/tas_playback_0.0.2
  • If using the mod portal (shouldn't be possible at the moment, but whatever) : Install the mod and unpack its contents.

Creating a run

To create a run :

  • Create a new folder factorio/mods/tas_playback_0.0.2/scenarios/YourNewRunName/
  • Create a blueprint.dat file containing your run's map, like you would to create a scenario, and copy it into this folder. To do that :
    • Create a new game using your chosen map seed, using the map editor
    • Save this scenario without doing anything in the world
    • Exit factorio
    • Go to the application directory, where mods and saves can be found: https://wiki.factorio.com/Application_directory#User_data_directory
    • Go into the scenario folder, find your scenario, open it, copy the file blueprint.dat into factorio/mods/tas_playback_0.0.2/scenarios/YourNewRunName/
    • You can now remove the scenario you created.
  • Copy the files configuration.lua and control.lua from the folder factorio/mods/tas_playback_0.0.2/scenarios/Test-TAS/ into factorio/mods/tas_playback_0.0.2/scenarios/YourNewRunName/
  • Create the file that will contain the instructions for your run into the folder factorio/mods/tas_playback_0.0.2/scenarios/YourNewRunName/. You can choose the name you want for this file. For example : YourRunFile.lua
  • Open the file configuration.lua in a text editor and edit the config.run_name and config.run_file variables to contain the name of your run's scenario and of the file that contains the commands. In our case, we will have :
config.run_name = "YourNewRunName"
config.run_file = "YourRunFile"

ATTENTION : These MUST be the EXACT names used as the folder name and the run's file name. Otherwise, the run will not work !

  • you can now start writing your run's commands into YourRunFile.lua.

Playing a run

To start playing the run :

  • In factorio menu, navigate to Play -> Scenarios
  • A scenario will appear as tas_playback/YourNewRunName (YourNewRunName being the name you used when you created the run's scenario, of course). Launch it.
  • If your run's configuration file contains config.autorun = true, the run will automatically start when loading the scenario.
  • If your run's configuration file contains config.autorun = false, you can use the chat command /init_run to start it at any moment. Your player will be repositionned at the right location and your inventory reset. Any modification that happened to the world since the game was started will, however, be kept.
  • You can at any point save the run.
    • When you will reload it, the run will continue playing from the tick when it was saved.
    • Any modification that is made to the run between saving and loading and that happens after the tick where the game was saved will be taken into account.

Additional information

  • The mod will not let you start a New Game while it is active.
    • If you want to play a regular game, toggle the mod.
    • If you want to play a TAS run, please use a scenario as instructed above.
  • Due to the way the mod loads the instructions for the run, the scenarios have to be located in the mod's folder and cannot be located in the standard scenarios folder.
  • The menu Options -> Mods gives you options about the level of verbosity you want when displaying what the run does.

Writing a run

Your run file (in our example YourRunFile.lua) should start with the lines :

local commandqueue = {}

commandqueue["settings"] = {
    allowspeed = true
}

You can change allowspeed = true by allowspeed = false if you want to inhibit the speed commands of your run.

If you include the line end_tick_debug = true in the settings section, the game will give the player back the control of mouse selection after the end of input.

The rest of the file should consist of a series of instruction that take the following form :

commandqueue[<tick>] = {
    {<command1>, <options1>},
    {<command2>, <options2>}, 
	...
}

Where :

  • <tick> is the number of the tick where these commands will be executed (the start of the run being tick 0)
  • Each {<command>, <options>} sequence represents an action to be executed by the TAS. It can be chosen in the following list :
    • {"move","<DIRECTION>"} commands the player to start moving in a direction or stop. Directions can be N,S,E,W,NE,SE,SW,NW or STOP.
    • {"craft","<ITEM>", <AMOUNT>} commands the player to pocket-craft given amount of specified item.
    • {"mine", {<X>,<Y>}} commands the player to start mining at specified coordinated. To stop mining, replace {<X>,<Y>} with nil.
    • {"build","<ITEM>", {<X>,<Y>}, <FACING DIRECTION>} commands the player to build the specified item at the specified coordinates, with the item facing a certain direction. The <FACING DIRECTION> should be an element of the factorio class defines.direction.
    • {"put",{X,Y},"<ITEM>", <AMOUNT>, <destination inventory type>} commands the player to put the specified amount of the specified item into the inventory of the entity at the given coordinates. The <destination inventory type> must be an element of the factorio class defines.inventory that says which inventory slot is to be used.
    • {"speed", <speed>} sets the game speed if allowspeed is at true. Otherwise, a warning will be generated.
    • {"take",{<X>,<Y>},"<ITEM>",<AMOUNT>,<source inventory type>} commands the player to take the specified amount of the specified item from the inventory of the entity at the given coordinates. The <source inventory type> must be an element of the factorio class defines.inventory that says which inventory slot is to be used.
    • {"tech", <RESEARCH>} sets the current research as specified.
    • {"print", "<text>"} prints some text in the tchat.
    • {"recipe", {<X>,<Y>}, <recipe>} sets the recipe of the entity at the given coordinates.
    • {"rotate", {<X>,<Y>}, "<direction>"} rotates the entity at the given coordinates to face the direction specified, among directions N,S,E,W.
    • {"stopcraft", <Index>, <Quantity>} cancels the crafting of the given quantity of the items at the given index in the queue. If the <Quantity> is not specified, 1 will be used.

factorio-tas-playback's People

Contributors

bilka2 avatar samuel38 avatar starbrow88 avatar yournamehere avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

tabasavr rina-y

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.