Rabby Posted August 15, 2022 Share Posted August 15, 2022 my code is if s_working_s and inst.components.workable ~= nil then if inst.components.workable.SetWorkLeft ~= nil then inst.components.workable.SetWorkLeft = inst.components.workable.SetWorkLeft * math.floor(Rand^0.5+0.5) end end "s_working_s" is on/off "Rand" is scale number, can down to 0.1 and up to 20 but this code not working. (test to evergreen_tall tree) i suspect if inst.components.workable then inst.components.workable:SetWorkLeft(TUNING.EVERGREEN_CHOPS_SMALL) end if inst.components.workable then inst.components.workable:SetWorkLeft(TUNING.EVERGREEN_CHOPS_NORMAL) end if inst.components.workable then inst.components.workable:SetWorkLeft(TUNING.EVERGREEN_CHOPS_TALL) end this code how can i change setworkleft? (sorry not good english) *also tried change TUNING code, but failed. there is no guide about TUNING.lua... or just i couldn't find it? **I wrote this question DS forum(mistake) and get answer like those SetWorkLeft is a function, not a variable. SetWorkLeft sets the workleft variable, that you can modify the way you want. local workable_comp = inst.components.workable if s_working_s and workable_comp and workable_comp.workleft then workable_comp:SetWorkLeft(workable_comp.workleft * math.floor(Rand^0.5+0.5)) end The SetWorkLeft function: function Workable:SetWorkLeft(work) if not self.workable then self.workable = true end work = work or 10 work = (work <= 0 and 1) or work if self.maxwork > 0 then work = (work > self.maxwork and self.maxwork) or work end self.workleft = work end TUNING is simply a table in the global environment that contains many values for various aspects of the game. You can easily change them. E.g. GLOBAL.TUNING.EVERGREEN_CHOPS_NORMAL = GLOBAL.TUNING.EVERGREEN_CHOPS_NORMAL * math.floor(Rand^0.5+0.5) but these 2 ways not works for me. it is DS code and DST code diff or just can't edit workleft?? Link to comment https://forums.kleientertainment.com/forums/topic/142617-i-want-to-edit-workleft/ Share on other sites More sharing options...
Bumber64 Posted August 16, 2022 Share Posted August 16, 2022 The code with workable_comp should work, provided Rand is properly defined. Where are you putting this code? Link to comment https://forums.kleientertainment.com/forums/topic/142617-i-want-to-edit-workleft/#findComment-1594439 Share on other sites More sharing options...
Rabby Posted August 16, 2022 Author Share Posted August 16, 2022 9 hours ago, Bumber64 said: The code with workable_comp should work, provided Rand is properly defined. Where are you putting this code? Spoiler local function qianghua(inst,selecting_scale,loot) inst.max_setscale = selecting_scale local Rand2 = inst.myscale ~= nil and inst.myscale or math.random(table.contains(s_sizing_1,inst.prefab) and 30 or 1,selecting_scale) local s_random_s = 0.25 -- 1% if Rand2 < 2 then -- 2% s_random_s = 0.25 elseif Rand2 < 20 then -- 18% s_random_s = 0 + math.random(3, 5)/10 elseif Rand2 < 35 then -- 15%, s_random_s = 0 + math.random(6, 9)/10 elseif Rand2 < 70 then -- 35% s_random_s = 1 elseif Rand2 < 80 then -- 10% s_random_s = 1 + math.random(1, 5)/10 elseif Rand2 < 85 then -- 5% s_random_s = 1 + math.random(6, 10)/10 elseif Rand2 < 89 then -- 4% s_random_s = 2 + math.random(1, 5)/10 elseif Rand2 < 93 then -- 4% s_random_s = 2 + math.random(6, 10)/10 elseif Rand2 < 95 then -- 2% s_random_s = 3 + math.random(1, 5)/10 elseif Rand2 < 97 then -- 2% s_random_s = 3 + math.random(6, 10)/10 elseif Rand2 < 99 then -- 2% s_random_s = 4 + math.random(1, 5)/10 elseif Rand2 <= 100 then -- 1% s_random_s = 4 + math.random(6, 10)/10 end local Rand = inst.myscale ~= nil and inst.myscale or s_random_s local Scale = inst.Transform:GetScale() if not Scale then return end if inst:HasTag("scaling_monster") then inst.AnimState:SetScale(Scale*math.ceil(math.sqrt(Rand)*10)/10, Scale*math.ceil(math.sqrt(Rand)*10)/10, Scale*math.ceil(math.sqrt(Rand)*10)/10) else inst.Transform:SetScale(Scale*math.ceil(math.sqrt(Rand)*10)/10, Scale*math.ceil(math.sqrt(Rand)*10)/10, Scale*math.ceil(math.sqrt(Rand)*10)/10) end if inst.components.aura and Rand > 1 then -- Aura inst.components.aura.radius = inst.components.aura.radius *math.ceil(math.sqrt(Rand)*10)/10 end if Xueliang then -- HP if inst.components.health ~= nil and not inst:HasTag("frog_hp_scale") then if inst.prefab == "rocky" or not inst.myscale then local percent = inst.components.health:GetPercent() inst.components.health:SetMaxHealth(inst.components.health.maxhealth * Rand) inst.components.health:SetPercent(percent) end elseif inst.components.health ~= nil and inst:HasTag("frog_hp_scale") then if inst.prefab == "rocky" or not inst.myscale then local percent = inst.components.health:GetPercent() inst.components.health:SetMaxHealth(math.ceil(inst.components.health.maxhealth * math.min(Rand, 2))) inst.components.health:SetPercent(percent) end end end if FanWei then -- Range if inst.components.combat then if Rand <= 1 then inst.components.combat.hitrange = inst.components.combat.hitrange * math.floor(math.sqrt(Rand)*10)/10 inst.components.combat.attackrange = inst.components.combat.attackrange * math.floor(math.sqrt(Rand)*10)/10 elseif Rand <= 2 then inst.components.combat.hitrange = inst.components.combat.hitrange * 0.85 * math.floor(math.sqrt(Rand)*10)/10 inst.components.combat.attackrange = inst.components.combat.attackrange * 0.8 * math.floor(math.sqrt(Rand)*10)/10 elseif Rand <= 3 then inst.components.combat.hitrange = inst.components.combat.hitrange * 0.82 * math.floor(math.sqrt(Rand)*10)/10 inst.components.combat.attackrange = inst.components.combat.attackrange * 0.77 * math.floor(math.sqrt(Rand)*10)/10 elseif Rand <= 4 then inst.components.combat.hitrange = inst.components.combat.hitrange * 0.8 * math.floor(math.sqrt(Rand)*10)/10 inst.components.combat.attackrange = inst.components.combat.attackrange * 0.75 * math.floor(math.sqrt(Rand)*10)/10 elseif Rand <= 5 then inst.components.combat.hitrange = inst.components.combat.hitrange * 0.75 * math.floor(math.sqrt(Rand)*10)/10 inst.components.combat.attackrange = inst.components.combat.attackrange * 0.7 * math.floor(math.sqrt(Rand)*10)/10 elseif Rand <= 6 then inst.components.combat.hitrange = inst.components.combat.hitrange * 0.72 * math.floor(math.sqrt(Rand)*10)/10 inst.components.combat.attackrange = inst.components.combat.attackrange * 0.65 * math.floor(math.sqrt(Rand)*10)/10 elseif Rand <= 7 then inst.components.combat.hitrange = inst.components.combat.hitrange * 0.7 * math.floor(math.sqrt(Rand)*10)/10 inst.components.combat.attackrange = inst.components.combat.attackrange * 0.62 * math.floor(math.sqrt(Rand)*10)/10 elseif Rand <= 8 then inst.components.combat.hitrange = inst.components.combat.hitrange * 0.69 * math.floor(math.sqrt(Rand)*10)/10 inst.components.combat.attackrange = inst.components.combat.attackrange * 0.61 * math.floor(math.sqrt(Rand)*10)/10 elseif Rand <= 9 then inst.components.combat.hitrange = inst.components.combat.hitrange * 0.68 * math.floor(math.sqrt(Rand)*10)/10 inst.components.combat.attackrange = inst.components.combat.attackrange * 0.6 * math.floor(math.sqrt(Rand)*10)/10 elseif Rand <= 10 then inst.components.combat.hitrange = inst.components.combat.hitrange * 0.67 * math.floor(math.sqrt(Rand)*10)/10 inst.components.combat.attackrange = inst.components.combat.attackrange * 0.59 * math.floor(math.sqrt(Rand)*10)/10 end end end if Gongji then -- Damage if inst.components.combat then if inst.components.domesticatable ~= nil and inst.components.domesticatable:IsDomesticated() then Rand = math.min(Rand) end inst.components.combat.defaultdamage = math.ceil(inst.components.combat.defaultdamage * math.floor((Rand^0.5)*10)/10) end end if diaoluo and loot and not inst:HasTag("structure") then -- Dropping Creature if inst.components.lootdropper ~= nil and not inst:HasTag("s_resource") then local beishu = math.floor(Rand+0.5) if beishu < 1 then beishu = 1 end local old = inst.components.lootdropper.DropLoot inst.components.lootdropper.DropLoot = function(self,pt) for k = 1, beishu do old(self,pt) end end if inst.prefab == "rock_ice" then local old1 = inst.components.lootdropper.SpawnLootPrefab inst.components.lootdropper.SpawnLootPrefab = function(self,lootprefab, pt, linked_skinname, skin_id, userid) for k = 1, beishu do old1(self,lootprefab, pt, linked_skinname, skin_id, userid) end end end if inst.prefab == "rock_ice_frost" then local old1 = inst.components.lootdropper.SpawnLootPrefab inst.components.lootdropper.SpawnLootPrefab = function(self,lootprefab, pt, linked_skinname, skin_id, userid) for k = 1, beishu do old1(self,lootprefab, pt, linked_skinname, skin_id, userid) end end end end local beishu = math.floor(Rand+0.5) if beishu < 1 then beishu = 1 end if beishu > 1 and inst.prefab == "tumbleweed" and inst.loot ~= nil and next(inst.loot) then local newloot = {} for k = 1,beishu -1 do for i, v in ipairs(inst.loot) do table.insert(newloot, v) end end for i, v in ipairs(newloot) do table.insert(inst.loot, v) end end end if diaoluo and loot and not inst:HasTag("structure") then local beishu3 = math.floor(Rand+0.5) if beishu3 < 1 then beishu3 = 1 end if inst.components.lootdropper ~= nil and inst:HasTag("s_resource") then local old2 = inst.components.lootdropper.DropLoot inst.components.lootdropper.DropLoot = function(self,pt) for k = 1, beishu3 do old2(self,pt) end end end end if caiji and inst.components.pickable then -- Dropping Pick local size = 1 if Rand > 4.5 then size = 5 elseif Rand > 3.5 then size = 4 elseif Rand > 2.5 then size = 3 elseif Rand > 1.5 then size = 2 end inst.components.pickable.numtoharvest = inst.components.pickable.numtoharvest*size end ---테스트 local workable_comp = inst.components.workable if s_working_s and workable_comp and workable_comp.workleft then workable_comp:SetWorkLeft(workable_comp.workleft * math.floor(Rand^0.5+0.5)) end ---테스트 if PengZhuang and inst.Physics ~= nil and not inst:HasTag("bird") and not table.contains(teshujianzhu,inst.prefab) and -- Collision not inst:HasTag("weighable_OVERSIZEDVEGGIES") and not inst:HasTag("heavy") then local radius = inst.Physics:GetRadius() or 0 local height = inst.Physics:GetHeight() or 2 inst.Physics:SetCapsule(radius * math.floor(math.sqrt(Rand)*10)/10, height) end inst.myscale = Rand end + evergreen function Spoiler s_evergreen = GetModConfigData("10_evergreen_scale") if GetModConfigData("10_evergreen") == true then local aaaaaaaaaaag = { "evergreen", } for k, v in pairs(aaaaaaaaaaag) do AddPrefabPostInit(v, function(inst) if not GLOBAL.TheWorld.ismastersim then return inst end inst:DoTaskInTime(0, function(...) qianghua(inst,s_evergreen,true) end) saveandload(inst) end) end end Link to comment https://forums.kleientertainment.com/forums/topic/142617-i-want-to-edit-workleft/#findComment-1594482 Share on other sites More sharing options...
Rabby Posted August 16, 2022 Author Share Posted August 16, 2022 OHHHHHHHHHHHHHHHHHHHHHHHHH I did it it should be prefabs name "_tall" and i just realized i do not wrote s_working_s = GetModConfigData("s_working_s")... i am idiot Link to comment https://forums.kleientertainment.com/forums/topic/142617-i-want-to-edit-workleft/#findComment-1594488 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