【Mindustry】自分用ロジックメモ
◆1つのユニットだけを設定して命令を送る
set flag 1111
set UType @flare
jump 8 notEqual @unit null
ubind UType
sensor f @unit @flag
jump 8 equal f flag
jump 4 notEqual f 0
ucontrol flag flag dy 0 0 0
1行目 1111 : フラグ番号、複数のプロセッサで実行する場合は2台目以降この番号を1112など被らないものに変更して実行する
2行目 "@flare" : 機体名称、フレア以外の機体にする場合はここを変更
3 ~ 8行目は機体を1機確保してフラグを付与する、あるいは確保した機体のフラグが変数と一致するかで1機を指定するロジック
このロジックを使用する場合は1ユニットにつき1プロセッサを割り当てる必要がある。
◆ユニットを移動させる
ucontrol move x y 0 0 0
バインドしたユニットを指定した位置に移動させる。
◆指定した建物にアイテムを搬出する
ucontrol itemDrop building 999 0 0 0
指定された建物にアイテムを搬出する。
buildingは変数。その他のタイプ(core等)に置き換えるたり、プロセッサの範囲内にある建物であれば直接ブロック名を記述してもOK。
◆指定された座標にあるブロックの情報を取得する
ucontrol getBlock x y type building 0 0 0 0 0
指定した座標(x,y)にどんなブロックが存在するかをタイプ(type)と建物名(building)変数に返す。座標はユニットの5タイル以内に配置する必要がある。
◆指定された建物から指定数のアイテムを取得する
ucontrol itemTake building @capper 0 0 0
指定の建物(from)から指定のアイテム(item)を指定数(amount)取得する
◆ブロックの座標をメッセージブロックに表示するサンプルプログラム
sensor xx container1 @x
sensor yy container1 @y
print xx
print ", "
print yy
printflush message1
◆指定した二つコンテナ間でアイテムを輸送するサンプルプログラム
set flag 1111
set UType @flare
set Item @titanium
set B1x 116.5
set B1y 104.5
set B2x 75.5
set B2y 121.5
jump 12 notEqual @unit null
ubind UType
sensor f @unit @flag
jump 12 equal f flag
jump 8 notEqual f 0
ucontrol flag flag dy 0 0 0
sensor hold @unit @firstItem
sensor capa @unit @itemCapacity
jump 20 greaterThan hold 0
ucontrol move B1x B1y 0 0 0
ucontrol getBlock B1x B1y type building 0
ucontrol itemTake building Item 20 building 0
end
ucontrol move B2x B2y 0 0 0
ucontrol getBlock B2x B2y type building 0
ucontrol itemDrop building 999 0 0 0
この記事が気に入ったらサポートをしてみませんか?