Jump to content

Wurt can trade Trinkets, Meat, etc. with PK due to conditionals in pigking.lua


lakhnish
  • Fixed

Wurt can trade meat, trinkets, etc. to PK due to the conditionals in pigking.lua

As per the AcceptTest function for pigking.lua:

if giver:HasTag("merm") and not item.prefab == "pig_token" then --current version
  
if giver:HasTag("merm") and item.prefab ~= "pig_token" then --fixed version
    

The fixed version allows Wurt to do the Pig King event while preventing her from trading meats, trinkets, etc.


Steps to Reproduce
Wurt can trade with Pig King. Go to pigking.lua. See conditional is messed up.
  • Like 2



User Feedback


A developer has marked this issue as fixed. This means that the issue has been addressed in the current development build and will likely be in the next update.

Another solution would be to add parenthesis so the line looks like this:
 

    if giver:HasTag("merm") and not (item.prefab == "pig_token") then

Lua turns `not item.prefab` into `false` first, then compares it to "pig_token". I didn't personally know it worked like that until now...

  • Like 1

Share this comment


Link to comment
Share on other sites

2 hours ago, Electroely said:

Lua turns `not item.prefab` into `false` first, then compares it to "pig_token". I didn't personally know it worked like that until now...

Was wrapping my head trying to understand why the initial code wasn't working. Good to know that's the reason why!

  • Like 1

Share this comment


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

×
  • Create New...