《饥荒》MOD制作图文教程 饥荒怎么制作MOD

自己制作《饥荒》MOD是一件不简单的事,如果不懂代码那就更难了,不用担心!今天小编就为大家带来的《饥荒》制作MOD的图文教程,非常详细,代码部分都有解析,再也不用担心看不懂代码啦!下面就让我们一起看看《饥荒》是如何制作MOD吧。

《饥荒》MOD制作图文教程 饥荒怎么制作MOD

游民星空 - 查攻略必备

下载游民App,免费领取游戏大作

《饥荒》MOD制作图文教程 饥荒怎么制作MOD

饥荒游戏吧 首字母G 2015-11-19 14:20
0

同样在exchange.lua中写入

  exchange.lua

  require "prefabutil"

  local assets =

  {

  Asset("ANIM", "anim/exchange.zip"),

  Asset("IMAGE", "images/inventoryimages/exchange.tex"),

  Asset("ATLAS", "images/inventoryimages/exchange.xml"),

  }

  local prefabs =

  {

  "exchange",

  }

  local function getstatus(inst)

  end

  local function onhammered(inst, worker)

  inst.components.lootdropper:DropLoot()

  SpawnPrefab("collapse_small").Transform:SetPosition(inst.Transform:GetWorldPosition())

  inst.SoundEmitter:PlaySound("dontstarve/common/destroy_wood")

  inst:Remove()

  end

  local function onhit(inst, worker)

  inst.AnimState:PlayAnimation("hit")

  inst.AnimState:PushAnimation("idle", true)

  end

  local function onbuilt(inst)

  inst.AnimState:PlayAnimation("place")

  inst.AnimState:PushAnimation("idle")

  end

  local function fn(Sim)

  local inst = CreateEntity()

  local trans = inst.entity:AddTransform()

  local anim = inst.entity:AddAnimState()

  inst.entity:AddSoundEmitter()

  MakeObstaclePhysics(inst, 1)

  anim:SetBank("exchange")

  anim:SetBuild("exchange")

  anim:PlayAnimation("idle", true)

  inst:AddTag("structure")

  inst:AddTag("structure")

  inst:AddComponent("lootdropper")

  inst:AddComponent("workable")

  inst.components.workable:SetWorkAction(ACTIONS.HAMMER)

  inst.components.workable:SetWorkLeft(4)

  inst.components.workable:SetOnFinishCallback(onhammered)

  inst.components.workable:SetOnWorkCallback(onhit)

  inst:AddComponent("inspectable")

  local function ShouldAcceptItem(inst, item)

  if item:HasTag("hat") then

  return false

  end

  if item.components.edible.foodtype == "SEEDS" then

  return false

  end

  return true

  end

  local function OnGetItemFromPlayer(inst, giver, item)

  local names = {"cave_banana","carrot","corn","pumpkin","eggplant","durian","pomegranate","dragonfruit","berries","meat","smallmeat","fish","eel","drumstick","bird_egg","froglegs"}

  inst.name = names[math.random(#names)]

  local veggie = SpawnPrefab(inst.name)

  local goldcoin = SpawnPrefab("goldcoin")

  if item.components.edible.foodtype == "VEGGIE" then

  giver.components.inventory:GiveItem(goldcoin)

  end

  if item.components.edible.foodtype == "MEAT" then

  giver.components.inventory:GiveItem(goldcoin)

  end

  if item.prefab == "goldcoin" then

  giver.components.inventory:GiveItem(veggie or meat)

  end

  end

  inst:AddComponent("trader")

  inst.components.trader.onaccept = OnGetItemFromPlayer

  inst.components.trader:SetAcceptTest(ShouldAcceptItem)

  inst.components.inspectable.getstatus = getstatus

  return inst

  end

  return Prefab( "common/exchange", fn, assets, prefabs ),

  MakePlacer("common/exchange_placer", "exchange", "exchange", "idle")

相关内容请关注:饥荒专区

责任编辑:修凡客

本文对您是否有帮助

攻略专题 进入

攻略合集

相关推荐

APP精彩推荐打开游民APP查看更多

在线玩推荐更多