Jump to content

Terrible gem checking way in moonrockcrater and winona_battery


Littlefat1213
  • Pending

It's terrible to check gem based on the prefab string suffix. which causes ancientfruit_gem was considered as gem.(Also we have dumbbell_gem but lucky it's not tradable)

AND JUST WATCH OUT SOME GUYS COULD ALREADY HAVE ANCIENTFRUIT GEM IN THEIR BATTERY SO PLEASE AVOID THE CRASH AFTER THIS FIXES.

-- moonrockcrater.lua
local function ItemTradeTest(inst, item)
    if item == nil then
        return false
    elseif string.sub(item.prefab, -3) ~= "gem" then
        return false, "NOTGEM"
    elseif string.sub(item.prefab, -11, -4) == "precious" then
        return false, "WRONGGEM"
    end
    return true
end

-- winona_battery_high.lua
local function ItemTradeTest(inst, item, doer)
    if item == nil then
        return false
	elseif item.prefab == "purebrilliance" then
		if doer and doer.components.skilltreeupdater and doer.components.skilltreeupdater:IsActivated("winona_lunar_2") then
			return true
		end
		return false, "NOGENERATORSKILL"
	elseif item.prefab == "alterguardianhatshard" then
		if doer and doer.components.skilltreeupdater and doer.components.skilltreeupdater:IsActivated("winona_lunar_1") then
			return true
		end
		return false, "NOGENERATORSKILL"
    elseif string.sub(item.prefab, -3) ~= "gem" then
        return false, "NOTGEM"
    elseif string.sub(item.prefab, -11, -4) == "precious" then
        return false, "WRONGGEM"
    end
    return true
end

-- pocketwatch.lua  Actually it's do no affect cause only purplegem allowed
local function Recall_ItemTradeTest(inst, item, giver)
    if item == nil then
        return false
    elseif string.sub(item.prefab, -3) ~= "gem" then
        return false, "NOTGEM"
	elseif item.prefab ~= "purplegem" then
        return false, "WRONGGEM"
    end
    return true
end

I think tag check is a better way and already in crabking.

local function ShouldAcceptItem(inst, item)
    return item:HasTag("gem") and #inst.socketed < MAX_SOCKETS
end

 


Steps to Reproduce

 As Above

  • Like 1



User Feedback


This crash bug has actually been around for quite a while. I had assumed it was already fixed, so I was a bit surprised to see it still happening.

Edited by adminaaassh
  • 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...