Muche Posted January 23, 2016 Share Posted January 23, 2016 Since there is a hard limit of 31 tags that an entity can have, is there a better way to count them than this (I am trying not to exhaust them all): local function GetTagsCount(inst) if inst == nil or inst.entity == nil then return 0 end local ds = inst.entity:GetDebugString() if ds == nil then return 0 end local tagsstr = string.match(ds, "Tags: ([^\n]+)\n") if tagsstr == nil then return 0 end local tags = string.split(tagsstr, " ") local tagscount = #tags return tagscount end Link to comment https://forums.kleientertainment.com/forums/topic/63100-counting-entitys-tags/ Share on other sites More sharing options...
Maris Posted January 23, 2016 Share Posted January 23, 2016 Great! I thought that there is no way to list all tags. Link to comment https://forums.kleientertainment.com/forums/topic/63100-counting-entitys-tags/#findComment-713127 Share on other sites More sharing options...
Muche Posted January 24, 2016 Author Share Posted January 24, 2016 1 hour ago, Maris said: Great! I thought that there is no way to list all tags. It seems this way of listing tags works only on host/server, not on client. Part of log from c_dump() on the server: GUID:113234 Name: Tags: _writeable inspectable writeable HAMMER_workable dragonflybait_medprio canlight structure SnowCovered blocker Prefab: homesign AnimState: bank: sign_home build: sign_home anim: idle anim/sign_home.zip:idle Frame: 1252.99/2 Transform: Pos=(-114.08,0.00,-87.87) Scale=(1.00,1.00,1.00) Heading=0.00 Network: NetworkID=17221 Owner=UNASSIGNED_RAKNET_GUID NetSleep=1111111111111111111111111111111111111111111111111111111111111110 MiniMapEntity: Physics: Collision Group: 512 Mask: (ACTIVE) Vel: 0.00 SoundEmitter: part of log from c_dump() on the client (of the same sign): GUID:101816 Name: Tags: _writeable FROMNUM writeable FROMNUM FROMNUM FROMNUM structure SnowCovered blocker Prefab: homesign AnimState: bank: sign_home build: sign_home anim: idle anim/sign_home.zip:idle Frame: 493.00/2 Transform: Pos=(-114.08,0.00,-87.87) Scale=(1.00,1.00,1.00) Heading=0.00 Network: NetworkID=17221 Owner=UNASSIGNED_RAKNET_GUID NetSleep=0000000000000000000000000000000000000000000000000000000000000000 MiniMapEntity: Physics: Collision Group: 512 Mask: (ACTIVE) Vel: 0.00 SoundEmitter: I have no idea what those FROMNUM mean, but they hide true tags. Looking at the sign (thus running inst:HasTag("inspectable") somewhere in playercontroller.lua/playeractionpicker.lua I guess) reveals it: GUID:101816 Name: Tags: _writeable inspectable writeable FROMNUM FROMNUM FROMNUM structure SnowCovered blocker Prefab: homesign AnimState: bank: sign_home build: sign_home anim: idle anim/sign_home.zip:idle Frame: 4165.02/2 Transform: Pos=(-114.08,0.00,-87.87) Scale=(1.00,1.00,1.00) Heading=0.00 Network: NetworkID=17221 Owner=UNASSIGNED_RAKNET_GUID NetSleep=0000000000000000000000000000000000000000000000000000000000000000 MiniMapEntity: Physics: Collision Group: 512 Mask: (ACTIVE) Vel: 0.00 SoundEmitter: Link to comment https://forums.kleientertainment.com/forums/topic/63100-counting-entitys-tags/#findComment-713171 Share on other sites More sharing options...
Maris Posted January 24, 2016 Share Posted January 24, 2016 (edited) I think that "FROMNUM" means that there is no info about tag name but there is info about tag hash. So you can check inst:HasTag(tag_name) even if there is no real tag name in memory. Tags are network synchronized. But inst:AddTag("my_tag_name") on the server won't send string "my_tag_name". It will send only hash of this string instead. Also there are real names of tags if there is inst:AddTag before inst.entity:SetPristine() in prefab. Those tags are initialized on client. Edited January 24, 2016 by Maris Link to comment https://forums.kleientertainment.com/forums/topic/63100-counting-entitys-tags/#findComment-713191 Share on other sites More sharing options...
Muche Posted January 24, 2016 Author Share Posted January 24, 2016 However, it seems tags are case-insensitive, c_sel():HasTag('CanLiGhT');c_dump() just produced GUID:100123 Name: Tags: _writeable inspectable writeable FROMNUM FROMNUM CanLiGhT structure SnowCovered blocker Link to comment https://forums.kleientertainment.com/forums/topic/63100-counting-entitys-tags/#findComment-713201 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