TemporarySolutn Posted June 29, 2019 Share Posted June 29, 2019 Im trying to edit wormwood and I assume that to edit it id have top get wormwood.lua and edit it but im not sure how I would actually have my modmain.lua include it and actually use it. Link to comment Share on other sites More sharing options...
Wolf_EX Posted June 29, 2019 Share Posted June 29, 2019 (edited) You would copy wormwood.lua into your mods scrips/prefabs folder and add it to the PrefabFiles in the modmain like any other prefab in a mod, but I would advise against modding it like that unless you have no other option. It's better to use AddPrefabPostInit("wormwood", myfunction). Edited June 29, 2019 by Wolf_EX Link to comment Share on other sites More sharing options...
Ultroman Posted June 29, 2019 Share Posted June 29, 2019 Definitely DO NOT copy/paste a game file into your mod folder, unless you're absolutely sure about what you're doing. Use the mod utility functions, like Wolf_EX said. Describe what you want to do. Maybe there's already a post on the forum where it is solved, or we can help you get started. Link to comment Share on other sites More sharing options...
TemporarySolutn Posted July 23, 2019 Author Share Posted July 23, 2019 On 6/29/2019 at 7:29 PM, Ultroman said: Definitely DO NOT copy/paste a game file into your mod folder, unless you're absolutely sure about what you're doing. Use the mod utility functions, like Wolf_EX said. Describe what you want to do. Maybe there's already a post on the forum where it is solved, or we can help you get started. Literally trying to use the regen code you gave me lmao Link to comment Share on other sites More sharing options...
Hornete Posted July 23, 2019 Share Posted July 23, 2019 Just now, JustCrimson said: Literally trying to use the regen code you gave me lmao What are you trying to do? Link to comment Share on other sites More sharing options...
TemporarySolutn Posted July 23, 2019 Author Share Posted July 23, 2019 2 minutes ago, Hornete said: What are you trying to do? Give wormwood a passive regen as long as its raining and his wetness is below a certain amount. I also want to give him custom lines when it starts raining and he hits the wetness threshold but im not sure how to do that part at all Link to comment Share on other sites More sharing options...
Hornete Posted July 23, 2019 Share Posted July 23, 2019 Just now, JustCrimson said: Give wormwood a passive regen as long as its raining and his wetness is below a certain amount. I also want to give him custom lines when it starts raining and he hits the wetness threshold but im not sure how to do that part at all AddPrefabPostInit("wormwood", function(inst) if not TheWorld.ismastersim then return end inst:DoPeriodicTask(1, function() if inst.components.moisture.moisture == 0 then print("No health regen") else if inst.components.moisture.moisture > 80 then --Over 80 stops the health -regen, you can adjust this to what you'd like print("Too wet!") else inst.components.health:DoDelta(1) --Heals 1 hp every secound, you can adjust this end end end) end) Tell me how that works Link to comment Share on other sites More sharing options...
TemporarySolutn Posted July 23, 2019 Author Share Posted July 23, 2019 attempt to index global "TheWorld" (a nill value) also what does this do 4 minutes ago, Hornete said: if not TheWorld.ismastersim then return end Link to comment Share on other sites More sharing options...
Hornete Posted July 23, 2019 Share Posted July 23, 2019 Just now, JustCrimson said: Put, GLOBAL.TheWorld. That is for optimastion. Link to comment Share on other sites More sharing options...
TemporarySolutn Posted July 23, 2019 Author Share Posted July 23, 2019 3 minutes ago, Hornete said: Put, GLOBAL.TheWorld. That is for optimastion. my game appears to be permanently loading now lmao nvm restart fixed its working, so now all i need is to add the custom lines (which i still dont know how to do) thanks Link to comment Share on other sites More sharing options...
Hornete Posted July 23, 2019 Share Posted July 23, 2019 Just now, JustCrimson said: my game appears to be permanently loading now lmao nvm restart fixed its working, so now all i need is to add the custom lines (which i still dont know how to do) thanks STRINGS.CHARACTER.WORMWOOD.ANNOUNCE_DAMP = "Rain!", STRINGS.CHARACTER.WORMWOOD.ANNOUNCE_WET = "Little wet", STRINGS.CHARACTER.WORMWOOD.ANNOUNCE_WETTER = "Really wet", STRINGS.CHARACTER.WORMWOOD.ANNOUNCE_SOAKED = "Too wet!", Put those lines in your modmain.lua and put local STRINGS = GLOBAL.STRINGS before these lines, and edit the strings as you wish. Link to comment Share on other sites More sharing options...
TemporarySolutn Posted July 23, 2019 Author Share Posted July 23, 2019 2 minutes ago, Hornete said: STRINGS.CHARACTER.WORMWOOD.ANNOUNCE_DAMP = "Rain!", STRINGS.CHARACTER.WORMWOOD.ANNOUNCE_WET = "Little wet", STRINGS.CHARACTER.WORMWOOD.ANNOUNCE_WETTER = "Really wet", STRINGS.CHARACTER.WORMWOOD.ANNOUNCE_SOAKED = "Too wet!", Put those lines in your modmain.lua and put local STRINGS = GLOBAL.STRINGS before these lines, and edit the strings as you wish. apparently items become slippery at wetness level 35? is there any way i could change this for wormwood (also thanks two times) Link to comment Share on other sites More sharing options...
Hornete Posted July 23, 2019 Share Posted July 23, 2019 Just now, JustCrimson said: apparently items become slippery at wetness level 35? is there any way i could change this for wormwood (also thanks two times) AddPrefabPostInit("wormwood", function(inst) if not GLOBAL.TheWorld.ismastersim then return end inst:DoPeriodicTask(1, function() if inst.components.moisture.moisture == 0 then print("No health regen") else if inst.components.moisture.moisture > 80 then --Over 80 stops the health -regen, you can adjust this to what you'd like print("Too wet!") else inst.components.health:DoDelta(1) --Heals 1 hp every secound, you can adjust this end end end) local function DropWetTool(inst, data) --Tool slip. if inst.components.moisture:GetSegs() < 6 then return end local tool = inst.components.inventory:GetEquippedItem(GLOBAL.EQUIPSLOTS.HANDS) if tool ~= nil and tool:GetIsWet() and math.random() < easing.inSine(GLOBAL.TheWorld.state.wetness, 0, .15, inst.components.moisture:GetMaxMoisture()) then local projectile = data.weapon ~= nil and data.projectile == nil and (data.weapon.components.projectile ~= nil or data.weapon.components.complexprojectile ~= nil) if projectile then local num = data.weapon.components.stackable ~= nil and data.weapon.components.stackable:StackSize() or 1 if num <= 1 then return end inst.components.inventory:Unequip(GLOBAL.EQUIPSLOTS.HANDS, true) tool = data.weapon.components.stackable:Get(num - 1) tool.Transform:SetPosition(inst.Transform:GetWorldPosition()) if tool.components.inventoryitem ~= nil then tool.components.inventoryitem:OnDropped() end else inst.components.inventory:Unequip(GLOBAL.EQUIPSLOTS.HANDS, true) inst.components.inventory:DropItem(tool) end if tool.Physics ~= nil then local x, y, z = tool.Transform:GetWorldPosition() tool.Physics:Teleport(x, .3, z) local angle = (math.random() * 20 - 10) * DEGREES if data.target ~= nil and data.target:IsValid() then local x1, y1, z1 = inst.Transform:GetWorldPosition() x, y, z = data.target.Transform:GetWorldPosition() angle = angle + ( (x1 == x and z1 == z and math.random() * 2 * PI) or (projectile and math.atan2(z - z1, x - x1)) or math.atan2(z1 - z, x1 - x) ) else angle = angle + math.random() * 2 * PI end local speed = projectile and 2 + math.random() or 3 + math.random() * 2 tool.Physics:SetVel(math.cos(angle) * speed, 10, math.sin(angle) * speed) end end end end) Uh, try this? I'm not too sure if this'd work. I made the slipperyness happen at 60 wetness. Link to comment Share on other sites More sharing options...
TemporarySolutn Posted July 23, 2019 Author Share Posted July 23, 2019 12 minutes ago, Hornete said: AddPrefabPostInit("wormwood", function(inst) if not GLOBAL.TheWorld.ismastersim then return end inst:DoPeriodicTask(1, function() if inst.components.moisture.moisture == 0 then print("No health regen") else if inst.components.moisture.moisture > 80 then --Over 80 stops the health -regen, you can adjust this to what you'd like print("Too wet!") else inst.components.health:DoDelta(1) --Heals 1 hp every secound, you can adjust this end end end) local function DropWetTool(inst, data) --Tool slip. if inst.components.moisture:GetSegs() < 6 then return end local tool = inst.components.inventory:GetEquippedItem(GLOBAL.EQUIPSLOTS.HANDS) if tool ~= nil and tool:GetIsWet() and math.random() < easing.inSine(GLOBAL.TheWorld.state.wetness, 0, .15, inst.components.moisture:GetMaxMoisture()) then local projectile = data.weapon ~= nil and data.projectile == nil and (data.weapon.components.projectile ~= nil or data.weapon.components.complexprojectile ~= nil) if projectile then local num = data.weapon.components.stackable ~= nil and data.weapon.components.stackable:StackSize() or 1 if num <= 1 then return end inst.components.inventory:Unequip(GLOBAL.EQUIPSLOTS.HANDS, true) tool = data.weapon.components.stackable:Get(num - 1) tool.Transform:SetPosition(inst.Transform:GetWorldPosition()) if tool.components.inventoryitem ~= nil then tool.components.inventoryitem:OnDropped() end else inst.components.inventory:Unequip(GLOBAL.EQUIPSLOTS.HANDS, true) inst.components.inventory:DropItem(tool) end if tool.Physics ~= nil then local x, y, z = tool.Transform:GetWorldPosition() tool.Physics:Teleport(x, .3, z) local angle = (math.random() * 20 - 10) * DEGREES if data.target ~= nil and data.target:IsValid() then local x1, y1, z1 = inst.Transform:GetWorldPosition() x, y, z = data.target.Transform:GetWorldPosition() angle = angle + ( (x1 == x and z1 == z and math.random() * 2 * PI) or (projectile and math.atan2(z - z1, x - x1)) or math.atan2(z1 - z, x1 - x) ) else angle = angle + math.random() * 2 * PI end local speed = projectile and 2 + math.random() or 3 + math.random() * 2 tool.Physics:SetVel(math.cos(angle) * speed, 10, math.sin(angle) * speed) end end end end) Uh, try this? I'm not too sure if this'd work. I made the slipperyness happen at 60 wetness. Dont think that worked, weapon got soaked while at 56 wetness so im not sure although it doesnt really matter however the dialog didnt work, i forgot what the error was but i zoned in on the "=" Link to comment Share on other sites More sharing options...
Hornete Posted July 23, 2019 Share Posted July 23, 2019 Just now, JustCrimson said: Dont think that worked, weapon got soaked while at 56 wetness so im not sure although it doesnt really matter however the dialog didnt work, i forgot what the error was but i zoned in on the "=" Get rid of the commas for the dialog, as for the tool soak, Yes the weapons still get soaked, but do they slip? Link to comment Share on other sites More sharing options...
TemporarySolutn Posted July 23, 2019 Author Share Posted July 23, 2019 1 minute ago, Hornete said: Get rid of the commas for the dialog, as for the tool soak, Yes the weapons still get soaked, but do they slip? I actually didnt check that lmao my game crashes and the log file says "attempt to index field 'CHARACTER'" (talking about the dialog) Link to comment Share on other sites More sharing options...
Ultroman Posted July 23, 2019 Share Posted July 23, 2019 I believe it's supposed to be STRINGS.CHARACTERS 1 hour ago, Hornete said: Spoiler AddPrefabPostInit("wormwood", function(inst) if not GLOBAL.TheWorld.ismastersim then return end inst:DoPeriodicTask(1, function() if inst.components.moisture.moisture == 0 then print("No health regen") else if inst.components.moisture.moisture > 80 then --Over 80 stops the health -regen, you can adjust this to what you'd like print("Too wet!") else inst.components.health:DoDelta(1) --Heals 1 hp every secound, you can adjust this end end end) local function DropWetTool(inst, data) --Tool slip. if inst.components.moisture:GetSegs() < 6 then return end local tool = inst.components.inventory:GetEquippedItem(GLOBAL.EQUIPSLOTS.HANDS) if tool ~= nil and tool:GetIsWet() and math.random() < easing.inSine(GLOBAL.TheWorld.state.wetness, 0, .15, inst.components.moisture:GetMaxMoisture()) then local projectile = data.weapon ~= nil and data.projectile == nil and (data.weapon.components.projectile ~= nil or data.weapon.components.complexprojectile ~= nil) if projectile then local num = data.weapon.components.stackable ~= nil and data.weapon.components.stackable:StackSize() or 1 if num <= 1 then return end inst.components.inventory:Unequip(GLOBAL.EQUIPSLOTS.HANDS, true) tool = data.weapon.components.stackable:Get(num - 1) tool.Transform:SetPosition(inst.Transform:GetWorldPosition()) if tool.components.inventoryitem ~= nil then tool.components.inventoryitem:OnDropped() end else inst.components.inventory:Unequip(GLOBAL.EQUIPSLOTS.HANDS, true) inst.components.inventory:DropItem(tool) end if tool.Physics ~= nil then local x, y, z = tool.Transform:GetWorldPosition() tool.Physics:Teleport(x, .3, z) local angle = (math.random() * 20 - 10) * DEGREES if data.target ~= nil and data.target:IsValid() then local x1, y1, z1 = inst.Transform:GetWorldPosition() x, y, z = data.target.Transform:GetWorldPosition() angle = angle + ( (x1 == x and z1 == z and math.random() * 2 * PI) or (projectile and math.atan2(z - z1, x - x1)) or math.atan2(z1 - z, x1 - x) ) else angle = angle + math.random() * 2 * PI end local speed = projectile and 2 + math.random() or 3 + math.random() * 2 tool.Physics:SetVel(math.cos(angle) * speed, 10, math.sin(angle) * speed) end end end end) Uh, try this? I'm not too sure if this'd work. I made the slipperyness happen at 60 wetness. You cannot overwrite local functions like that, Hornete. Doesn't work that way. If this was DS, it would be easy, because in the places where it drops the items for being wet, it checks for a "notslippery" tag. It does not have this check in DST. Link to comment Share on other sites More sharing options...
Ultroman Posted July 23, 2019 Share Posted July 23, 2019 It's pretty convenient that the Unequip function gets a boolean saying whether the item was dropped because it was slippery, so we can stop the unequip from happening by extending that function, BUT...it'll still call DropItem() afterwards, which we can't do anything about, since the code is in a local function. An interesting idea just came to me, though. Since we know that the code in that local function will always execute in the same frame, we can do some trickery. Try putting this in your character prefab Lua at the bottom of the master_postinit function: local function oldUnequip = inst.components.inventory.Unequip inst.components.inventory.Unequip = function(self, equipslot, slip, ...) -- If the item was unequipped due to it slipping, and it is a hand-item... if slip and equipslot == GLOBAL.EQUIPSLOTS.HANDS then local item = self.equipslots[equipslot] if item ~= nil then -- Store the item in a custom variable on the inventory. self.tempitem = item -- Exit, not unequipping the item return end end -- Otherwise, proceed normally. oldUnequip(self, equipslot, slip, ...) end local function oldDropItem = inst.components.inventory.DropItem inst.components.inventory.DropItem = function(self, item, wholestack, randomdir, pos, skipfall, tossdir, setspeed, ...) -- If we have an item stored in the tempitem variable, then it means Unequip was just called, -- and it is about to try to drop the item which we prevented from being unequipped due to a slip. if self.tempitem and self.tempitem == item then -- We remove the item from the stored variable... self.tempitem = nil -- And return immediately, not dropping the item. return end oldDropItem(self, item, wholestack, randomdir, pos, skipfall, tossdir, setspeed, ...) end Link to comment 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