[异星工厂]填海指令

用于批量填海的控制台指令。可以将自身相邻的整片水域一次性填平

/c local player_position = game.player.position
 local neighbouring_water_tiles = {}
 for x=player_position.x-1,player_position.x+1 do
     for y=player_position.y-1,player_position.y+1 do
         local t = game.player.surface.get_tile(x,y)
         if t.name == "water" or t.name == "deepwater" then
             table.insert(neighbouring_water_tiles, {x=x, y=y})
         end
     end
 end
 local first_water_tile = neighbouring_water_tiles[1]
 local connected_water_tiles = game.player.surface.get_connected_tiles(first_water_tile, {"water", "deepwater"})
 local replacement_tiles = {}
 for i, p in ipairs(connected_water_tiles) do
     table.insert(replacement_tiles, {name="landfill", position=p})
 end
 game.player.surface.set_tiles(replacement_tiles)
 game.player.print(string.format("替换了 %i 个水方块", #replacement_tiles))

效果如图所示:

执行后:

必须相邻水单元格才会进行替换,自身没有相邻水单元格时不会执行任何替换。

暂无评论

发送评论 编辑评论


				
|´・ω・)ノ
ヾ(≧∇≦*)ゝ
(☆ω☆)
(╯‵□′)╯︵┴─┴
 ̄﹃ ̄
(/ω\)
∠( ᐛ 」∠)_
(๑•̀ㅁ•́ฅ)
→_→
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
(ノ°ο°)ノ
(´இ皿இ`)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ( ̄∇ ̄o)
ヾ(´・ ・`。)ノ"
( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃
(ó﹏ò。)
Σ(っ °Д °;)っ
( ,,´・ω・)ノ"(´っω・`。)
╮(╯▽╰)╭
o(*////▽////*)q
>﹏<
( ๑´•ω•) "(ㆆᴗㆆ)
😂
😀
😅
😊
🙂
🙃
😌
😍
😘
😜
😝
😏
😒
🙄
😳
😡
😔
😫
😱
😭
💩
👻
🙌
🖕
👍
👫
👬
👭
🌚
🌝
🙈
💊
😶
🙏
🍦
🍉
😣
Source: github.com/k4yt3x/flowerhd
颜文字
Emoji
小恐龙
花!
上一篇
下一篇