×.-ㄧ1n_、 发表于 2013-7-5 16:52

鱼晾干了希望可以变咸鱼 变鱼干。求修改

猪肉掉猪肉 鱼肉就是鱼肉兔肉,总是用小块肉忽悠我们

slxc920113 发表于 2013-7-5 19:26

你先提供贴图文件,就是tex那种格式,真相不知道怎么处理,代码什么的我大约可以搞定。
话说,tex是texture的缩写吧,怎么和我写论文时用的Ctex软件一个后缀。

slxc920113 发表于 2013-7-5 19:40

本帖最后由 slxc920113 于 2013-7-5 20:40 编辑

具体修改方法:添加一个全局变量。
先注册一个比如dryfish的prefabs对象,在fish.lua的开头
local assets=
{
    Asset("ANIM", "data/anim/fish.zip"),
    Asset("ANIM", "data/anim/fish01.zip"),
    Asset("IMAGE", "data/inventoryimages/fish.tex"),
    Asset("IMAGE", "data/inventoryimages/fish_cooked.tex"),
}
添加一句 Asset("IMAGE", "data/inventoryimages/fish_dried.tex"),(前提是你已经有这个贴图文件)
local prefabs =
{
    "fish_cooked",
    "spoiled_food",
}
添加一句"fish_dried"。
然后把inst.components.dryable:SetProduct("smallmeat_dried")
改成inst.components.dryable:SetProduct("fish_dried")
最后在文件中加一个函数
local function driedfish(Sim)
        local inst = common()
    inst.AnimState:SetBank("meat_rack_food")
    inst.AnimState:SetBuild("meat_rack_food")
    inst.AnimState:PlayAnimation("idle_dried_small")

    inst.components.edible.healthvalue = TUNING.HEALING_MEDSMALL
    inst.components.edible.hungervalue = TUNING.CALORIES_SMALL
    inst.components.edible.sanityvalue = TUNING.SANITY_SMALL

    inst.components.perishable:SetPerishTime(TUNING.PERISH_PRESERVED)

        inst.components.stackable.maxsize = TUNING.STACK_SIZE_SMALLITEM

    return inst
end

slxc920113 发表于 2013-7-5 20:34

然后如果对于本身不支持dryable的对象,开头一样修改。在后面的fn函数加一句:
inst:AddComponent("dryable")
    inst.components.dryable:SetProduct("*****")
    inst.components.dryable:SetDryTime(TUNING.DRY_FAST)(括号里是turning中的变量值,可以选择其他时间变量,也可以直接输入数字)
比如找一个黄油,butter.lua
ocal function fn(Sim)
        local inst = CreateEntity()
        inst.entity:AddTransform()
        inst.entity:AddAnimState()
   
    MakeInventoryPhysics(inst)
   
    inst.AnimState:SetBank("butter")
    inst.AnimState:SetBuild("butter")
    inst.AnimState:PlayAnimation("idle")
   
    inst:AddComponent("stackable")
        inst.components.stackable.maxsize = TUNING.STACK_SIZE_SMALLITEM

    inst:AddComponent("inspectable")
   
    inst:AddComponent("inventoryitem")
       
    inst:AddComponent("edible")
    inst.components.edible.healthvalue = TUNING.HEALING_LARGE
    inst.components.edible.hungervalue = TUNING.CALORIES_MED
       
        inst:AddComponent("perishable")
        inst.components.perishable:SetPerishTime(TUNING.PERISH_SUPERSLOW)
        inst.components.perishable:StartPerishing()
        inst.components.perishable.onperishreplacement = "spoiled_food"
       
   
    return inst
end
随便找一个位置(当然必须是一个inst:AddComponent写完之后)加上

rosesscarlet 发表于 2013-7-5 21:57

本帖最后由 rosesscarlet 于 2013-7-5 21:58 编辑

slxc920113 发表于 2013-7-5 19:40 http://bbs.blacksheepgame.com/static/image/common/back.gif
具体修改方法:添加一个全局变量。
先注册一个比如dryfish的prefabs对象,在fish.lua的开头
local assets=


inst.AnimState:PlayAnimation("idle_dried_small")

话说这一句要怎样写啊,是冒号么-----

slxc920113 发表于 2013-7-5 22:24

rosesscarlet 发表于 2013-7-5 21:57 static/image/common/back.gif
inst.AnimStatelayAnimation("idle_dried_small")

话说这一句要怎样写啊,是冒号么----- ...
:(半角冒号)P

只为玩单机 发表于 2013-7-5 22:26

slxc920113 发表于 2013-7-5 20:34 static/image/common/back.gif
然后如果对于本身不支持dryable的对象,开头一样修改。在后面的fn函数加一句:
inst:AddComponent("dryable ...

对于你的专业知识,在外行看来只能膜拜。。

slxc920113 发表于 2013-7-5 22:34

本帖最后由 slxc920113 于 2013-7-5 22:45 编辑

刚才没说完,在fish.lua的最后一句return fish("fish", "fish01") 后面添加
Prefab( "common/inventory/fish_dried", driedfish, assets)
当然我跟建议吧这些加到meat.lua中,而不是fish.lua中。因为这儿都是各种肉,而且有许多局部函数,免去了复制到fish.lua中的工作。

×.-ㄧ1n_、 发表于 2013-7-6 00:08

slxc920113 发表于 2013-7-5 22:34 static/image/common/back.gif
刚才没说完,在fish.lua的最后一句return fish("fish", "fish01") 后面添加
Prefab( "common/inventory/fis ...

请问贴图的话有要求是什么格式之类的么?

b0101537 发表于 2013-7-7 04:16

slxc920113 发表于 2013-7-5 19:26 static/image/common/back.gif
你先提供贴图文件,就是tex那种格式,真相不知道怎么处理,代码什么的我大约可以搞定。
话说,tex是texture ...

tex可以用官方釋出的TEXTool轉化,可將圖像image轉成tex,或是tex轉回圖像,
基本上遊戲運行都是讀取tex做運算的。
页: [1]
查看完整版本: 鱼晾干了希望可以变咸鱼 变鱼干。求修改