代码来源于“易宁”大佬的分享,仅供学习,不要直接复制粘贴。
原帖链接:http://bbs.3dmgame.com/thread-3859071-1-1.html
1
2五十七.用芦苇种植芦苇(芦苇可移植)
3
4 1.用MT管理器打开游戏目录/assets/DLC0002/scripts/prefabs/cutreeds.lua文件,在inst:AddComponent("inspectable")的下一行插入以下内容:
5
6local function OnDeploy (inst, pt)
7 SpawnPrefab("reeds").Transform:SetPosition(pt.x, pt.y, pt.z)
8 inst.components.stackable:Get():Remove()
9end
10 inst:AddComponent("deployable")
11 inst.components.deployable.ondeploy = OnDeploy
12
13
14 2.用MT管理器打开游戏目录/assets/scripts/prefabs/reeds.lua文件,在inst:AddComponent("inspectable")的下一行插入以下内容:
15
16local function dig_up(inst, chopper)
17 inst.components.lootdropper:SpawnLootPrefab("cutreeds")
18 inst:Remove()
19end
20 inst:AddComponent("workable")
21 inst.components.workable:SetWorkAction(ACTIONS.DIG)
22 inst.components.workable:SetOnFinishCallback(dig_up)
23 inst.components.workable:SetWorkLeft(1)
24 inst:AddComponent("lootdropper")
25
26 即可让芦苇可以被铲子铲掉得芦苇,用芦苇可种芦苇,使芦苇可移植