Jump to content

Need help with keyhandler action.........


Recommended Posts

Hello, I need help trying to make something work... Here's the code I need help with...

local STEALTH = GLOBAL.Action()
STEALTH.str = "Stealth"
STEALTH.id = "STEALTH"
STEALTH.fn = function(act)
if act.target.components.sanity.current >= 60 and act.target.components.sanity:IsSane() and act.target.components.sheltered.sheltered then
act.target:DoTaskInTime(0.05, function()
act.target:AddComponent("grogginess")
act.target.DynamicShadow:Enable(false)
act.target.components.grogginess:SetDecayRate(0)
act.target.components.grogginess:AddGrogginess(0.25)
act.target.components.locomotor.runspeed = 2.35 * TUNING.WILSON_RUN_SPEED
act.target.AnimState:SetMultColour(.95,.95,.95,.95)
end)
act.target:DoTaskInTime(0.10, function()
act.target.AnimState:SetMultColour(.90,.90,.90,.90)
end)
act.target:DoTaskInTime(0.15, function()
act.target.AnimState:SetMultColour(.85,.85,.85,.85)
end)
act.target:DoTaskInTime(0.20, function()
act.target.AnimState:SetMultColour(.80,.80,.80,.80)
end)
act.target:DoTaskInTime(0.25, function()
act.target.AnimState:SetMultColour(.75,.75,.75,.75)
end)
act.target:DoTaskInTime(0.30, function()
act.target.AnimState:SetMultColour(.70,.70,.70,.70)
end)
act.target:DoTaskInTime(0.35, function()
act.target.AnimState:SetMultColour(.65,.65,.65,.65)
end)
act.target:DoTaskInTime(0.40, function()
act.target.AnimState:SetMultColour(.60,.60,.60,.60)
end)
act.target:DoTaskInTime(0.45, function()
act.target.AnimState:SetMultColour(.55,.55,.55,.55)
end)
act.target:DoTaskInTime(0.50, function()
act.target.AnimState:SetMultColour(.50,.50,.50,.50)
end)
act.target:DoTaskInTime(0.55, function()
act.target.AnimState:SetMultColour(.45,.45,.45,.45)
end)
act.target:DoTaskInTime(0.60, function()
act.target.AnimState:SetMultColour(.40,.40,.40,.40)
end)
act.target:DoTaskInTime(0.65, function()
act.target.AnimState:SetMultColour(.35,.35,.35,.35)
end)
act.target:DoTaskInTime(0.70, function()
act.target.AnimState:SetMultColour(.30,.30,.30,.30)
end)
act.target:DoTaskInTime(0.75, function()
act.target.AnimState:SetMultColour(.25,.25,.25,.25)
end)
act.target:DoTaskInTime(0.80, function()
act.target.AnimState:SetMultColour(.20,.20,.20,.20)
end)
act.target:DoTaskInTime(0.85, function()
act.target.AnimState:SetMultColour(.15,.15,.15,.15)
end)
act.target:DoTaskInTime(0.90, function()
act.target.AnimState:SetMultColour(.10,.10,.10,.10)
end)
act.target:DoTaskInTime(0.95, function()
act.target:AddTag("notarget")
act.target.AnimState:SetMultColour(.05,.05,.05,.05)
act.target.components.talker:Say("...")
act.target.components.combat.damagemultiplier = 2.75
end)
act.target:DoTaskInTime(5, function()
act.target:RemoveTag("notarget")
act.target.DynamicShadow:Enable(true)
act.target:RemoveComponent("grogginess")
act.target.AnimState:SetMultColour(1.0,1.0,1.0,1.0)
act.target.components.combat.damagemultiplier = 1.75
act.target.components.locomotor.runspeed = 2 * TUNING.WILSON_RUN_SPEED
end)
end
end

AddAction(STEALTH) 

So... For some reason this code causes a crash if you have Inst:AddTag("beaver") which I really need my character to have since I can't make a custom SGwilson, that would be way to hard for me... So I'm wondering is there a way to make this entire action cancel & become unactivateable if my character has Inst:AddTag("beaver")?

Also, is there a more efficient way of making a character's textures fade out smoothly instead of having like 10 DoTaskInTime?

EDIT 1: Okay, I tested why it gets crash when I have Inst:AddTag("beaver") and the thing causing the crash is act.target:AddComponent("grogginess") which's very weird since when my character's starving, overheating or freezing he gets groggy and you can go insane have the beaver tag and no crash happens, does anyone know why this could be happening?!

Edited by SuperDavid
Link to comment
Share on other sites

11 minutes ago, SuperDavid said:

So... For some reason this code causes a crash if you have Inst:AddTag("beaver") which I really need my character to have since I can't make a custom SGwilson, that would be way to hard for me... So I'm wondering is there a way to make this entire action cancel & become unactivateable if my character has Inst:AddTag("beaver")?

Post the crash log.

12 minutes ago, SuperDavid said:

Also, is there a more efficient way of making a character's textures fade out smoothly instead of having like 10 DoTaskInTime?

Using FOR would suffice. But for this particular case, you have the tech available for you.

inst.components.colourtweener:StartTween({0.05, 0.05, 0.05, 0.05}, 1)

Would replace all those SetMultColour.

Link to comment
Share on other sites

22 minutes ago, SuperDavid said:

Okay, I tested why it gets crash when I have Inst:AddTag("beaver") and the thing causing the crash is act.target:AddComponent("grogginess") which's very weird since when my character's starving, overheating or freezing he gets groggy and you can go insane have the beaver tag and no crash happens, does anyone know why this could be happening?!

Don't add and remove grogginess then.

Replace RemoveComponent("grogginess") for

inst.components.grogginess:SetResistance(10000)

And AddComponent("grogginess") for

inst.components.grogginess:SetResistance(3)

 

Link to comment
Share on other sites

Here's one of the crashes but it's not the only crashes that happens there are others which say stuff like inventory nil, health nil, hunger nil... If you want me to say the other crashes can you maybe tell me again how to get into the crash log for worlds with caves. Also, these crashes only happens in worlds with caves, it doesn't happen in worlds without caves...

"string "scripts/widgets/statusdisplays.lua"]:328: attempt to index field 'sanity' (a nil value)

LUA ERROR stack traceback:

scripts/widgets/statusdisplays.lua:328 in (method) SetSanityPercent (Lua) <327-335>

scripts/widgets/statusdisplays.lua:328 in (method) SanityDelta (Lua) <337-349>

scripts/widgets/statusdisplays.lua:26 in (local) fn (Lua) <26-26>

scripts/entityscript.lua:960 in (method) PushEvent (Lua) <954-977>

scripts/prefabs/player_classified.lua:244 in (local) fn (Lua) <234-251>

scripts/entityscript.lua:960 in (method) PushEvent (Lua) <954-977>

scripts/mainfunctions.lua:285 in () ? (Lua) <282-287"

13 minutes ago, DarkXero said:

Don't add and remove grogginess then.

Replace RemoveComponent("grogginess") for


inst.components.grogginess:SetResistance(10000)

And AddComponent("grogginess") for


inst.components.grogginess:SetResistance(3)

 

I added this it causes the same crashes plus doesn't remove the groggy effect when the stealth action ends.

All I want from the groggy effect is anims, is there a way I just change all of his anim into groggy without using the component?

Edited by SuperDavid
Link to comment
Share on other sites

20 minutes ago, DarkXero said:

In any moment do you add or remove the sanity component?

No, I don't which is why it's so weird. It might be some problem with Inst:AddTag("beaver") since beaver form doesn't have sanity or an inventory, I think :?...

Also, here's another one of the crashes that happens...

"[string "scripts/widgets/itemtile.lua"]:214:attempt to index field 'inventory' (a nil value)

LUA ERROR stack traceback:

scripts/widgets/itemtile.lua:214 in (upvalue) ItemTile_GetDescriptionString_base (Lua) <203-249>

../mods/workshop-347079953/modmain.lua:128 in (method) GetDescriptionString (Lua) <123-139>

../mods/workshop-347079953/modmain.lua:128 in (local) fn (Lua) <110-120>

scripts/entityscript.lua:960 in (method) PushEvent (Lua) <954-977>

scripts/mainfunctions.lua:285 in () ? (Lua) <282-287>"

EDIT: This crash seems to be from some other mod called "DisplayFoodValues" so i'll uninstall and see if I still get this same crash...

EDIT 2: Another crash that happens after I disabled "DisplayFoodValues" mod!!!

"[string "scripts/components/playercontroller.lua"]:1619: attempt to index field 'inventory' (a nil value)

LUA ERROR stack traceback:

scripts/components/playercontroller.lua:1619 in (method) OnUpdate (Lua) <1452-1803>

scripts/update.lua:187 in () ? (Lua) <150-223>

Edited by SuperDavid
Link to comment
Share on other sites

Okay, here's how you do the crashes.

Step 0: Play in a world with caves on.

Step 1: Get yourself a purple amulet.

Step 2: Go under a tree and press RIGHTBRACKET also known as ]

Step 3: As you start fading out entering stealth mode equip the purple amulet.

Step 4: The game crashed.

Adam mod.zip

Edited by SuperDavid
Link to comment
Share on other sites

Alright, found the issue.

[00:01:03]: Error serializing tags for entity adam[111831] - 32 tags; exceeds maximum size of 31
[00:01:03]: Net partial byte (32) out of range [0, 31]

Makes sense then, when you remove the beaver tag you stay inside the limit.

I would say combine all tags into one, but that would break your pet logic.

I'm going to look at the mod and see how to clean it up.

Link to comment
Share on other sites

Thank you so much DarkXero! Now it won't crash anymore :D! If I can ask a question, a entity can only have 31 Inst:AddTags as max? Does that mean I can not add anymore tags to my character, forever? Again, thank you so very much you really are very great help for my mod, you helped add lots of the cool things, thanks :D!

Link to comment
Share on other sites

10 hours ago, SuperDavid said:

Thank you so much DarkXero! Now it won't crash anymore :D! If I can ask a question, a entity can only have 31 Inst:AddTags as max? Does that mean I can not add anymore tags to my character, forever? Again, thank you so very much you really are very great help for my mod, you helped add lots of the cool things, thanks :D!

That's the max, unless Klei increases it. You can suggest in Suggestions and Feedback to increase it. And this is a huge problem, because some hats, like the beefalo hat, adds the beefalo tag to your character on equip. So it will return the crash. The good news is that most tags (except beaver, monster, spiderwhisperer) can be replaced by something else, so you have some breathing room for other stuff that uses tags on your character.

That doesn't mean you have to stop doing stuff. You can look for workarounds (like changing the function provided to FindEntity calls to check on possible targets, instead of changing the tags that are looked for). You can use net_bool function to create net variables, and set them to true or false to make them act like tags and make them reach the client.

Basically, there's some work to do on your mod. Your warg, hound, and mossling whisperer tags shouldn't be needed.

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
  • Create New...