这是长矛fn的代码 大家可以参照下。
![[滑稽]](/static/emoticons/u6ed1u7a3d.png)
因为是武器 所以有所不同。至于我为何要看武器的 这也是我的一个错误。我一直很反感现在大部分年轻人只会参照书本,结果今天不知不觉也脑残了一遍 参照触电教程搬了长矛 我应该搬帽子的 不过没差太多 配合下 咳咳。
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)