Raised This Month: $32 Target: $400
 8% 

TF2 Get weapon generic name


Post New Thread Reply   
 
Thread Tools Display Modes
nosoop
Veteran Member
Join Date: Aug 2014
Old 10-13-2021 , 08:54   Re: TF2 Get weapon generic name
Reply With Quote #11

Quote:
Originally Posted by Bacardi View Post
Code:
...tf\scripts\items\items_game.txt
Why not look from keyvalue file ?
That causes flashbacks to TF2ItemsInfo. 😱

Quote:
Originally Posted by Cieniu97 View Post
If you have any suggestions how to convert valve data structure to some workable data structure (doesnt have to be in source) then I am all ears and after finishing I will happily post it on github
You can check a look at ValvePython/vdf since you're working with Python. If you really want absolutely correct names, you'll need to cross-reference the localization token (e.g. TF_Unique_MediGun_Resist for Vaccinator) with the individual translation entry stored in the game files.

I have a script that can copy specific game localization tokens into a SourceMod translation file here.
__________________
I do TF2, TF2 servers, and TF2 plugins.
I don't do DMs over Discord -- PM me on the forums regarding inquiries.
AlliedModders Releases / Github / TF2 Server / Donate (BTC / BCH / coffee)
nosoop is offline
Cieniu97
Junior Member
Join Date: Sep 2021
Location: Poland
Old 10-13-2021 , 11:10   Re: TF2 Get weapon generic name
Reply With Quote #12

Quote:
Originally Posted by nosoop View Post
You can check a look at ValvePython/vdf since you're working with Python.
Yo! That is lit. I had to use 9 lines of code in python to get list of all items with respected names.

PHP Code:
import vdf
import json
vdf.parse(open('items_game.txt'))
items = {}
for 
l in d["items_game"]["items"]:
  print(
" " +d["items_game"]["items"][l]["name"])
  
items[l] = d["items_game"]["items"][l]["name"]
with open('allitems.json''w') as json_file:
  
json.dump(itemsjson_file
result here in attachment, and as usual just change name from txt to json.
Nosoop you are the best!

Fallowup questions. How often does items_game change? Every update or whenever they change something inside? Is the structure of items_game consistent? Did they ever change structure of the data inside?

Thanks again!
I will still be working on how to make it generic tho
Attached Files
File Type: txt allitems.txt (340.8 KB, 35 views)
Cieniu97 is offline
nosoop
Veteran Member
Join Date: Aug 2014
Old 10-14-2021 , 02:03   Re: TF2 Get weapon generic name
Reply With Quote #13

Quote:
Originally Posted by Cieniu97 View Post
Fallowup questions. How often does items_game change? Every update or whenever they change something inside? Is the structure of items_game consistent? Did they ever change structure of the data inside?
1. Whenever they change something related to items / attributes / qualitites / &c.
2. There are minor quirks related to keys being case-insensitive; see TF2IDB's parsing logic.
3. They historically have. You probably don't need to worry about backwards-compatible breakages these days, especially since they've moved towards protobufs for newer economy things.
__________________
I do TF2, TF2 servers, and TF2 plugins.
I don't do DMs over Discord -- PM me on the forums regarding inquiries.
AlliedModders Releases / Github / TF2 Server / Donate (BTC / BCH / coffee)
nosoop is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 06:53.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode