mod制作直播
饥荒mod制作吧
全部回复
仅看楼主
level 6
[滑稽]没错 就是直播 而且不是教程 就是边学边问问题,然后自己总结的那种直播。然后我现在在做帽子(人物太坑) 我打算做完帽子做武器 做完武器 开始进阶人物----我一直想做的猪八戒(一个辣鸡贴图我都弄好了)
那么这是我研究一下午的帖子 https://tieba.baidu.com/p/4801688246?pid=98472595235&cid=0#98472595235
2016年09月29日 10点09分 1
level 6
咳咳 那么上个帖子是讲到 我在看长矛的代码
local assets=
{
Asset("ANIM", "anim/spear.zip"),
Asset("ANIM", "anim/swap_spear.zip"),
}
local function onfinished(inst)
inst:Remove()
end
local function onequip(inst, owner)
owner.AnimState:OverrideSymbol("swap_object", "swap_spear", "swap_spear")
owner.AnimState:Show("ARM_carry")
owner.AnimState:Hide("ARM_normal")
end
local function onunequip(inst, owner)
owner.AnimState:Hide("ARM_carry")
owner.AnimState:Show("ARM_normal")
end
local function fn(Sim)
local inst = CreateEntity()
local trans = inst.entity:AddTransform()
local anim = inst.entity:AddAnimState()
MakeInventoryPhysics(inst)
anim:SetBank("spear")
anim:SetBuild("spear")
anim:PlayAnimation("idle")
inst:AddTag("sharp")
inst:AddComponent("weapon")
inst.components.weapon:SetDamage(TUNING.SPEAR_DAMAGE)
-------
inst:AddComponent("finiteuses")
inst.components.finiteuses:SetMaxUses(TUNING.SPEAR_USES)
inst.components.finiteuses:SetUses(TUNING.SPEAR_USES)
inst.components.finiteuses:SetOnFinished( onfinished )
inst:AddComponent("inspectable")
inst:AddComponent("inventoryitem")
inst:AddComponent("equippable")
inst.components.equippable:SetOnEquip( onequip )
inst.components.equippable:SetOnUnequip( onunequip )
return inst
end
return Prefab( "common/inventory/spear", fn, assets)
这是长矛的代码。这个代码文件我自己理解就是相当于做mod的images--prefabs里面那个文件
QAQ 然后我之前很多跟这一样的代码都写在modmain
2016年09月29日 10点09分 2
level 6
这是某作者的帽子代码 modmain。他纸写了定义物品和设置物品基本的名字 材料 语言
QAQ 那么我现在就得把modmain的东西都搬过去了
PrefabFiles = {
"foilhat",
}
STRINGS = GLOBAL.STRINGS
RECIPETABS = GLOBAL.RECIPETABS
Recipe = GLOBAL.Recipe
Ingredient = GLOBAL.Ingredient
TECH = GLOBAL.TECH
GLOBAL.STRINGS.NAMES.FOILHAT = "Tinfoil hat"
STRINGS.RECIPE_DESC.FOILHAT = "Say goodbye to the mind control."
GLOBAL.STRINGS.CHARACTERS.GENERIC.DESCRIBE.FOILHAT = "They can't track me now."
local foilhat = GLOBAL.Recipe("foilhat",{ Ingredient("papyrus", 2), Ingredient("nitre", 2) },
RECIPETABS.DRESS, TECH.NONE )
foilhat.atlas = "images/inventoryimages/foilhat.xml"
2016年09月29日 10点09分 3
level 6
local function fn(sim) 然后接下来讲讲 fn 我觉得这个也应该是放在prefabs 因为别的mod都是这样。
2016年09月29日 10点09分 5
level 6
MakeInvenToryPhysics(inst) ---创建物理库存 (吧主没备注 我就按自己英语水平瞎翻译了)
anim:SetBank("hat_pigking") ---这一段 设置动画什么什么的
anim:SetBuild("hat_pigking")
anim:PlayAnimation("idle")
那么这一大段也是要搬过去啦 [勉强]
2016年09月29日 11点09分 8
level 6
咳咳,顺便说一下啊,qwq 刚刚开始学饥荒lua的时候我是直接做人物 当时太急 结果就是各种问题 浪费了我2天时间 所以最好就是从小东西开始做了。例如帽子。呸呸,例如先玩坏游戏[滑稽]
2016年09月29日 11点09分 9
level 6
这是长矛fn的代码 大家可以参照下。[滑稽]因为是武器 所以有所不同。至于我为何要看武器的 这也是我的一个错误。我一直很反感现在大部分年轻人只会参照书本,结果今天不知不觉也脑残了一遍 参照触电教程搬了长矛 我应该搬帽子的 不过没差太多 配合下 咳咳。
local function fn(Sim)
local inst = CreateEntity() ---创造实体的那个格式
local trans = inst.entity:AddTransform()
local anim = inst.entity:AddAnimState()
MakeInventoryPhysics(inst) 这就是刚刚那个瞎翻译的那句
anim:SetBank("spear") 这个和上面讲的也是一样的了
anim:SetBuild("spear")
anim:PlayAnimation("idle")
inst:AddTag("sharp") ??什么东西。添加标签(锋利的?) 那我就暂时理解成添加到战斗栏把 虽然战斗栏是WAR 但是没办法 没别的理解了 我觉得这个 在我的mod里 应该不用写 或者说我已经写过了。就是下面制作材料的 那这里就不管
inst:AddComponent("weapon") 这里是添加到组件--武器里面 那么问题来了 上面TM是什么东西
inst.components.weapon:SetDamage(TUNING.SPEAR_DAMAGE) 这就是武器伤害了 我现在就暂时不写 因为还在解决基本mod能不能在游戏显示的问题
-------
inst:AddComponent("finiteuses") 组件--有限使用 表示单词连在一起 想了半天是什么意思
inst.components.finiteuses:SetMaxUses(TUNING.SPEAR_USES) 在这个组件里面 设置最大食用
inst.components.finiteuses:SetUses(TUNING.SPEAR_USES) 设置使用(我暂时不明白他和上面的区别)
inst.components.finiteuses:SetOnFinished( onfinished ) 用完干嘛干嘛
inst:AddComponent("inspectable") 这也是添加组件 但是! 这什么鬼 缩写? 我完全不知道怎么翻译
inst:AddComponent("inventoryitem") ----1
inst:AddComponent("equippable") ---2
inst.components.equippable:SetOnEquip( onequip )---3
inst.components.equippable:SetOnUnequip( onunequip )---4
好 以上这部分我不想解释了 因为现在只是把我之前写错位置的搬过去 这只是参照
return inst
end
return Prefab( "common/inventory/spear", fn, assets)
2016年09月29日 11点09分 10
那个两个设置耐久的,第一个是最高耐久,另一个是做出来时候的耐久
2016年09月30日 04点09分
添加标签就是字面上的意思,比如桦树和常青树都有树这个标签,有些标签可能原版里不会用上
2017年02月13日 00点02分
2017年02月21日 04点02分
level 6
好 某帽子的这段代码 并不是在main里面 也就是说 我们那段代码需要搬到帽子的代码lua下 (以下全用代码lua代替)
inst:AddComponent("inventoryitem")
inst.components.inventoryitem.imagename = "foilhat" 引号里面就是某帽子的名字
inst.components.inventoryitem.atlasname = "images/inventoryimages/foilhat.xml" 这就是定义物品栏图标的一段代码 上面都是
inst:AddComponent("equippable") 这一大段 是堆叠的 我大概理解了一点 这一句 建立组件 -装备
inst.components.equippable.equipslot = EQUIPSLOTS.HEAD 在装备里面 的指定装备物品=(是)我这理解为 等于我们的帽子
↑ 翻译-指定装备物品 就是我门的帽子了 应该是
inst.components.equippable:SetOnEquip(OnEquip) 设置装备的时候 e。。应该是拿在手上把
inst.components.equippable:SetOnUnequip(OnUnequip) 不装备的时候
那么这一段我就很好奇了啊。不装备 装备 也没有说是堆叠多少 。只写了一串在装备的代码 那好 应该就是默认了 目测就是1 暂时理解为1
2016年09月29日 11点09分 12
没有写能堆叠多少就是不能堆叠
2016年09月30日 04点09分
@XWJ249 明白
2016年09月30日 05点09分
level 6
那么这2段 也是要搬到代码lua里面的了
2016年09月29日 11点09分 13
level 6
local function fn(sim)
------这一段-搬
local inst = CreateEntity()
local trans = inst.entity:AddTransform() ---一种格式QAQ。每个实物都必须有
local anim = inst.entity:AddAnimState()
MakeInvenToryPhysics(inst) ---创建物理库存
anim:SetBank("hat_pigking") ---这一段 设置动画什么什么的
anim:SetBuild("hat_pigking")
anim:PlayAnimation("idle")
inst:AddComponent("inventoryitem") ---定义物品栏图标
inst.components.inventoryitem.imagename = "hat_pigking"
inst.components.inventoryitem.atlasname = "images/inventoryimages/hat_pigking.xml"
inst:AddComponent("equippable")
inst.components.equippable.equipslot = EQUIPSLOTS.HEAD
inst.components.equippable:SetOnEquip(OnEquip)
inst.components.equippable:SetOnUnequip(OnUnequip)
return inst
end
return Prefab ("common/inventory/hat_pigking",fn,asseta,prefabs)这最后一句就是返回该代码 虽然我没有理解 但是从返回 prefab 我就知道 这肯定不是属于modmain的 那么稳稳搬
那这就是我的fn所有内容了 ---后面的字都是无效的 就是自己备注的 所以我一般容易忘都会在后面备注
以上就是我要搬过去的内容
2016年09月29日 11点09分 14
level 1
咩,路过~水水水水水水不知道有没有15字。咩~[呵呵]
2016年09月29日 11点09分 15
哇,有人
2016年09月29日 13点09分
level 6
local assets=
{
Asset("ANIM", "anim/foilhat.zip"),
Asset("ANIM", "anim/foilhat_swap.zip"),
Asset("ATLAS", "images/inventoryimages/foilhat.xml"),
Asset("IMAGE", "images/inventoryimages/foilhat.tex"),
}
local prefabs = 这个应该就是定义设定这个东东了
{
}
local function fn() 这下面都是fn 省略了
那么现在代码lua里面就是这样了 某帽子里面也是这样 这就很没问题了 暂时就算是
正确的

但是在长矛里面可不是这样
local function onfinished(inst) 这个倒是看懂-定义在使用完发生的事情 为inst
inst:Remove() 然后inst对应的就是删除了 也就是用完删掉
end
长矛是这样的,并且没有定义设定那段 。定义设定 那个我觉得长矛应该不需要 。而且这个我觉得还有可能是定义物品。那定义设定那段 就不管了
local function onequip(inst, owner)
owner.AnimState:OverrideSymbol("swap_object", "swap_spear", "swap_spear")
owner.AnimState:Show("ARM_carry")
owner.AnimState:Hide("ARM_normal")
end
local function onunequip(inst, owner)
owner.AnimState:Hide("ARM_carry")
owner.AnimState:Show("ARM_normal")
end
2016年09月29日 11点09分 16
定义用完后面还有2段代码 先不讲
2016年09月29日 11点09分
level 6
那么问题来了 在某帽子的代码lua里 为何没有用完干嘛的指令 难道不用吗。这就是个很大的疑问了 就算无限使用 也应该有个代码定义用完不消失把 又或者是耐久不消耗
2016年09月29日 11点09分 17
那么现在 就需要再找一个消耗耐久的 以及一个不消耗耐久的武器
2016年09月29日 11点09分
@无形杀金士顿 代码不是你这么理解的,是定义让他消失,有耐久,不是定义不消失,无耐久
2016年09月30日 05点09分
@XWJ249 明白了
2016年09月30日 05点09分
level 6
消耗耐久的我找到的是一个草叉 他不是在原有草叉修改 而是在新草叉修改
这mod超级好用 推荐 Smart-Pitchfork-Plus 自己看说明把
咳咳 回归正题---他是掉耐久的 然后我门来看看他的代码
2016年09月29日 12点09分 18
level 6
local assets=
{
Asset("ANIM", "anim/pitchfork.zip"),
--Asset("ANIM", "anim/goldenpitchfork.zip"),
Asset("ANIM", "anim/swap_pitchfork.zip"),
--Asset("ANIM", "anim/swap_goldenpitchfork.zip"),
Asset("IMAGE", "images/inventoryimages/smartpfp.tex"),
Asset("ATLAS", "images/inventoryimages/smartpfp.xml"),
}
local function onfinished(inst) 是的 他也有这个消耗完的指令
inst:Remove()
end
local function pickup(inst, owner)
local pt = owner:GetPosition()
inst.candig = inst.components.terraformer:CanTerraformPoint(pt)
if inst.candig then
inst.components.terraformer:Terraform(pt)
inst.SoundEmitter:PlaySound("dontstarve/wilson/dig")
inst.components.finiteuses:Use(0.25)
else
end
end
local function onequip(inst, owner)
inst.task = inst:DoPeriodicTask(0.1, function() pickup(inst, owner) end)
owner.AnimState:OverrideSymbol("swap_object", "swap_pitchfork", "swap_pitchfork")
owner.AnimState:Show("ARM_carry")
owner.AnimState:Hide("ARM_normal")
end
local function onunequip(inst, owner)
owner.AnimState:Hide("ARM_carry")
owner.AnimState:Show("ARM_normal")
if inst.task then inst.task:Cancel() inst.task = nil end
end
local function fn(Sim)
local inst = CreateEntity()
local trans = inst.entity:AddTransform()
local anim = inst.entity:AddAnimState()
inst.entity:AddSoundEmitter()
MakeInventoryPhysics(inst)
if IsDLCEnabled(CAPY_DLC) then
MakeInventoryFloatable(inst, "idle_water", "idle")
end
anim:SetBank("pitchfork")
anim:SetBuild("pitchfork")
anim:PlayAnimation("idle")
inst.AnimState:SetMultColour(0/255,0/255,0/255,1)
inst:AddTag("sharp")
-------
inst:AddComponent("finiteuses")
inst.components.finiteuses:SetMaxUses(TUNING.PITCHFORK_USES)
inst.components.finiteuses:SetUses(TUNING.PITCHFORK_USES)
inst.components.finiteuses:SetOnFinished( onfinished)
inst.components.finiteuses:SetConsumption(ACTIONS.TERRAFORM, .125)
-------
inst:AddComponent("weapon")
inst.components.weapon:SetDamage(TUNING.PITCHFORK_DAMAGE)
inst:AddInherentAction(ACTIONS.TERRAFORM)
inst:AddComponent("inspectable")
inst:AddComponent("inventoryitem")
inst.components.inventoryitem.atlasname = "images/inventoryimages/smartpfp.xml"
inst.components.inventoryitem.imagename = "smartpfp"
inst:AddComponent("terraformer")
inst:AddComponent("equippable")
inst.components.equippable:SetOnEquip( onequip )
inst.components.equippable:SetOnUnequip( onunequip )
return inst
end
--local function onequipgold(inst, owner)
--owner.AnimState:OverrideSymbol("swap_object", "swap_goldenpitchfork", "swap_goldenpitchfork")
--owner.SoundEmitter:PlaySound("dontstarve/wilson/equip_item_gold")
--owner.AnimState:Show("ARM_carry")
--owner.AnimState:Hide("ARM_normal")
--end
--local function golden(Sim)
--local inst = fn(Sim)
--inst.AnimState:SetBuild("goldenpitchfork")
--inst.components.finiteuses:SetConsumption(ACTIONS.TERRAFORM, .125 / TUNING.GOLDENTOOLFACTOR)
--inst.components.weapon.attackwear = 1 / TUNING.GOLDENTOOLFACTOR
--inst.components.researchvalue.basevalue = TUNING.RESEARCH_VALUE_GOLD_TOOL
--inst.components.equippable:SetOnEquip( onequipgold )
--return inst
--end
return Prefab( "common/inventory/smart_pf_plus", fn, assets) --,
--Prefab( "common/inventory/goldenpitchfork", golden, assets)
2016年09月29日 12点09分 19
1 2 3 4 5 6 尾页