コンソールコマンド

Last-modified: 2024-01-14 (日) 18:26:03

※注意!
/c系のコンソールコマンドを使用すると、そのセーブデータでは実績の解除ができなくなります。
その旨を警告する文章が一度表示されますので、構わないのであればもう一度コマンドを実行してください。

 

チャットウインドウ(デフォルトでは@キー)に特定の文字列を入力することでコンソールコマンドが使えます。
チートの様に使える物もあるので乱用するとゲームに飽きるのが早くなるかもしれません。各自、気をつけて使って下さい。
ゲームのアップデートやMod導入の有無など、プレイ環境によってコマンドが使えない場合があります。
詳しい方はぜひコマンドの追加・編集をお願いします。

基本

変数の値を表示する

変数値を変更する前に初期値を調べておくと、戻す時に便利。

/c game.player.print(VARIABLE).

例:ゲーム速度の変数値を表示する

/c game.player.print(game.speed).

全ての変更を元に戻す

テクノロジーや速度も含むが自チームのみ

/c game.player.force.reset()

レシピ・技術アンロック

コマンドを使う前に使いたいレシピや技術の内部名称を調べておいてください。
Factorio\data\base\locale\ja内のbase.cfgのレシピなら[item-name]や[recipe-name]、
技術なら[technology-name]などで確認できます。
面倒なら英語名を小文字に直しスペースを-に置き換えれば一部を除き入力可能です。

個別のレシピ

[""]内に開放したいレシピ名を入れる。
trueをfalseに変えるとレシピを削除出来る。
例:自チームの組立機2のレシピを開放

/c game.player.force.recipes["assembling-machine-2"].enabled = true

個別の技術

/c game.player.force.technologies['技術名'].researched = true

研究を無効化する場合は以下のコマンドを使う。

/c game.player.force.technologies['技術名'].researched = false; game.player.force.set_saved_technology_progress('技術名', 0)

個別の技術(∞研究)

['']内に∞研究できる技術名を入れる。

例:自チームの掘削効率の∞研究を100にする。上限4294967295

/c game.player.force.technologies['mining-productivity-16'].level=100

全技術研究完了

自チームの全技術研究完了

/c game.player.force.research_all_technologies()

全ての手作りアイテムの即時・無限作成有効化

自分が作成できる全てのアイテムを材料無し、加工時間無しで入手できるようにする

/c game.player.cheat_mode = true

アイテムの手作りの速度変更

自チームの全員のアイテムの手作りの速度変更
初期値1、2で速度2倍、etc.

/c game.player.force.manual_crafting_speed_modifier=X

鉱物・設置物の採掘速度変更

自チームの全員の鉱物・設置物の採掘速度変更
初期値1、2で速度2倍、etc.

/c game.player.force.manual_mining_speed_modifier=X

アイテム個数変更

指定したアイテムを好きな個数出す

/c game.player.insert({ name = "欲しいアイテムの内部名称" , count = 個数 })

欲しいアイテムの内部名称が不明な場合、以下のいずれかの対応を取ると良い。

  • Factorio\data\base\locale\ja内のbase.cfgの[item-name]や英wikiなどで内部名称を確認する
  • ゲームの言語を英語に変えて目的のアイテムを探し、大文字を小文字に変え半角スペースを-に置き換えて入力する。
    • 例:車=car、銅鉱石=copper-ore、組立機3=assembling-machine-3
    • Flamethrowerなど、一部のアイテムは非対応
  • 本コマンドで無限チェストを出し、必要なアイテムは無限チェストから取り出す。
    • 無限チェスト: 任意のアイテムを無限に取り出せるチェスト。内部名称は infinity-chest。
      /c game.player.insert({ name = "infinity-chest" , count = 1 })
  • チートモードで代用する。
    • 鉄鉱石など、採掘でしか得られないアイテムは非対応。

列車関連アイテム全種所持&無限化

技術開発していなくても列車が使えるようになり、レールや機関車をいくら設置しても減らなくなる。

/c name={"locomotive" , "cargo-wagon" , "fluid-wagon" , "rail" ,
             "train-stop" , "rail-signal" , "rail-chain-signal"}
for _,n in pairs ( name ) do
  game.player.insert( {name = n , count = 5} )
end
script.on_event( defines.events.on_built_entity , function( event )
  local p = game.players[event.player_index]
  for _ , n in pairs ( name ) do
    local c = p.get_item_count( n )
    if ( c < 5 ) then
      p.insert( {name = n,count = 5 - c } )
    end
  end
end)

枯渇した資源を再生成する

完全に掘り尽くした資源を再生成する。指定した資源がマップ上に残っている場合は無効。

/c game.regenerate_entity("再生成したい資源のエンティティ名")

資源を生成する

自分を中心に、指定した資源を生成する。
OREの部分をiron-oreなど資源名に変える。Zで資源の個数、
rでプレイヤーの座標からどの程度の範囲で生成するかを指定する。

/c local r=5
local name="ORE"
local amount=Z
local surface = game.player.surface
local pos = game.player.position
 for y =pos.y-r, pos.y+r do
  for x = pos.x-r , pos.x+r do
   surface.create_entity({name=name, amount=amount,
     position={x,y}})
   end
 end

ユーティリティ系

ゲーム速度変更ボタン追加

自分の画面の左上に速度変更ボタンを2つ追加する。TimeButtonsというModでも同じ事が出来る。

/c game.player.gui.top.add{type = "button" , caption = "1倍速" , name = "1x"}
game.player.gui.top.add{type = "button" ,  caption = "2倍速" , name = "2x"}
script.on_event( defines.events.on_gui_click , function( event )
  local p = game.players[event.player_index]
  if ( event.element.name == "1x" ) then
    p.print( "1倍速" )
    game.speed = 1
  elseif ( event.element.name == "2x" ) then
    p.print( "2倍速" )
    game.speed = 2
  end
end)

データロード後にボタンが無効になるため以下のコマンドを入力して再度有効化する必要がある。

/c script.on_event( defines.events.on_gui_click , function( event )
 local p = game.players[event.player_index]
 if ( event.element.name == "1x" ) then
   p.print( "1倍速" )
   game.speed = 1
 elseif ( event.element.name == "2x" ) then
   p.print( "2倍速" )
   game.speed = 2
 end
end)

ゲームの速度を変更する

上記のシンプル版。初期値1で普通の速度、2ならば2倍。

/c game.speed = X

プレイヤー全員の体力が常に回復

時間経過(1tick)するたびにプレイヤーの体力を100回復します。ただし、即死ダメージを受けると死にます。
ゲームが重くなる場合があります。

/c script.on_event( defines.events.on_tick , function( event )
  for _ , p in pairs ( game.players ) do
    if( p.character ~= nil ) then
      p.character.damage( -100 , p.force)
    end
  end
end)

プレイヤー無敵化

自身の体力ゲージを無くし死なないようにします。
副次的効果としてプレイヤーがバイターの攻撃対象から外れます(近づく、攻撃する、巣を破壊など何をしても無視されます)。

/c game.player.character.destructible=false

自分の位置を確認

/c game.player.print("("..game.player.position.x..", "..game.player.position.y..")")

自分の位置をテレポート

/c game.player.teleport({X, Y})

常に昼にする

自分がいるディメンションを常に昼にする
trueで時間が昼に固定される。falseで元に戻す。

/c game.player.surface.always_day=true

常に夜にする

自分がいるディメンションを常に夜にする。

/c game.player.surface.always_day = true; game.player.surface.daytime = 0.5

時間の流れを止める

自分の居るディメンションの時間の流れを止める
ゲームは動作するが、進化ファクターの増加などが止まる。falseで元に戻す。

/c game.player.surface.freeze_daytime(true)

ピースフルモードにする

ゲームの途中でピースフルモードにする。(0.13対応版)

/c game.player.surface.peaceful_mode=true

これだけでは既に敵対モードになっているバイターがそのままなので、それらを消去する

/c game.forces["enemy"].kill_all_units()

マルチプレイ関連

他のプレイヤー全員を自分の位置にテレポートさせる

/c local p = game.player
for _ , player in pairs ( game.players ) do
  player.teleport( p.position , p.surface )
end

自チームのスポーン地点を変更する

スポーン地点にしたい場所に移動して使用する。

/c local p = game.player
  p.force.set_spawn_position( p.position , p.surface )

その他

一定時間ごとに敵が攻撃してくる

一定時間ごとに敵の襲撃を受け、襲撃のたびに数が1匹ずつ増える。
(3*60*60)の数字が時間(tick)を、attack_count + 1の数字が1回ごとに増える数を意味する。

/c local targetselect = function(surface)
  local targets = {}
  for _ , player in pairs(game.players)do
    if player.surface == surface and player.character then
      table.insert(targets,player.character)
    end
  end
  if (#targets > 0)then
    return targets[math.random(#targets)]
  end
return nil
end
script.on_nth_tick(3*60*60 , function( event )
  if( attack_count ~= nil ) then
    attack_count = attack_count + 1
  else
    attack_count = 5
  end
  for _ , surface in pairs(game.surfaces)do
    local target = targetselect(surface)
    if ( target ~= nil ) then
      surface.set_multi_command{command =
        {type = defines.command.attack , target = target ,
        distraction=defines.distraction.by_enemy },
      unit_count = attack_count}
    end
  end
end)

全てのバイターを消去

enemyチームのすべてのユニット(巣、ワーム等)を消す。

/c local surface = game.player.surface
for key, entity in pairs(surface.find_entities_filtered({force= "enemy"})) do
  entity.destroy()
end

現在のバイターの進化ファクターの数値を表示

/evolution

※このコマンドでは、/cは不要。

巣の拡張を止める

/c game.map_settings.enemy_expansion.enabled=false

進化ファクターの数値を変更

Xは0.0から1.0の間の数値。

/c game.forces["enemy"].evolution_factor=X

現マップの汚染を0にする

バイターは退化しないし、汚染は再び累積していく。

/c game.player.surface.clear_pollution()

強制的にマップを開く

まだplayerチームが見ていない場所のマップを開く。座標は(x1, y1)~(x2, y2)の矩形。
※実行する前に、まず自分の位置の座標を確認するのがよい。
※一度行うと、元に戻せない。セーブデータの容量が増えるので、事前にデータをセーブした上で慎重に行うこと。

/c game.forces.player.chart(game.player.surface, {{x = x1, y = y1}, {x = x2, y = y2}})

開いたマップの情報を更新する

プレイヤーやレーダーで既に開いているplayerチームのマップの各チャンクについて、
バイターの巣の情報などを更新する。

/c game.forces.player.rechart()

全マップを未探索状態に戻す

プレイヤーやレーダーで既に開いているplayerチームのマップを
全て探索していない状態にする(完全に黒色にする)。
ただし、セーブファイル上の地図情報は残るので、これだけではセーブファイルの軽量化はできない。
セーブファイルを軽量化したい場合はチャンクの削除を参照。

/c game.forces.player.clear_chart()

非公開のチャンク情報を削除する。

上記の「残った地図情報」を削除するのに使う。探索し過ぎたことで
大きくなったセーブデータの容量の削除に使用できる。

/c local surface = game.player.surface
   local force = game.player.force
   for chunk in surface.get_chunks() do
     if not force.is_chunk_charted(surface, chunk) then
       surface.delete_chunk(chunk)
     end
   end

プレイヤーを中心に指定範囲のオブジェクトを消去する

自分のX,Y座標を中心に、指定した範囲の全ての設置物を消去する。鉱物資源だけでなく、建物も含むので注意。
XPOS,YPOSで、プレイヤーのX,Y座標からどの程度の座標の範囲で消去するかを指定する。

/c for key, entity in pairs(game.player.surface.find_entities_filtered{
  area={{game.player.position.x-XPOS, game.player.position.y-YPOS},
  {game.player.position.x+XPOS, game.player.position.y+YPOS}},
  name="ORE/OBJECT"}) do
entity.destroy()
end

巨大なスクリーンショットを撮影する

例えば4000x4000ピクセルのSSを撮りたい場合、XPOS,YPOSに4000,4000を入れる。
撮影されたSSは、「mods」のフォルダ内にある「script-output」に保存される。

/c game.take_screenshot{resolution = {x = XPOS, y = YPOS}}

自身の近くを埋め立てる

自身を中心とした半径r以内にある水、もしくは深水タイルを草タイルへと置き換える

/c local r = 2
local tiles = {}
local p = game.player.character.position
local s = game.player.surface
for x = p.x-r, p.x+r do
  for y = p.y-r, p.y+r do
    tilename = s.get_tile( x , y ).name
    if ( tilename == "deepwater" or tilename == "water" or
        tilename == "deepwater-green" or tilename == "water-green")then
      table.insert( tiles , { name = "grass-1" , position = { x = x , y = y }})
    end
  end
end
s.set_tiles(tiles)

池を生成する

プレイヤーの位置から左上に池を生成する。
w = 幅 h = 高さ tile_name = water(水) または deepwater が指定可能、sand-1 を指定すると砂地に埋め立てが可能です。

/c
local w = 20
local h = 10
local tile_name = 'water'
local tiles = {}
local surface = game.player.surface
local pos = game.player.position
for y =pos.y-h-1, pos.y-1 do
 for x = pos.x-w , pos.x do
   table.insert(tiles,{name = tile_name, position={x,y}})
 end
end
surface.set_tiles(tiles)

レシピ一覧をCSV形式で出力する

レシピごとに、必要な材料数や製作時間がカンマ区切りで出力される。
出力結果は「%appdata%\Factorio\script-output」に保存される。一番右の列でソートすると製作ウィンドウと同じ並び順になる。
Factorio計算機をExcelで自作したい、という酔狂な人のために。

/c local filename="recipes.csv"
game.write_file(filename, "Name,ID,Group,Times,Output1,Num,Output2,Num,Output3,Num,Input1,Num,Input2,Num,Input3,Num,Input4,Num,Input5,Num,Input6,Num,Input7,Num,Input8,Num,SortOrder\n", false)
for ID, recipe in pairs(game.player.force.recipes) do
  if not(recipe.hidden) then
    game.write_file(filename, recipe.localised_name, true)
    game.write_file(filename, "," .. ID .. ",", true)
    game.write_file(filename, recipe.group.localised_name, true)
    game.write_file(filename, "," .. recipe.energy, true)
    for i = 1 , 3 do
      if (i > #recipe.products) then
        game.write_file(filename, ",,", true)
      else
        game.write_file(filename, "," , true)
        if (recipe.products[i].type=="fluid") then
          game.write_file(filename, game.fluid_prototypes[recipe.products[i].name].localised_name, true)
        else
          game.write_file(filename, game.item_prototypes[recipe.products[i].name].localised_name, true)
        end
        game.write_file(filename, "," .. recipe.products[i].amount, true)
      end
    end
    for i = 1 , 8 do
      if (i > #recipe.ingredients) then
        game.write_file(filename, ",,", true)
      else
        game.write_file(filename, "," , true)
        if (recipe.ingredients[i].type=="fluid") then
          game.write_file(filename, game.fluid_prototypes[recipe.ingredients[i].name].localised_name, true)
        else
          game.write_file(filename, game.item_prototypes[recipe.ingredients[i].name].localised_name, true)
        end
        game.write_file(filename, "," .. recipe.ingredients[i].amount, true)
      end
    end
    game.write_file(filename, "," .. recipe.group.order .. ":" .. recipe.subgroup.order .. ":" .. recipe.order .. "\n", true)
  end
end

コメント

  • Switch版でコンソールコマンドが効かないんだけどなぜだかわかりますか? ピースフルモードの命令は受け付けたっぽいチャットが出るんだけど実際には切り替わらないし、バイターの削除コマンドに至っては打ち込んでもうんともすんともって感じ。スペルミスはしてないんですが…… -- 2024-01-09 (火) 20:08:20
  • ディメンションって何ですか? サーフィスとは違うもの? -- 2023-03-25 (土) 18:08:09
    • 同じものだと思うよ。公式用語が無いので日本語も安定していないのだろう。ちなみに英wikiだと the World で、これまた別表現。 -- 2023-03-25 (土) 20:47:39
    • 同じものなんだけどもsurfaceを表面ってそのまま訳すのもカタカナで書くのも分かりにくいかなって、だからと言って地面や地表だと意味が違うし考えるのが面倒になって適当に書いといたら後でだれか適切なのに書き換えてくれるだろうと -- 2023-09-09 (土) 23:30:27
  • 追加のインベントリスロットを100個にする /c game.player.force.character_inventory_slots_bonus=100 -- 2022-01-03 (月) 00:39:30
  • 「個別の技術(∞研究)」の仕様変わった? -- 2019-12-14 (土) 18:22:26
    • 仕様は変わっていませんが内部名称が変更されて今は存在しない技術を指定しているので使えません -- 2019-12-17 (火) 20:25:21
      • 正しいtechnology-nameに変えても動作しないようです -- 2020-07-18 (土) 19:22:14
      • 正しいtechnology-nameに変えれば正常に動作します、何か間違えているのでは?ver0.17.79&0.18.36で確認 -- 2020-07-19 (日) 11:06:29
      • 間違えていました。-1をつけ忘れていました。 -- 2020-07-22 (水) 15:58:51
  • すいませんこのコマンドの何が間違っているのでしょうか?/c local name="stone-ore" local amount=50000 local surface = game.player.surface local pos = game.player.position for y =pos.y-50, pos.y+50 do for x = pos.x-50, pos.x+50 do surface.create_entity({name=name, amount=amount, position={x,y}}) end end -- 2019-11-19 (火) 10:36:34
    • 自己解決しました。 -- 2019-11-19 (火) 14:15:32
  • コンクリートを張っても残る草のデカールを削除するコマンドは無いモノか -- 2019-11-03 (日) 13:04:56
  • プレイヤーを出して、建設ロボを使える状態にする /c game.player.create_character() game.player.cheat_mode=true game.player.force.research_all_technologies() game.player.insert{name="power-armor-mk2", count = 1} game.player.insert{name="construction-robot", count = 125} local p_armor = game.player.get_inventory(5)[1].grid p_armor.put({name = "fusion-reactor-equipment"}) p_armor.put({name = "fusion-reactor-equipment"}) p_armor.put({name = "battery-mk2-equipment"}) p_armor.put({name = "battery-mk2-equipment"}) p_armor.put({name = "battery-mk2-equipment"}) p_armor.put({name = "solar-panel-equipment"}) p_armor.put({name = "belt-immunity-equipment"}) p_armor.put({name = "exoskeleton-equipment"}) p_armor.put({name = "exoskeleton-equipment"}) p_armor.put({name = "exoskeleton-equipment"}) p_armor.put({name = "exoskeleton-equipment"}) p_armor.put({name = "exoskeleton-equipment"}) p_armor.put({name = "personal-roboport-mk2-equipment"}) p_armor.put({name = "personal-roboport-mk2-equipment"}) p_armor.put({name = "personal-roboport-mk2-equipment"}) p_armor.put({name = "personal-roboport-mk2-equipment"}) p_armor.put({name = "personal-roboport-mk2-equipment"}) -- 2019-10-23 (水) 10:03:20
  • チートアイテム一式を入手 /c local item1={"infinity-chest","loader","fast-loader","express-loader", "electric-energy-interface","infinity-pipe"} for _,n in pairs ( item1 ) do game.player.insert( {name=n , count = 10} ) end -- 2019-10-23 (水) 10:01:05
  • ゲーム速度変更ボタンをコンソールで追加しましたが、消せません。速度変更ボタンを消すコンソールコマンドがわからず困っています -- 2019-02-08 (金) 19:05:37
    • コマンド'game.player.gui.top.add{type = "button" , caption = "1倍速" , name = "1x"}'で追加したボタンを削除するには、コマンド'game.player.gui.top["1x"].destroy()'を実行します(参考: https://lua-api.factorio.com/latest/LuaGuiElement.html )。または、ゲームを再起動します。 -- 2019-02-08 (金) 21:56:49
  • 別のプレイヤーがコンソールコマンドで資源を生成した場合、 その後自分がそのデータに入った場合は自分も実績解除ができないのでしょうか? -- 2018-12-03 (月) 02:38:05