MODの作り方/BomberTutorial

Last-modified: 2016-08-02 (火) 09:46:23
 

英語ページのBomberTutorialをクロームで和訳しながら作ってました、同じような感じで試してみることを目的に投稿致します。
wikiの整形等はわかりかねますので、それ以上は無理です。

 注意書き 画像は内部にある画像で流用してますので用意する必要はありません
      わかる範囲で動く場所とわからないけど他MODからの流用コードで動いてる場所があります
      とりあえずアイテム追加してそれが動くとこまでです。
      1.3で動くようになっています。
      整形がずれておりますが { ~ } までがだいたいコードです
      爆撃はしません

1.セットアップ

mods フォルダに BomberTutorial_0.1.1 を作成します。
フォルダ名は下記の info.json ファイルの一部内容と同一である必要があります。

BomberTutorial_0.1.1 フォルダに data.lua ファイルと info.json ファイルを作成します。
info.json の内容は下記の通り

{
 "name": "BomberTutorial",
 "version": "0.1.1",
 "title": "BomberTutorial",
 "author": "",
 "contact": "",
 "homepage": "",
 "factorio_version":"0.13"
}

2.アイテムの追加

bombertutorial_0.1.1 フォルダに prototypes フォルダを作成します。
その場所に item.lua ファイルを作成します。内容は下記の通り

data:extend({
{
   type = "item",
   name = "bomber",
   icon = "__base__/graphics/icons/defender.png",
   flags = { "goes-to-quickbar" },
   subgroup = "capsule",
   place_result="bomber",
   stack_size= 50,
 }
})

3.レシピの追加

prototypes フォルダに recipe.lua ファイルを作成します。(上記で作成した場所)
内容は下記の通り

data:extend({
{
   type = "recipe",
   name = "bomber",
   enabled = "true",
   energy_required = 0.1,
   ingredients =
   {
     {"iron-plate",1},
   },
   result = "bomber"
 }
})

 注意書き enabled = "true", の文ですぐに作成できるようになっております

     他のページを参考に技術ツリーなどに組み込んでください

     (英語ページに似たようなことが書いてある)

4.エンティティ

残念ながらここは動いてるけどよくわかりません。ごみが多数あると思います
mocombat_0.5.9 のMODを参考にさせて頂きました。
type = "car", での動作がわかりかねます

prototypes フォルダに entity.lua を作成します。内容は下記の通り

data:extend({
 {
     type = "unit",
     name = "bomber",
     icon = "__base__/graphics/icons/defender.png",
     flags = {"placeable-player",  "placeable-off-grid"},
     minable = {mining_time = 1, result = "bomber"},
     max_health = 2000,
run_animation =
	{
		filename = "__base__/graphics/icons/defender.png",
		priority = "high",
		still_frame = 1,
		width = 37,
		height = 34,
		frame_count = 1,
		direction_count = 1,
		shift = {0, 0}
	},
attack_parameters =
	{
 		type = "projectile",
 		ammo_category = "capsule",
 		cooldown = 20,
 		projectile_center = {0, 1},
 		projectile_creation_distance = 0.6,
 		range = 15,
 		sound = make_light_gunshot_sounds(),
 		ammo_type =
 		{
			category = "capsule",
			target_type = "position",
			action =
			{
	  			type = "direct",
	 			 action_delivery =
	  			{
					type = "projectile",
					projectile = "defender-capsule",
					starting_speed = 0.2,
					source_effects =
					{
		 				 type = "create-explosion",
		 				entity_name = "explosion-gunshot-small"
					},
				target_effects =
				{
		  			{
						type = "create-entity",
						entity_name = "explosion-hit"
		  			},
		  			{
						type = "damage",
						damage = { amount = 5 , type = "physical"}
	}	}	}	}  	},
animation = {
	  width = 102,
	  height = 86,
	  scale=0.3,
	  frame_count = 2,
	  direction_count = 64,
	  shift = {0, -0.05625},
	  animation_speed = 8,
	  max_advance = 0.2,
	  stripes =
	  {
		{filename = "__base__/graphics/entity/car/car-1.png",
                           width_in_frames = 2,height_in_frames = 22,},
		{filename = "__base__/graphics/entity/car/car-2.png",
                           width_in_frames = 2,height_in_frames = 22,},
		{filename = "__base__/graphics/entity/car/car-3.png",
                           width_in_frames = 2,height_in_frames = 20,},
	  }
	}
},
	movement_speed = 0.24,
	distance_per_frame = 0.1,
	vision_distance = 100,
	pollution_to_join_attack = 2,
	distraction_cooldown = 1,
	corpse = "small-remnants",
     corpse = "medium-remnants",
     selection_box = {{-0.7, -1.2}, {0.7, 1.2}},
     acceleration_per_energy = 0.15,
     breaking_speed = 0.09,
     burner =
       {
         effectivity = 0.25,
         emissions = 20,
         fuel_inventory_size = 2,
       },
     consumption = "1J",
     friction = 0.01,
     pictures = {
       filename = "__base__/graphics/icons/defender.png",
       priority = "high",
       frame_width = 211,
       frame_height = 211,
       direction_count = 9
     },
     rotation_speed = 0.05,
     weight = 50,
     inventory_size = 12
 },
     energy_per_hit_point = 100 ,
	friction = 0.01,
	subgroup = "capsule",
})

5.一連のファイルの読みこみ設定

bombertutorial_0.1.1 フォルダ内の data.lua ファイルを下記のように編集します。

require("prototypes.item")
require("prototypes.recipe")
require("prototypes.entity")

以上これで起動させれば動きました
本来であれば 4.エンティティ 内部での動作設定を
チュートリアルでの control.lua ファイルに記載するのがすじと思われます。
もっと詳しい方がご助力いただけると幸いですが、
一部の人を混乱させてしまうかなと思いつつ筆を置きます。