New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Function to avoid overriding Equipment IDs #1326

Merged
merged 3 commits into from Jan 18, 2017

Conversation

Projects
None yet
4 participants
@GamefreakDE
Contributor

GamefreakDE commented Jan 15, 2017

Making Equipment in TTT was always really hard due to the high probability of someone overriding your number, this should fix it. Open to any suggestions.

@robotboy655 robotboy655 added the TTT label Jan 15, 2017

@GamefreakDE GamefreakDE changed the title from Making a method to avoid overriding Equipment IDs to ethod to avoid overriding Equipment IDs Jan 15, 2017

@GamefreakDE GamefreakDE changed the title from ethod to avoid overriding Equipment IDs to Function to avoid overriding Equipment IDs Jan 15, 2017

@markusmarkusz

This comment has been minimized.

Contributor

markusmarkusz commented Jan 15, 2017

Why not just do it like AddScoreGroup and GROUP_ *?
That would be much easier in my opinion.

@GamefreakDE

This comment has been minimized.

Contributor

GamefreakDE commented Jan 15, 2017

Do you mean like this?

function AddEquipmentID(name) -- Utility function to register a new ID
if G["EQUIP"..name] then error("ID of name '"..name.."' already exists!") return end
EQUIP_COUNT = EQUIP_COUNT * 2
G["EQUIP"..name] = EQUIP_COUNT
end

And at the start : EQUIP_COUNT = 4

@markusmarkusz

This comment has been minimized.

Contributor

markusmarkusz commented Jan 15, 2017

Yes, I think this would be much easier and cleaner.

@GamefreakDE

This comment has been minimized.

Contributor

GamefreakDE commented Jan 15, 2017

The problem is, wouldnt this cause problems with people who just write EQUIP_MARTY = 1024 as an example? I dont know how we should fix this because most past addon creators wont change their addons.

@markusmarkusz

This comment has been minimized.

Contributor

markusmarkusz commented Jan 15, 2017

There would be compatibility problems. I would say we're doing it just like with the UniqueID to SteamID conversion. This has also killed some addons and destroyed all bot functions in TTT. However, this affected only a few addons.
I also don't know many addons who use this equipment table. There aren't many of them. It shouldn't do much damage. Especially not with EQUIP_MARTY, since you need to have 8 different items which use this equipment table.. And that would be really much.

@GamefreakDE

This comment has been minimized.

Contributor

GamefreakDE commented Jan 15, 2017

The Problem is that in my workshop actually are many equipment items, that's the reason why I made the pull :P

@svdm

This comment has been minimized.

Collaborator

svdm commented Jan 16, 2017

I don't like hacking the global table to generate the EQUIP_* global variable. It's going to do unexpected things if name contains spaces or special characters, etc. It's also not required for equipment to have their ID in a global with a name like EQUIP_* at all.

If someone wants to make an addon with 3 pieces of equipment and store their ID in a table, that's perfectly fine. It's up to the addon author to check if a player has the equipment and make it do something, and add it in the right UI places, so as long as the ID is somewhere it's fine.

Why not something like this, which is cleaner and more flexible:

EQUIP_MAX = 4

function GenerateNewEquipmentID()
   EQUIP_MAX = EQUIP_MAX * 2
   return EQUIP_MAX
end

Which you would use in an addon like:
MY_EQUIP_THING = GenerateNewEquipmentID()

I realise the G[...] method is the same as AddScoreGroup, but I don't like it there either and wouldn't mind replacing it with a cleaner solution (although I'll have to keep most of the current version for compatibility).

@svdm svdm merged commit 38603fa into Facepunch:master Jan 18, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment