饥荒simpletgp饥荒mod怎么安装装

本周下载排行
累计下载排行
01VS2010水晶报表Crystal Report Viewer 控件 v13.0官方版01编程工具 / 278M02The Unscrambler X v10.3 破解pc版02编程工具 / 204.3M03SourceTree Windows版 v2.0.7
免费版03编程工具 / 12.3M04华表插件cell v5.25.25 免费版04编程工具 / 1.3M05AMD APP SDK v2.8 官方最新版05编程工具 / 104.8M06Java SE Runtime(jre8 64位版) 8.0.50.13 x64 官方版06编程工具 / 15.2M07索贝非编软件_Sobey EditMax v7 2.2 PRO免费版07编程工具 / 395.5M08DCU2PAS(是可以快速将DCU文件转换为汇编代码的工具) v3.0.0.1084 英文绿08编程工具 / 562KB09WingIDE Professiona破解版 v5.1.10 百度免费版09编程工具 / 333.0M10Visual Studio 2010 vs2010中文旗舰版(含MSDN版)10编程工具 / 2.53G
01SourceTree Windows版 v2.0.7
免费版01编程工具 / 12.3M02jdk7 64位 7u67 官方正式版(Java SE Development Kit 7)02编程工具 / 124.2M03华表插件cell v5.25.25 免费版03编程工具 / 1.3M04UML软件开发与建模工具Enterprise Architect v13官方中文版04编程工具 / 50.3M05VS2010水晶报表Crystal Report Viewer 控件 v13.0官方版05编程工具 / 278M06Visual Studio 2010 vs2010中文旗舰版(含MSDN版)06编程工具 / 2.53G07WingIDE Professiona破解版 v5.1.10 百度免费版07编程工具 / 333.0M08LabVIEW2014
官方中文版08编程工具 / 1.43G09UltraEdit32(ue编辑器) V20.00.0.1046 烈火汉化增强版(ue编辑器09编程工具 / 11.7M10Java SE Runtime(jre8 64位版) 8.0.50.13 x64 官方版10编程工具 / 15.2M
热门关键词
6.4M / 简体中文 / 3.911.7M / 简体中文 / 10.0399M / 英文 / 7.04.34G / 简体中文 / 10.040.9M / 简体中文 / 7.0120KB / 简体中文 / 7.0103M / 简体中文 / 10.0211.9M / 简体中文 / 7.5204.3M / 简体中文 / 0.0261.7M / 简体中文 / 10.0
装机必备软件论坛功能正在维护中...4543人阅读
lua 备忘录(6)
介绍一些组件
原文:[Introduction to some Components]
翻译: @czfshine
Prefabs(预设物), Components(组件), Stategraphs(状态图), 这一些名词意味着是什么呢?我希望它们像XYZ一样简单。
General(一般)
假设你已经熟悉基本的Lua
一个组件(component)是一些为预设件(prefabs)准备的代码,
通常组件是来描述一个单一的属性(例:生命,饥饿,攻击),
允许在一个预设件上用各种各样的创意组合各种组件,
仍然困惑于这段句话吗?
要使用一个组件,你首先需要将它添加到你的预设件:
inst:AddComponent("MyComponent")
然后你可以自定义具体的细节:
ponents.MyComponent.maxvalue = 100
ponents.MyComponent:SetSomething(true)
如果组件有提供,当你需要时你可以访问该组件的某个函数,或给组件设置一组函数:
ponents.MyComponent:BeFun()
ponents.MyComponent.befunfn = BackflipFn
这些只是理论,选择看下面一些有意义的例子! 或者最好直接去看游戏数据!
Armor(护甲)
这个组件可以使你的盔甲,具有减少玩家全部或某些类型的伤害的功能.
遗憾的是,该组件还意味着有耐久性。
重要的变量
标签——盔甲标签只有一个效果,可以抵御有一个的相同的标签的攻击。
onfinished:
移除护甲–理论上你可以使用这个更换装备或重置属性。
(function)
ontakedamage:
当受到伤害时触发
重要的函数
InitCondition(amount, absorb_percent)
初始化护甲,设置耐久度(num amount ),减伤百分比(num absorb_percent)
SetCondition(amount)
设置耐久度(num amount )
local function ruinshat_proc(inst, owner)
inst:AddTag("forcefield")
ponents.armor:SetAbsorption(TUNING.FULL_ABSORPTION)
ponents.armor.ontakedamage = function(inst, damage_amount)
if owner then
local sanity = ponents.sanity
if sanity then
local unsaneness = damage_amount * TUNING.ARMOR_RUINSHAT_DMG_AS_SANITY
sanity:DoDelta(-unsaneness, false)
inst.active = true
owner:DoTaskInTime(TUNING.ARMOR_RUINSHAT_DURATION, function()
if inst:IsValid() then
inst:RemoveTag("forcefield")
ponents.armor.ontakedamage = nil
ponents.armor:SetAbsorption(TUNING.ARMOR_RUINSHAT_ABSORPTION)
owner:DoTaskInTime(TUNING.ARMOR_RUINSHAT_COOLDOWN, function() inst.active = false end)
local function tryproc(inst, owner)
if not inst.active and math.random() & TUNING.ARMOR_RUINSHAT_PROC_CHANCE then
ruinshat_proc(inst, owner)
local function ruins_onunequip(inst, owner)
owner:RemoveEventCallback("attacked", inst.procfn)
local function ruins_onequip(inst, owner)
inst.procfn = function() tryproc(inst, owner) end
owner:ListenForEvent("attacked", inst.procfn)
local function ruins()
local inst = simple()
inst:AddComponent("armor")
ponents.armor:InitCondition(TUNING.ARMOR_RUINSHAT, TUNING.ARMOR_RUINSHAT_ABSORPTION)
ponents.equippable:SetOnEquip(ruins_onequip)
ponents.equippable:SetOnUnequip(ruins_onunequip)
return inst
Beard(胡子)
这个组件使你的生物有胡子,绝燃和剃须必须自己编码。
callbacks:
回调表–插入每天胡子的变化状态,一个函数
剃须奖励物品名,通常是“beardhair”
(string)
canshavetest:
限制能否剃须,返回布尔值与原因
(fn [ret] bln,str)
重置函数,(例:被火烧毁)
–重置,状态回到零天
beefalo.lua
local function GetStatus(inst)
if ponents.follower.leader ~= nil then
return "FOLLOWER"
elseif ponents.beard and ponents.beard.bits == 0 then
return "NAKED"
local function fn(Sim)
local hair_growth_days = 3
inst:AddComponent("beard")
ponents.beard.bits = 3
ponents.beard.daysgrowth = hair_growth_days + 1
ponents.beard.onreset = function()
inst.sg:GoToState("shaved")
ponents.beard.canshavetest = function() if not ponents.sleeper:IsAsleep() then return false, "AWAKEBEEFALO" end return true end
ponents.beard.prize = "beefalowool"
ponents.beard:AddCallback(0, function()
if ponents.beard.bits == 0 then
anim:SetBuild("beefalo_shaved_build")
ponents.beard:AddCallback(hair_growth_days, function()
if ponents.beard.bits == 0 then
inst.hairGrowthPending = true
return inst
Burnable(可燃的)
该组件允许你的预设物可以点燃和燃烧。这并不包括蔓延! (参见propagator(传播算子))
MakeSmallBurnable(inst, time, offset)
MakeMediumBurnable(inst, time, offset)
MakeLargeBurnable(inst, time, offset)
MakeSmallBurnableCharacter(inst,
sym, offset)
MakeMediumBurnableCharacter(inst, sym, offset)
MakeLargeBurnableCharacter(inst, sym, offset)
重要的变量
– 要多长时间完全燃烧
–当着火时调用
onextinguish:
– 当不再着火时调用
– 当燃烧完成时调用
–能否被点燃
–是否在燃烧
重要的函数
AddBurnFX(prefab, offset, followsymbol)
–增加特效
SetFXLevel(level, percent)
–改变火的强度
Ignite(immediate)
– 立即燃烧
Extinguish()
–停止燃烧
firepit.lua
local function onignite(inst)
if not ponents.cooker then
inst:AddComponent("cooker")
local function onextinguish(inst)
if ponents.cooker then
inst:RemoveComponent("cooker")
local function fn(Sim)
ponents.burnable:AddBurnFX("campfirefire", Vector3(0,.4,0) )
inst:ListenForEvent("onextinguish", onextinguish)
inst:ListenForEvent("onignite", onignite)
ponents.fueled:SetUpdateFn( function()
if GetSeasonManager() and GetSeasonManager():IsRaining() then
ponents.fueled.rate = 1 + TUNING.FIREPIT_RAIN_RATE*GetSeasonManager():GetPrecipitationRate()
ponents.fueled.rate = 1
注意:firepit 不会在烧焦时明确的移除它自己,不像campfire,如上面所说的,fueled 组件会帮你处理细节.
Container(容器)
这个组件可以让你的预设物可以接受主角给予物品(就像锅子或箱子一样),此外还有一个库存(inventory)组件,但是那个十分适合角色。
重要的变量
——你的预设物能够接受多少项目
widgetslotpos:
在这里设置的格子的位置(相对位置)
(table (Vector3))
canbeopened:
——能否打开
acceptsstacks:
–不接受整堆的物品
默认”chest”
——不能同时打开两个相同类型的箱子
widgetanimbank / widgetanimbuild:
widgetpos:
(相对屏幕)的位置
( Vector3)
side_align_tip:
未知的效果,但需要
itemtestfn:
widgetbuttoninfo:
这是一个交互式按钮
(table( widget))
onopenfn / onclosefn:
当打开/关闭时调用,只有在这个物品里有效
重要的函数
IsFull()/IsEmpty()
–返回true 或 false
DropEverything()
– 把箱子里的所有物品弹出
DestroyContents()
– 销毁里面所有的物品
GiveItem(item, slot, src_pos, drop_on_fail, skipsound)
–把物品给予给箱子,注意参数item是一个实例
GetItemInSlot(slot)
–返回slot里的实例
FindItems(fn)
– 返回能够导致fn返回true的项目
Has(item, amount)
– 返回是否具有该数量的物品
ConsumeByName(item, amount)
– 删除指定数量的项目
cookpot.lua
local slotpos = {
Vector3(0,64+32+8+4,0),
Vector3(0,32+4,0),
Vector3(0,-(32+4),0),
Vector3(0,-(64+32+8+4),0)}
local widgetbuttoninfo = {
text = "Cook",
position = Vector3(0, -165, 0),
fn = function(inst)
ponents.stewer:StartCooking()
validfn = function(inst)
return ponents.stewer:CanCook()
local function itemtest(inst, item, slot)
if cooking.IsCookingIngredient(item.prefab) then
return true
local function onopen(inst)
inst.AnimState:PlayAnimation("cooking_pre_loop", true)
inst.SoundEmitter:PlaySound("dontstarve/common/cookingpot_open", "open")
inst.SoundEmitter:PlaySound("dontstarve/common/cookingpot", "snd")
local function onclose(inst)
if not ponents.stewer.cooking then
inst.AnimState:PlayAnimation("idle_empty")
inst.SoundEmitter:KillSound("snd")
inst.SoundEmitter:PlaySound("dontstarve/common/cookingpot_close", "close")
local function fn(Sim)
inst:AddComponent("container")
ponents.container.itemtestfn = itemtest
ponents.container:SetNumSlots(#slotpos)
ponents.container.widgetslotpos = slotpos
ponents.container.widgetanimbank = "ui_cookpot_1x4"
ponents.container.widgetanimbuild = "ui_cookpot_1x4"
ponents.container.widgetpos = Vector3(200,0,0)
ponents.container.side_align_tip = 100
ponents.container.widgetbuttoninfo = widgetbuttoninfo
ponents.container.acceptsstacks = false
ponents.container.type = "cooker"
ponents.container.onopenfn = onopen
ponents.container.onclosefn = onclose
Cookable(烹饪)
该组件能够让你的物品能够被烹饪。
重要的变量
煮熟时得到什么物品
(str或fn)
oncooked:
在煮熟时调用。
local function defaultfn()
local inst = commonfn()
inst:AddComponent("cookable")
ponents.cookable.product = "tallbirdegg_cooked"
return inst
Dapperness(衣衫褴褛)
顾名思义,给物品一个不整洁的标签,可以按一定的速度减少人物的san值.
重要的变量
dapperness:
默认 0 速度
每当减少时调用
sweatervest.lua
local function fn(Sim)
inst:AddComponent("dapperness")
ponents.dapperness.dapperness = TUNING.DAPPERNESS_MED
return inst
Eater(吃者)
让你的预设物(通常是一个标准的动物)可以食用带有Edible(可食用的)组件的物品。
重要的变量
strongstomach:
默认false,是否可以吃有毒的东东
foodprefs:
所有能过吃的物品列表
(table )
当食用时调用
lasteattime:
上一次吃东东是什么时候
(num(GetTime() ))
ignoresspoilage:
默认false,忽略变质
caneattest:
指定什么可以吃(返回true时)
重要的函数
TimeSinceLastEating()
–类似lasteattime,你可以用它来确定什么时候可以开始吃.
基本的食物类型
ELEMENTAL (矿物),
HORRIBLE (你不想知道的)
local function OnEat(inst, food)
if ponents.edible
and ponents.edible.foodtype == "MEAT"
and ponents.werebeast
and not ponents.werebeast:IsInWereState() then
if ponents.edible:GetHealth() & 0 then
ponents.werebeast:TriggerDelta(1)
if ponents.edible and ponents.edible.foodtype == "VEGGIE" then
local poo = SpawnPrefab("poop")
poo.Transform:SetPosition(inst.Transform:GetWorldPosition())
local function fn(Sim)
inst:AddComponent("eater")
ponents.eater:SetOmnivore()
ponents.eater:SetCanEatHorrible()
ponents.eater.strongstomach = true
ponents.eater:SetOnEatFn(OnEat)
return inst
Edible(可食用的)
能够让你的物品(通常是标准的物品)可以被食用。
重要的变量
healthvalue:
–增加的生命
hungervalue:
–增加的饥饿
sanityvalue:
–增加的san
默认”GENERIC”
–孰能孰否
local function fn(Sim)
ponents.edible.foodtype = "MyFoodType"
ponents.edible.healthvalue = -10
ponents.edible.hungervalue = 0
ponents.edible.sanityvalue = 40
ponents.edible.stale_health = 2
return inst
Equippable(可装备的)
能够让你的物品(通常是一个标准的装备)可以被持有或者穿戴,当然,你需要一个可交互的动画来显示。
重要的变量
equipslot:
默认EQUIPSLOTS.HANDS
(EQUIPSLOTS.*)
equipstack:
是否需要投掷(像吹箭)
isequipped:
装备是否正在装备(只读)
onequipfn/onunequipfn:
在装备时或者卸装时调用
walkspeedmult:
加快或减慢穿戴者
local function onequip(inst, owner)
owner.AnimState:OverrideSymbol("swap_object", "swap_axe", "swap_axe")
owner.AnimState:Show("ARM_carry")
owner.AnimState:Hide("ARM_normal")
local function onunequip(inst, owner)
owner.AnimState:Hide("ARM_carry")
owner.AnimState:Show("ARM_normal")
local function fn(Sim)
inst:AddComponent("equippable")
ponents.equippable:SetOnEquip(onequip)
ponents.equippable:SetOnUnequip(onunequip)
Finite Uses(耐久)
限定物品(通常是一个标准的装备)的使用次数。
重要的变量
–最大使用次数
– 当前还剩多少
onfinished:
当耐久完了之后调用(注意,不会自动的删除它本身,你要显式调用)
重要的函数
设置当前耐久
SetConsumption(action, uses)
设置各种行动所需的耐久度
local function onfinished(inst)
inst:Remove()
local function fn(Sim)
inst:AddComponent("finiteuses")
ponents.finiteuses:SetMaxUses(TUNING.AXE_USES)
ponents.finiteuses:SetUses(TUNING.AXE_USES)
ponents.finiteuses:SetOnFinished( onfinished)
ponents.finiteuses:SetConsumption(ACTIONS.CHOP, 1)
return inst
Harvestable(收获)
可以让你的组件可以生产物品。
重要的变量
–当前拥有多少物品
maxproduce:
可以容纳多少产品
重要的函数
SetUp(product, max, time, onharvest, ongrow)
立刻生长完成
StartGrowing(time)\StopGrowing()
开始\停止生长
beebox.lua
local function onchildgoinghome(inst, data)
if data.child and ponents.pollinator and ponents.pollinator:HasCollectedEnough() then
if ponents.harvestable then
ponents.harvestable:Grow()
local function fn(Sim)
inst:AddComponent("harvestable")
ponents.harvestable:SetUp("honey", 6, nil, onharvest, updatelevel)
inst:ListenForEvent("childgoinghome", onchildgoinghome)
return inst
Health(生命)
为你的事物(通常是标准的动物或人物)增加一个生命属性。
如果该事物拥有combat(攻击)组件的话,这个是必须的.
重要的变量
minhealth:
– 如果设置这个变量&0,你的动物将不会死亡。
invincible:
– 无敌模式
vulnerabletoheatdamage:
– 能否被烧伤
fire\_damage\_scale:
– 烧伤的比例
nofadeout:
– 动画效果,死亡时是否直接删除而不会躺下
–天生的护甲值
canmurder:
– 能否被谋杀
murdersound:
– 当死亡时声音路径
– 能否治疗
– 在治疗或受伤时调用(重新定义如何受伤或治疗)
重要的函数
SetMaxHealth(amount)
– 设置最大值
DoDelta(amount, overtime, cause, ignore_invincible)
–更改状态
slurper.lua
local function fn(Sim)
inst:AddComponent("health")
ponents.health:SetMaxHealth(200)
ponents.health.canmurder = false
return inst
Hunger(饥饿)
可以让你的事物(通常是一个标准的动物或者人物)获得饥饿的属性,这个整个饥荒游戏的中心慨念
重要的变量
– 你的事物能够食用多少的物品
hungerrate,hurtrate:
– 饥饿的速度
– 是否会饿
– 减低饥饿值的间隔
smallbird.lua
local function GetStatus(inst)
if ponents.hunger then
if ponents.hunger:IsStarving(inst) then
return "STARVING"
elseif ponents.hunger:GetPercent() & .5 then
return "HUNGRY"
local function GetPeepChance(inst)
local peep_percent = 0.1
if ponents.hunger then
if ponents.hunger:IsStarving() then
peep_percent = 1
elseif ponents.hunger:GetPercent() & .25 then
peep_percent = 0.9
elseif ponents.hunger:GetPercent() & .5 then
peep_percent = 0.75
return peep_percent
local function fn(Sim)
inst:AddComponent("hunger")
ponents.hunger:SetMax(TUNING.SMALLBIRD_HUNGER)
ponents.hunger:SetRate(TUNING.SMALLBIRD_HUNGER/TUNING.SMALLBIRD_STARVE_TIME)
ponents.hunger:SetKillRate(TUNING.SMALLBIRD_HEALTH/TUNING.SMALLBIRD_STARVE_KILL_TIME)
return inst
Insulator(保暖)
让你的物品(通常是一个标准的装备)拥有保暖功能。可以降低temperature(温度)组件对人物的影响。
重要的变量
insulation:
–整个组件就是这个变量.
sweatervest.lua
inst:AddComponent("insulator")
ponents.insulator.insulation = TUNING.INSULATION_SMALL
Inventory-Item(可存放)
可以让你的物品可以被捡起存放进物品栏。通常这个组件不需要任何的设置,一切保持默认最好。
重要的变量
canbepickedup:
– 能够被捡起
onpickupfn:
– 当被捡起时调用
cangoincontainer:
–能够进入容器
keepondeath:
– 对于十分重要的角色项目或许有用?
在物品栏的图片名称
图片的图集文件
掉落时调用
参数为 inst它本身
onpickupfn
捡起时调用
onputininventoryfn
放入物品栏时调用
重要的函数
GetContainer()
返回拥有物品栏或者容器的实例
要返回它本身使用GetContainer().inst
ChangeImageName(newname)
heatrock.lua
local function UpdateImages(inst, range)
inst.currentTempRange = range
ponents.inventoryitem:ChangeImageName("heat_rock"..tostring(range))
local function inst()
inst:AddComponent("inventoryitem")
return inst
Perishable(腐败)
让你的物品会随着时间的推移慢慢的腐败,
注意,这个组件不会删除物品本身,除非你给它设置一个替换物
重要的变量
perishtime:
– 要多长时间才会完全的腐败
当腐败后调用(在替换之前)
onperishreplacement:
替换物,可为空
重要的函数
IsFresh(),IsStale(),IsSpoiled()
–返回true 或 false取决于当前的百分比
GetPercent()
返回一个介于0到1 之间的数字
SetPercent(percent)
设置百分比
ReducePercent(amount)
减低百分比
StartPerishing(),StopPerishing()
开始/结束 腐败
petals.lua
local function fn(Sim)
local inst = CreateEntity()
inst:AddComponent("perishable")
ponents.perishable:SetPerishTime(TUNING.PERISH_FAST)
ponents.perishable:StartPerishing()
ponents.perishable.onperishreplacement = "spoiled_food"
return inst
Pickable(可采摘)
这个组件类似Harvestable,不过可以移植.
重要的变量
regentime:
再生需要多长时间
onregenfn,onpickedfn,makeemptyfn,makefullfn,makebarrenfn,ontransplantfn:
当这些事件发生时调用
max_cycles,cycles_left:
– 在缺肥前可以采摘多少
caninteractwith:
–能否采摘
numtoharvest:
–每次采摘有多少果实
quickpick:
是否需要快速的采摘
重要的函数
FinishGrowing()
立即可收获
Pause(),Resume()
暂停/恢复 生长
SetUp(product, regen, numbertoharvest)
IsBarren()
返回需不需要果实
MakeBarren()
carrot.lua
local function onpickedfn(inst)
inst:Remove()
local function fn(Sim)
inst:AddComponent("pickable")
ponents.pickable.picksound = "dontstarve/wilson/pickup_plants"
ponents.pickable:SetUp("carrot", 10)
ponents.pickable.onpickedfn = onpickedfn
ponents.pickable.quickpick = true
return inst
local function ontransplantfn(inst)
if ponents.pickable then
ponents.pickable:MakeBarren()
local function onregenfn(inst)
inst.AnimState:PlayAnimation("grow")
inst.AnimState:PushAnimation("idle", true)
local function makefullfn(inst)
inst.AnimState:PlayAnimation("idle", true)
local function makebarrenfn(inst)
inst.AnimState:PlayAnimation("idle_dead")
local function onpickedfn(inst)
inst.SoundEmitter:PlaySound("dontstarve/wilson/pickup_reeds")
inst.AnimState:PlayAnimation("picking")
if ponents.pickable and ponents.pickable:IsBarren() then
inst.AnimState:PushAnimation("idle_dead")
inst.AnimState:PushAnimation("picked")
local function makeemptyfn(inst)
inst.AnimState:PlayAnimation("picked")
local function fn(Sim)
inst:AddComponent("pickable")
ponents.pickable.picksound = "dontstarve/wilson/pickup_reeds"
ponents.pickable:SetUp("cutgrass", TUNING.GRASS_REGROW_TIME)
ponents.pickable.onregenfn = onregenfn
ponents.pickable.onpickedfn = onpickedfn
ponents.pickable.makeemptyfn = makeemptyfn
ponents.pickable.makebarrenfn = makebarrenfn
ponents.pickable.makefullfn = makefullfn
ponents.pickable.max_cycles = 20
ponents.pickable.cycles_left = 20
ponents.pickable.ontransplantfn = ontransplantfn
return inst
Propagator(传播算子)
可以让你的物品可以传播火和热,即使它是不可燃的.
注意:可以使用
MakeSmallPropagator(inst)
MakeLargePropagator(inst)
改变传播速度
重要的变量
flashpoint:
–当它点燃
currentheat:
decayrate:
冷却速度单位每秒
propagaterange:
–火能传播多远
heatoutput:
–热量损失速度 每秒
–火能否伤害人物
damagerange:
–火伤害距离
acceptsheat:
能否传播给另外的物品
onflashpoint:
–点燃时调用
重要的函数
Delay(time)
StartSpreading() StopSpreading()
– 开始/停止传播热量
AddHeat(amount)
Repairable(可修理)
这个组件可以让你的物品(通常是一个标准的装备)可以在使用后修理,恢复耐久.
通常需要一个类似生命的组件来配合,如 Workable, Perishable ,都有这样的效果.
重要的变量
repairmaterial:
–需要的材料(不是预设物的名字)
announcecanfix:
–在人物查看时是否可以知道可修理
onrepaired:
–修理时调用
local function onrepaired(inst)
if data.buildsound then
inst.SoundEmitter:PlaySound(data.buildsound)
makeobstacle(inst)
local function fn(Sim)
inst:AddComponent("repairable")
if data.name == "ruins" then
ponents.repairable.repairmaterial = "thulecite"
ponents.repairable.repairmaterial = data.name
ponents.repairable.onrepaired = onrepaired
return inst
Sanity-Aura(san光环)
可以影响附近人物的san值,这个组件十分容易使用,在装备上时自动调用,参考
dapperness.
重要的变量
–速率 每秒
用来限制影响的范围
减少或增加多少san
Talker(话语者)
可以让你的事物(人物或者动物)可以说话,表现为在上方有一行字符.
重要的函数
停止说,做另外一些重要的事情.
Say(script, time, noanim)
script 可以 一个string或者table,包括另外两个变量.
local function greet(inst)
ponents.talker:Say("Good morning!")
local function fn(Sim)
inst.ListenForEvent("daytime",greet)
return inst
Tool(工具)
可以让你的物品(通常是装备)可以增加一些工具的功能.
通常与 worker,workable
这两个组件相关.
重要的函数
SetAction(act, effectiveness)
–设置你的装备能干啥,当 effectiveness = nil是删除这一行动.
axe_pickaxe.lua
local function fn(Sim)
inst:AddComponent("tool")
ponents.tool:SetAction(ACTIONS.CHOP, 1.33)
ponents.tool:SetAction(ACTIONS.MINE, 1.33)
return inst
Tradable(交易)
这个组件可以让你的物品可以和交易员交易,当然你也可以设置一个黄金价格.
local function fn(Sim)
inst:AddComponent("tradable")
ponents.tradable.goldvalue = 3
inst:AddComponent("equippable")
ponents.equippable.equipslot = EQUIPSLOTS.HEAD
ponents.equippable:SetOnEquip( onequip )
ponents.equippable:SetOnUnequip( onunequip )
return inst
Useable Item(可使用的)
这个组件可以让你的人物使用带有这个组件的物品,效果取决于你让他干什么,当别的组件不能满足时,才使用这个.
重要的变量
在人物开始使用时调用
onstopusefn
在人物停止使用时调用
caninteractfn
限制人物是否可以使用
local function stopusingbush(inst, data)
local hat = ponents.inventory and ponents.inventory:GetEquippedItem(EQUIPSLOTS.HEAD)
if hat and not (data.statename == "hide_idle" or data.statename == "hide") then
ponents.useableitem:StopUsingItem()
local function onequipbush(inst, owner)
inst:ListenForEvent("newstate", stopusingbush, owner)
local function onunequipbush(inst, owner)
inst:RemoveEventCallback("newstate", stopusingbush, owner)
local function onusebush(inst)
local owner = ponents.inventoryitem.owner
if owner then
owner.sg:GoToState("hide")
local function bush()
local inst = simple()
inst:AddTag("hide")
ponents.inventoryitem.foleysound = "dontstarve/movement/foley/bushhat"
inst:AddComponent("useableitem")
ponents.useableitem:SetOnUseFn(onusebush)
ponents.equippable:SetOnEquip( onequipbush )
ponents.equippable:SetOnUnequip( onunequipbush )
return inst
Workable(能工作的)
这个组件可以让你的物品(通常是装备)可以挖,锤,砍,…..
重要的变量
onwork,onfinish:
–在对应事件发生时调用
ACTIONS.CHOP
savestate:
是否保存状态
重要的函数
Destroy(destroyer)
SetWorkLeft(work)
–手动设置工作
tree_marsh.lua
local function chop_down_tree(inst, chopper)
ponents.workable:SetWorkAction(ACTIONS.DIG)
ponents.workable:SetOnFinishCallback(dig_up_stump)
ponents.workable:SetWorkLeft(1)
local function fn(Sim)
inst:AddComponent("workable")
ponents.workable:SetWorkAction(ACTIONS.CHOP)
ponents.workable:SetWorkLeft(10)
ponents.workable:SetOnWorkCallback(chop_tree)
ponents.workable:SetOnFinishCallback(chop_down_tree)
return inst
这不是一个组件,但是行为很像,所以在这里介绍它.
inst.entity:AddLight()
重要的函数
SetIntensity(percent)
SetRadius(number)
– 光照多远
SetFalloff(percent)
–消退速度
Enable(boolean)
SetColour(r, b, g)
–设置颜色
mininglantern.lua
local function turnon(inst)
inst.Light:Enable(true)
inst.AnimState:PlayAnimation("idle_on")
local function turnoff(inst)
inst.Light:Enable(false)
inst.AnimState:PlayAnimation("idle_off")
local function fuelupdate(inst)
local fuelpercent = ponents.fueled:GetPercent()
inst.Light:SetIntensity(Lerp(0.4, 0.6, fuelpercent))
inst.Light:SetRadius(Lerp(3, 5, fuelpercent))
inst.Light:SetFalloff(.9)
local function fn()
inst.entity:AddLight()
inst.Light:SetColour(180/255, 195/255, 150/255)
fuelupdate(inst)
&&相关文章推荐
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
访问:41022次
排名:千里之外
原创:20篇
评论:18条
(1)(1)(1)(2)(1)(1)(1)(5)(1)(1)(5)(3)
(window.slotbydup = window.slotbydup || []).push({
id: '4740881',
container: s,
size: '200,200',
display: 'inlay-fix'}

我要回帖

更多关于 腾讯饥荒mod怎么安装 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信