MF99K

  • Content Count

    1157
  • Joined

  • Last visited

Community Reputation

2748 Excellent

About MF99K

  • Rank
    hec
...

Badges

Recent Profile Visitors

7733 profile views
  1. currently this is the purple staff postinit local UpvalueHacker = GLOBAL.require "upvaluehacker" --UpvalueHacker.SetUpvalue(GLOBAL.Prefabs.staff.fn, onblink, "onblink") AddPrefabPostInit("telestaff", function(inst) print("postinit on") local function teleport_start(teleportee, staff, caster, loctarget, target_in_ocean) local ground = TheWorld --V2C: Gotta do this RIGHT AWAY in case anything happens to loctarget or caster local locpos = teleportee.components.teleportedoverride ~= nil and teleportee.components.teleportedoverride:GetDestPosition() or loctarget == nil and getrandomposition(caster, teleportee, target_in_ocean) or loctarget.teletopos ~= nil and loctarget:teletopos() or loctarget:GetPosition() if teleportee.components.locomotor ~= nil then teleportee.components.locomotor:StopMoving() end staff.components.finiteuses:Use(1) if ground:HasTag("cave") then -- There's a roof over your head, magic lightning can't strike! ground:PushEvent("ms_miniquake", { rad = 3, num = 5, duration = 1.5, target = teleportee }) return end local isplayer = teleportee:HasTag("player") if isplayer then teleportee.sg:GoToState("forcetele") else if teleportee.components.health ~= nil then teleportee.components.health:SetInvincible(true) end if teleportee.DynamicShadow ~= nil then teleportee.DynamicShadow:Enable(false) end teleportee:Hide() end --#v2c hacky way to prevent lightning from igniting us local preventburning = teleportee.components.burnable ~= nil and not teleportee.components.burnable.burning if preventburning then teleportee.components.burnable.burning = true end ground:PushEvent("ms_sendlightningstrike", teleportee:GetPosition()) if preventburning then teleportee.components.burnable.burning = false end if caster ~= nil and caster.components.sanity ~= nil and not caster:HasTag("warptraveller") then caster.components.sanity:DoDelta(-TUNING.SANITY_HUGE) print("not warper") end if caster ~= nil and caster.components.sanity ~= nil and caster:HasTag("warptraveller") then caster.components.sanity:DoDelta(TUNING.SANITY_TINY) print("warper") end ground:PushEvent("ms_deltamoisture", TUNING.TELESTAFF_MOISTURE) if isplayer then teleportee.sg.statemem.teleport_task = teleportee:DoTaskInTime(3, teleport_continue, locpos, loctarget) else teleport_continue(teleportee, locpos, loctarget) end end UpvalueHacker.SetUpvalue(GLOBAL.Prefabs.telestaff.fn, teleport_start, "teleport_start") end) Alborgo on the discord pointed out that the correct prefab name is "telestaff" so I fixed that, but the code still appears to do nothing and doesn't provide the prints inside the function
  2. I'd assume adding a print here would be a good place to start? AddPrefabPostInit("purplestaff", teleport_start, function(inst) print("postinit on") local function teleport_start(teleportee, staff, caster, loctarget, target_in_ocean)
  3. most of the crashes I get are usually syntax errors, so if that is what is happening, something about the context of the error is what's preventing an error log. I don't know enough about when stuff is accessed to know why there are different kinds of crashes. I've added several prints, and none of them have showed up in console, which shows me something isn't connected. As it currently stands, this is the purple staff postinit stuff: local UpvalueHacker = GLOBAL.require "upvaluehacker" --UpvalueHacker.SetUpvalue(GLOBAL.Prefabs.staff.fn, onblink, "onblink") AddPrefabPostInit("purplestaff", teleport_start, function(inst) local function teleport_start(teleportee, staff, caster, loctarget, target_in_ocean) local ground = TheWorld --V2C: Gotta do this RIGHT AWAY in case anything happens to loctarget or caster local locpos = teleportee.components.teleportedoverride ~= nil and teleportee.components.teleportedoverride:GetDestPosition() or loctarget == nil and getrandomposition(caster, teleportee, target_in_ocean) or loctarget.teletopos ~= nil and loctarget:teletopos() or loctarget:GetPosition() if teleportee.components.locomotor ~= nil then teleportee.components.locomotor:StopMoving() end staff.components.finiteuses:Use(1) if ground:HasTag("cave") then -- There's a roof over your head, magic lightning can't strike! ground:PushEvent("ms_miniquake", { rad = 3, num = 5, duration = 1.5, target = teleportee }) return end local isplayer = teleportee:HasTag("player") if isplayer then teleportee.sg:GoToState("forcetele") else if teleportee.components.health ~= nil then teleportee.components.health:SetInvincible(true) end if teleportee.DynamicShadow ~= nil then teleportee.DynamicShadow:Enable(false) end teleportee:Hide() end --#v2c hacky way to prevent lightning from igniting us local preventburning = teleportee.components.burnable ~= nil and not teleportee.components.burnable.burning if preventburning then teleportee.components.burnable.burning = true end ground:PushEvent("ms_sendlightningstrike", teleportee:GetPosition()) if preventburning then teleportee.components.burnable.burning = false end if caster ~= nil and caster.components.sanity ~= nil and not caster:HasTag("warptraveller") then caster.components.sanity:DoDelta(-TUNING.SANITY_HUGE) print("not warper") end if caster ~= nil and caster.components.sanity ~= nil and caster:HasTag("warptraveller") then caster.components.sanity:DoDelta(TUNING.SANITY_TINY) print("warper") end ground:PushEvent("ms_deltamoisture", TUNING.TELESTAFF_MOISTURE) if isplayer then teleportee.sg.statemem.teleport_task = teleportee:DoTaskInTime(3, teleport_continue, locpos, loctarget) else teleport_continue(teleportee, locpos, loctarget) end end UpvalueHacker.SetUpvalue(GLOBAL.Prefabs.staff.fn, teleport_start, "teleport_start") end) right now, this code does not crash, but also does nothing
  4. thing is, it doesn't crash the bracket is lower down in the code, it just doesn't do anything at all
  5. I tried both AddPrefabPostInit("purplestaff", teleport_start, function(inst) and AddPrefabPostInit("purplestaff", function(inst) neither of them crash the game, but neither of them use the modded function either The actual crash is that the game reverts to the character select screen and then freezes. I know that this type of crash doesn't usually produce error logs, but the same thing occurs for both the postinits I posted earlier
  6. I was able to get the code for the wormhole and orangestaff to work fine, but the purple staff and lazy deserter code causes an errorless crash this is the code for those local UpvalueHacker = GLOBAL.require "upvaluehacker" --UpvalueHacker.SetUpvalue(GLOBAL.Prefabs.staff.fn, onblink, "onblink") AddPrefabPostInit("purplestaff" teleport_start, function(inst) local function teleport_start(teleportee, staff, caster, loctarget, target_in_ocean) local ground = TheWorld --V2C: Gotta do this RIGHT AWAY in case anything happens to loctarget or caster local locpos = teleportee.components.teleportedoverride ~= nil and teleportee.components.teleportedoverride:GetDestPosition() or loctarget == nil and getrandomposition(caster, teleportee, target_in_ocean) or loctarget.teletopos ~= nil and loctarget:teletopos() or loctarget:GetPosition() if teleportee.components.locomotor ~= nil then teleportee.components.locomotor:StopMoving() end staff.components.finiteuses:Use(1) if ground:HasTag("cave") then -- There's a roof over your head, magic lightning can't strike! ground:PushEvent("ms_miniquake", { rad = 3, num = 5, duration = 1.5, target = teleportee }) return end local isplayer = teleportee:HasTag("player") if isplayer then teleportee.sg:GoToState("forcetele") else if teleportee.components.health ~= nil then teleportee.components.health:SetInvincible(true) end if teleportee.DynamicShadow ~= nil then teleportee.DynamicShadow:Enable(false) end teleportee:Hide() end --#v2c hacky way to prevent lightning from igniting us local preventburning = teleportee.components.burnable ~= nil and not teleportee.components.burnable.burning if preventburning then teleportee.components.burnable.burning = true end ground:PushEvent("ms_sendlightningstrike", teleportee:GetPosition()) if preventburning then teleportee.components.burnable.burning = false end if caster ~= nil and caster.components.sanity ~= nil and not caster:HasTag("warptraveller") then caster.components.sanity:DoDelta(-TUNING.SANITY_HUGE) end if caster ~= nil and caster.components.sanity ~= nil and caster:HasTag("warptraveller") then caster.components.sanity:DoDelta(TUNING.SANITY_TINY) end ground:PushEvent("ms_deltamoisture", TUNING.TELESTAFF_MOISTURE) if isplayer then teleportee.sg.statemem.teleport_task = teleportee:DoTaskInTime(3, teleport_continue, locpos, loctarget) else teleport_continue(teleportee, locpos, loctarget) end end UpvalueHacker.SetUpvalue(GLOBAL.Prefabs.staff.fn, teleport_start, "teleport_start") end) --lazy deserter (townportal) local function OnStartChanneling(inst, channeler) inst.AnimState:PlayAnimation("turn_on") inst.AnimState:PushAnimation("idle_on_loop") StartSoundLoop(inst) TheWorld:PushEvent("townportalactivated", inst) inst.MiniMapEntity:SetIcon("townportalactive.png") inst.MiniMapEntity:SetPriority(20) if inst.icon ~= nil then inst.icon.MiniMapEntity:SetIcon("townportalactive.png") inst.icon.MiniMapEntity:SetPriority(20) inst.icon.MiniMapEntity:SetDrawOverFogOfWar(true) end inst.channeler = channeler.components.sanity ~= nil and channeler or nil if inst.channeler ~= nil and inst.channeler:HasTag("warptraveller") then inst.channeler.components.sanity:DoDelta(-TUNING.SANITY_SMALL) inst.channeler.components.sanity.externalmodifiers:SetModifier(inst, -TUNING.DAPPERNESS_TINY) else if inst.channeler ~= nil then inst.channeler.components.sanity:DoDelta(-TUNING.SANITY_MED) inst.channeler.components.sanity.externalmodifiers:SetModifier(inst, -TUNING.DAPPERNESS_SUPERHUGE) end end) AddPrefabPostInit("townportal", function(inst) inst.components.channelable.onchannelfn = OnStartChanneling end)
  7. ah yea, I had a feeling it was something along those lines, where if it was a function called from within another function (or object) it would need to be set up differently I would assume this also means that only teleport_start would need the upvalue hacker?
  8. So from what I understand, whether the upvalue hacker is needed depends on where the function is getting called? so any function that's called with something along the lines of "inst.components.[component].[component function] = [function name]" shouldn't need it?
  9. So I'm assuming then that the orangestaff postinit would look like this? local function onblink(staff, pos, caster) if caster ~= nil and caster.components.sanity ~= nil and not caster:HasTag("warptraveller") then caster.components.sanity:DoDelta(-TUNING.SANITY_MED) end if caster ~= nil and caster.components.sanity ~= nil and caster:HasTag("warptraveller") then caster.components.sanity:DoDelta(TUNING.SANITY_TINY) end staff.components.finiteuses:Use(1) end AddPrefabPostInit("orangestaff", function(inst) inst.components.blinkstaff.onblinkfn = onblink end) with the function to be changed and then the postinit? And it doesn't need the upvalue hacker in this case? What determines whether that is needed or not?
  10. I can already tell I'm doing something wrong with setting this up for the purple staff code, but this is what I have so far for the orange staff code and I want to make sure I'm doing this right: local UpvalueHacker = GLOBAL.require "upvaluehacker" AddPrefabPostinit("staff" onblink(staff, pos, caster) local function onblink(staff, pos, caster) if caster ~= nil and caster.components.sanity ~= nil and not caster:HasTag("warptraveller") then caster.components.sanity:DoDelta(-TUNING.SANITY_MED) end if caster ~= nil and caster.components.sanity ~= nil and caster:HasTag("warptraveller") then caster.components.sanity:DoDelta(TUNING.SANITY_TINY) end staff.components.finiteuses:Use(1) end UpvalueHacker.SetUpvalue(GLOBAL.Prefabs.staff.fn, onblink, "onblink") end) From what I understand, I put the upvaluehacker.lua into the scripts folder and then reference it in modmain, is this the correct way to do that?
  11. I'm trying to make postinits to replace several existing functions inside prefab files, and I'm wondering how to do this properly. These are the files/functions in question: how would I set these up properly as a postinit so that the postinit would replace these functions with my custom code? (the code posted is the original code)
  12. that's what I was asking about, but wanted to know how to tell the game to check for a specific action. I ended up changing the code so that the tool/weapon's efficiency is proportional to fuel level instead
  13. what I'm wondering here is since fueled and finite uses are usually both shown in inventory as a percent, do they use the same values or work on the same values I would want consumption to subtract from fuel level
  14. I already have it set up like a lantern, but I want it to consume fuel on each use instead of durability. I have this set up for attacks: but I want it to do the same for ACTIONS.CHOP and ACTIONS.MINE