Rabby Posted August 3, 2022 Share Posted August 3, 2022 like hamlet DLC, I want to make Tropical Experience mod's Tall grass, Vine bush, bamboo tree can be dug without hack. but I don't know how though i purchased Hamlet DLC for data 'bamboo.lua'. Spoiler local assets= { Asset("ANIM", "anim/bush_vine.zip"), } local prefabs = { "vine", "dug_bush_vine", "hacking_fx", } local respawndays = 2 --tempo para renascer em dias local function OnTimerDone(inst, data) if data.name == "spawndelay" then inst.AnimState:PlayAnimation("grow") -- inst.AnimState:PushAnimation("sway", true) inst.AnimState:PushAnimation("idle",true) inst:AddTag("machetecut") inst.components.workable:SetWorkLeft(6) inst.components.workable:SetWorkAction(ACTIONS.HACK) if inst.prefab ~= "oceanbush_vine" then MakeObstaclePhysics(inst, 0.35) end end end local function dig_up(inst, worker) if inst:HasTag("machetecut") then inst:RemoveTag("machetecut") inst.components.workable:SetWorkAction(ACTIONS.DIG) inst.components.workable:SetWorkLeft(1) inst.components.lootdropper:SpawnLootPrefab("vine") inst.components.timer:StartTimer("spawndelay", 60*8*respawndays) return end if not inst:HasTag("machetecut") then if inst.components.lootdropper ~= nil then inst.components.lootdropper:SpawnLootPrefab("dug_bush_vine") end inst:Remove() end end local function onhackedfn(inst, hacker, hacksleft) if not inst:HasTag("machetecut") then return end local fx = SpawnPrefab("hacking_fx") local x, y, z= inst.Transform:GetWorldPosition() fx.Transform:SetPosition(x,y + math.random()*2,z) if(hacksleft <= 0) then inst.AnimState:PlayAnimation("disappear") inst.AnimState:PushAnimation("hacked_idle") inst.SoundEmitter:PlaySound("dontstarve_DLC002/common/vine_drop") if inst.prefab ~= "oceanbush_vine" then RemovePhysicsColliders(inst) end else inst.AnimState:PlayAnimation("chop") inst.AnimState:PushAnimation("idle") end inst.SoundEmitter:PlaySound("dontstarve_DLC002/common/vine_hack") end local function OnSave(inst, data) if not inst:HasTag("machetecut") then data.tag = 1 end end local function OnLoad(inst, data) if data and data.tag == 1 then inst.AnimState:PlayAnimation("hacked_idle") inst:RemoveTag("machetecut") inst.components.workable:SetWorkAction(ACTIONS.DIG) inst.components.workable:SetWorkLeft(1) if inst.prefab ~= "oceanbush_vine" then RemovePhysicsColliders(inst) end end end local function fn() local inst = CreateEntity() inst.entity:AddTransform() inst.entity:AddAnimState() inst.entity:AddMiniMapEntity() inst.entity:AddSoundEmitter() inst.entity:AddNetwork() inst.MiniMapEntity:SetIcon("bushVine.png" ) inst.AnimState:SetRayTestOnBB(true) inst.AnimState:SetBank("bush_vine") inst.AnimState:SetBuild("bush_vine") inst.AnimState:PlayAnimation("idle",true) --MakeObstaclePhysics(inst, 0.35) MakeSmallObstaclePhysics(inst, .1) inst:AddTag("machetecut") inst:AddTag("plant") inst:AddTag("bush_vine") inst.entity:SetPristine() if not TheWorld.ismastersim then return inst end inst.AnimState:SetTime(math.random() * 2) inst:AddComponent("interactions") inst:AddComponent("inspectable") inst:AddComponent("lootdropper") inst:AddComponent("timer") inst:ListenForEvent("timerdone", OnTimerDone) inst:AddComponent("workable") inst.components.workable:SetWorkAction(ACTIONS.HACK) inst.components.workable:SetOnFinishCallback(dig_up) inst.components.workable:SetWorkLeft(6) inst.components.workable.onwork = onhackedfn MakeMediumBurnable(inst) MakeSmallPropagator(inst) MakeHauntableIgnite(inst) inst.OnSave = OnSave inst.OnLoad = OnLoad return inst end local DAMAGE_SCALE = 0.5 local function OnCollide(inst, data) local boat_physics = data.other.components.boatphysics if boat_physics ~= nil then local hit_velocity = math.floor(math.abs(boat_physics:GetVelocity() * data.hit_dot_velocity) * DAMAGE_SCALE / boat_physics.max_velocity + 0.5) inst.components.workable:WorkedBy(data.other, hit_velocity * TUNING.SEASTACK_MINE) end end local function fn1() local inst = CreateEntity() inst.entity:AddTransform() inst.entity:AddAnimState() inst.entity:AddMiniMapEntity() inst.entity:AddSoundEmitter() inst.entity:AddNetwork() inst.MiniMapEntity:SetIcon("bushVine.png" ) inst.AnimState:SetRayTestOnBB(true) inst.AnimState:SetBank("bush_vine") inst.AnimState:SetBuild("bush_vine") inst.AnimState:PlayAnimation("idle",true) inst:AddTag("machetecut") inst:AddTag("plant") inst:AddTag("bush_vine") inst:AddTag("ignorewalkableplatforms") inst:SetPhysicsRadiusOverride(1.8) MakeWaterObstaclePhysics(inst, 0.35, 2, 1.25) inst:AddTag("ignorewalkableplatforms") inst:SetPrefabNameOverride("bush_vine") MakeInventoryFloatable(inst, "med", 0, {1.1, 0.6, 1.1}) inst.components.floater.bob_percent = 0 local land_time = (POPULATING and math.random()*5*FRAMES) or 0 inst:DoTaskInTime(land_time, function(inst) inst.components.floater:OnLandedServer() end) inst.entity:SetPristine() if not TheWorld.ismastersim then return inst end inst.AnimState:SetTime(math.random() * 2) inst:AddComponent("interactions") inst:AddComponent("inspectable") inst:AddComponent("lootdropper") inst:AddComponent("timer") inst:ListenForEvent("timerdone", OnTimerDone) inst:AddComponent("workable") inst.components.workable:SetWorkAction(ACTIONS.HACK) inst.components.workable:SetOnFinishCallback(dig_up) inst.components.workable:SetWorkLeft(6) inst.components.workable.onwork = onhackedfn MakeMediumBurnable(inst) MakeSmallPropagator(inst) MakeHauntableIgnite(inst) inst.OnSave = OnSave inst.OnLoad = OnLoad inst:ListenForEvent("on_collide", OnCollide) return inst end return Prefab("bush_vine", fn, assets, prefabs), Prefab("oceanbush_vine", fn1, assets, prefabs) this is bush_vine.lua in TE(Tropical Experience) Spoiler local assets= { Asset("ANIM", "anim/bush_vine.zip"), Asset("MINIMAP_IMAGE", "bushVine"), } local prefabs = { "vine", "dug_bush_vine", "hacking_fx", } local function ontransplantfn(inst) if inst.components.hackable then inst.components.hackable:MakeBarren() end end local function dig_up(inst, chopper) if inst.components.hackable and inst.components.hackable:CanBeHacked() then inst.components.lootdropper:SpawnLootPrefab("vine") end if inst.components.hackable and not inst.components.hackable.withered then local bush = inst.components.lootdropper:SpawnLootPrefab("dug_bush_vine") else inst.components.lootdropper:SpawnLootPrefab("vine") end inst:Remove() end local function onregenfn(inst) inst.AnimState:PlayAnimation("grow") inst.AnimState:PushAnimation("idle", true) inst.Physics:SetCollides(true) end local function makeemptyfn(inst) if inst.components.hackable and inst.components.hackable.withered then inst.AnimState:PlayAnimation("dead_to_empty") inst.AnimState:PushAnimation("hacked_idle") else inst.AnimState:PlayAnimation("hacked_idle") end inst.Physics:SetCollides(false) end local function makebarrenfn(inst) if inst.components.hackable and inst.components.hackable.withered then if not inst.components.hackable.hasbeenhacked then inst.AnimState:PlayAnimation("full_to_dead") else inst.AnimState:PlayAnimation("empty_to_dead") end inst.AnimState:PushAnimation("idle_dead") else inst.AnimState:PlayAnimation("idle_dead") end inst.Physics:SetCollides(true) end local function onhackedfn(inst, hacker, hacksleft) local fx = SpawnPrefab("hacking_fx") local x, y, z= inst.Transform:GetWorldPosition() fx.Transform:SetPosition(x,y + math.random()*2,z) if(hacksleft <= 0) then inst.AnimState:PlayAnimation("disappear") if inst.components.hackable and inst.components.hackable:IsBarren() then inst.AnimState:PushAnimation("idle_dead") inst.Physics:SetCollides(true) else inst.Physics:SetCollides(false) inst.SoundEmitter:PlaySound("dontstarve_DLC002/common/vine_drop") inst.AnimState:PushAnimation("hacked_idle") end else inst.AnimState:PlayAnimation("chop") inst.AnimState:PushAnimation("idle") end inst.SoundEmitter:PlaySound("dontstarve_DLC002/common/vine_hack") end local function inspect_vine(inst) if inst:HasTag("burnt") then return "BURNT" elseif inst:HasTag("stump") then return "CHOPPED" end end local function makefn(stage) local function fn(Sim) local inst = CreateEntity() local trans = inst.entity:AddTransform() local anim = inst.entity:AddAnimState() local sound = inst.entity:AddSoundEmitter() local minimap = inst.entity:AddMiniMapEntity() minimap:SetIcon( "bushVine.png" ) anim:SetBank("bush_vine") anim:SetBuild("bush_vine") anim:PlayAnimation("idle",true) anim:SetTime(math.random()*2) local color = 0.75 + math.random() * 0.25 anim:SetMultColour(color, color, color, 1) inst:AddTag("vine") inst:AddTag("plant") inst:AddComponent("hackable") inst.components.hackable:SetUp("vine", TUNING.VINE_REGROW_TIME) inst.components.hackable.onregenfn = onregenfn inst.components.hackable.onhackedfn = onhackedfn inst.components.hackable.makeemptyfn = makeemptyfn inst.components.hackable.makebarrenfn = makebarrenfn inst.components.hackable.max_cycles = 20 inst.components.hackable.cycles_left = 20 inst.components.hackable.ontransplantfn = ontransplantfn inst.components.hackable.hacksleft = TUNING.VINE_HACKS inst.components.hackable.maxhacks = TUNING.VINE_HACKS local variance = math.random() * 4 - 2 inst.makewitherabletask = inst:DoTaskInTime(TUNING.WITHER_BUFFER_TIME + variance, function(inst) inst.components.hackable:MakeWitherable() end) if stage == 1 then inst.components.hackable:MakeBarren() end inst:AddComponent("lootdropper") inst:AddComponent("inspectable") inst.components.inspectable.getstatus = inspect_vine inst:AddComponent("workable") inst.components.workable:SetWorkAction(ACTIONS.DIG) inst.components.workable:SetOnFinishCallback(dig_up) inst.components.workable:SetWorkLeft(1) MakeHackableBlowInWindGust(inst, TUNING.VINE_WINDBLOWN_SPEED, TUNING.VINE_WINDBLOWN_FALL_CHANCE) --------------------- MakeMediumBurnable(inst) MakeSmallPropagator(inst) inst.components.burnable:MakeDragonflyBait(1) MakeObstaclePhysics(inst, .35) --MakeNoGrowInWinter(inst) --------------------- return inst end return fn end local function vine(name, stage) return Prefab("forest/objects/"..name, makefn(stage), assets, prefabs) end return vine("bush_vine", 0), vine("depleted_bush_vine", 1) this is vine.lua in Hamlet Databundle. I thought Spoiler [[ local function dig_up(inst, worker) if inst:HasTag("machetecut") then inst:RemoveTag("machetecut") inst.components.workable:SetWorkAction(ACTIONS.DIG) inst.components.workable:SetWorkLeft(1) inst.components.lootdropper:SpawnLootPrefab("vine") inst.components.timer:StartTimer("spawndelay", 60*8*respawndays) return end ]] This part should be edited to Spoiler [[ local function dig_up(inst, chopper) if inst.components.hackable and inst.components.hackable:CanBeHacked() then inst.components.lootdropper:SpawnLootPrefab("vine") end if inst.components.hackable and not inst.components.hackable.withered then local bush = inst.components.lootdropper:SpawnLootPrefab("dug_bush_vine") else inst.components.lootdropper:SpawnLootPrefab("vine") end inst:Remove() end ]] I tried this 2 hours, but nothing worked. Link to comment https://forums.kleientertainment.com/forums/topic/142339-cant-make-dighack-same-time/ Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now