Jump to content

Crafting Tab Not updating.


Recommended Posts

392581697_notworking.thumb.gif.ae7277f1bba1899b1544762356a9f026.gif
 

--easy to call counting the followers
local function HoldMePlease (inst)
local count = 0
    for k, v in pairs(inst.components.petleash.pets) do
        if v:HasTag("Thomasclone") then
		    count = count + 1
            --return true
        end
    end
	if inst.player_classified ~= nil then
	   inst.player_classified.thomaspower:set(count)
	end
end

local function GetFollowerCount (inst)
local count = 0
    for k, v in pairs(inst.components.petleash.pets) do
        if v:HasTag("Thomasclone") then
		    count = count + 1
            --return true
        end
    end
	if inst.player_classified ~= nil then
	   inst.player_classified.thomaspower:set(count)
	end
	return count
end
--AddComponentPostInit("leader",function on follower gained)
--AddPlayerPostInit(function on enity death if pet and thomas tag)

--remove one of the pet's with a tag
local function RemovePets (inst, amount)
local pets = amount
    for k, v in pairs(inst.components.petleash.pets) do
        if v:HasTag("Thomasclone") and pets > 0 then
		    pets = pets - 1
			   v:Remove()
        end
    end
	if inst.player_classified ~= nil then
	   local New_Pets = inst.player_classified.thomaspower:value() - amount
	   inst.player_classified.thomaspower:set(New_Pets)
	end
end

--NetVariables Code
local TheNet = GLOBAL.TheNet
local CLIENT_SIDE =	 GLOBAL.TheNet:GetIsClient() or (TheNet:GetIsServer() and not TheNet:IsDedicated())
AddPrefabPostInit("player_classified",function(inst)
inst.clones_numbers = 0
inst.thomaspower = GLOBAL.net_ushortint(inst.GUID, "clones_numbers", "thomasdirtyuwu")
    if CLIENT_SIDE then
            inst:ListenForEvent("thomasdirtyuwu", function(inst)
            inst.clones_numbers = inst.thomaspower:value()
			print("NUM:"..inst.clones_numbers)
        end)
    end
end)
--[[
--local follower = GLOBAL.follower
--On Getting Follower
AddComponentPostInit("leader", function(inst)
local old_addfollower = inst.AddFollower
function inst:AddFollower (follower)
old_addfollower(self ,follower)
if self.followers[follower] ~= nil and follower.components.follower == nil then return end
      if follower:HasTag("thomas") then
         self.inst:PushEvent("CreateCloneEvent", { owner = self.inst })
      end
   end
end)--]]
AddPlayerPostInit(function(inst)
if not GLOBAL.TheWorld.ismastersim then return inst end
   inst:ListenForEvent("CreateCloneEvent", HoldMePlease)
   --inst:DoPeriodicTask(0 , GetFollowerCount)--this ******** for netvars
end)

----Components Builder 
local Ingredient = GLOBAL.Ingredient
GLOBAL.STRINGS.NAMES.WOMIS_MASK = "Clone Power"
GLOBAL.CHARACTER_INGREDIENT.THOMAS = "womis_mask"

AddComponentPostInit("builder", function(inst)
local old_haschar = inst.HasCharacterIngredient
function inst:HasCharacterIngredient(ingredient)
	if ingredient.type == GLOBAL.CHARACTER_INGREDIENT.THOMAS then
		if self.inst.components.petleash ~= nil then
			local amount = GetFollowerCount (self.inst)
			return amount >= ingredient.amount, amount
		end
	else
		return old_haschar(self, ingredient)
	end
end

local old_remove = inst.RemoveIngredients
function inst:RemoveIngredients(ingredients, recname)
	old_remove(self, ingredients, recname)
		
	local recipe = GLOBAL.AllRecipes[recname]
	if recipe then
		for k,v in pairs(recipe.character_ingredients) do
			if v.type == GLOBAL.CHARACTER_INGREDIENT.THOMAS then
			    RemovePets (self.inst, v.amount)
				--self.inst.components.hunger:DoDelta(v.amount)
			end
		end
	end
end
end)

AddClassPostConstruct("components/builder_replica", function(inst)
local old_haschar = inst.HasCharacterIngredient
function inst:HasCharacterIngredient(ingredient)
	if ingredient.type == GLOBAL.CHARACTER_INGREDIENT.THOMAS then
		if self.inst.components.builder ~= nil then
			return self.inst.components.builder:HasCharacterIngredient(ingredient)
		elseif self.inst.player_classified ~= nil then
		--
			local CurrentPets = self.inst.player_classified ~= nil and self.inst.player_classified.thomaspower:value() or 0--ExtraIngredientCheck(self.inst)
			if CurrentPets ~= nil then
				return CurrentPets >= ingredient.amount, CurrentPets
			end
			if CurrentPets == 0 then
				print("NOTE:classified == nil")
				--print("NOTE:"..CurrentPets)
			end
			print("AMOUNT:"..CurrentPets)
		--
		end
	else
		return old_haschar(self, ingredient)
	end
return false, 0
end
end)
--[-[
local old_ischaringred = GLOBAL.IsCharacterIngredient
GLOBAL.IsCharacterIngredient = function(ingredienttype)
	return ingredienttype == GLOBAL.CHARACTER_INGREDIENT.THOMAS or old_ischaringred(ingredienttype)
end--]]

okay to summaries after crafting it doesn't update properly for me and only works when turning off the crafting tab than going back on:
this still doesn't fix the tab itself tho


 

this is a caves world and it does work when without so i 'm sure it's a netvar problem but i'm really bad with netvars so i'm hoping that someone can tell me what's wrong with it

Link to comment
Share on other sites

image.thumb.png.864d8048e008efda0798cd03a718da3b.png
I'm not sure but i think it's working but still doesn't update because it sees it has 0 but doesn't change still
also i have no clue how the whole "inst.clones_numbers = ...:value()" works i'm just really new to it

It updates tho when i pick up and item change my health values or make a new clone tho

"Num:value" should be the value from the thomasdirtyuwu events btw

Link to comment
Share on other sites

image.thumb.png.c1872e043e0580f69b2f69e7371a62bb.png
the function updates with the popup refresh i think and this should be the right value , i honestly have no clue why this doesn't work

image.thumb.png.1a5c7c1b5d5ba59fd24f39201d35f3f7.png

It only doesn't work when After crafting tho so i'm not sure why

workshop-2068569379.rar
here's the file if you wanna check it out. But i'll poste the answer if i can figure it out

also please ignore the tag functions

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...