Thomas Die Posted December 11, 2020 Share Posted December 11, 2020 --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 More sharing options...
penguin0616 Posted December 11, 2020 Share Posted December 11, 2020 @thomas4846 You're using netvars but discarding the values in a few places. Take "inst.clones_numbers = ...:value()", which you never reference again. I'm not able to test your code, but I suggest you put some prints in your HasCharacterIngredient(s) and figure out where it stops working. 1 Link to comment Share on other sites More sharing options...
Thomas Die Posted December 11, 2020 Author Share Posted December 11, 2020 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 More sharing options...
penguin0616 Posted December 11, 2020 Share Posted December 11, 2020 I assume then, that either the game doesn't refresh the popup as much as you want it to, or you're returning the wrong results. Perhaps hook into RecipePopup:Refresh(), and see how often it is called in comparison to your ingredient check? 1 Link to comment Share on other sites More sharing options...
Thomas Die Posted December 11, 2020 Author Share Posted December 11, 2020 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 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 More sharing options...
penguin0616 Posted December 12, 2020 Share Posted December 12, 2020 @thomas4846 Looks like whenever you spawn a thing, HasCharacterIngredient gets called. When you remove them with the "recipe", it doesn't get called. I'm don't know *what* about spawning a thing causes it to refresh, but that's what you'll have to simulate in order to get it to update the recipe popup. 1 1 Link to comment Share on other sites More sharing options...
Thomas Die Posted December 12, 2020 Author Share Posted December 12, 2020 they call me hacker man nvm it does't work anymore okay now this works Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now