Skip to content
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

Fix wirelink issues #2942

Merged
merged 3 commits into from
Dec 14, 2023
Merged

Fix wirelink issues #2942

merged 3 commits into from
Dec 14, 2023

Conversation

Denneisk
Copy link
Member

@Denneisk Denneisk commented Dec 12, 2023

  • Add createWirelink to reintroduce creating wirelink outputs
  • Wirelink TriggerOutput now sends a table with field wirelink = true to indicate it's a wirelink trigger
  • Fixed validWirelink would consider most wirelinks invalid
  • Fixed EGP wirelink outputted nothing

Fixes #2940

- Add createWirelink
- Fixed validWirelink expected ent.extended
@Denneisk
Copy link
Member Author

Denneisk commented Dec 12, 2023

@Grocel You can check for wirelinks with this just by doing

function ENT:TriggerInput(name, value, ext)
local wired = self:IsConnectedInputWire(name) or istable(ext) and ext.wirelink

@Fasteroid Fasteroid mentioned this pull request Dec 12, 2023
@Grocel
Copy link
Contributor

Grocel commented Dec 12, 2023

@Grocel You can check for wirelinks with this just by doing

function ENT:TriggerInput(name, value, ext)
local wired = self:IsConnectedInputWire(name) or istable(ext) and ext.wirelink

Thanks, this is very helpful! Is it guaranteed to be passed with every trigger call that might come via wirelink? I think it could be helpful to pass the name of the wirelink it was coming from as well. Like if it was triggered via "wirelinkA" or "wirelinkB" etc. in case of multiple wirelink ports.

@Denneisk
Copy link
Member Author

Denneisk commented Dec 12, 2023

Is it guaranteed to be passed with every trigger call that might come via wirelink?

As far as I know, wirelinks are only usable with E2, so this will always exist for a wirelink input.

I think it could be helpful to pass the name of the wirelink it was coming from as well.

Wirelinks are just entities and they don't directly retain any information about Wiremod wires, so that's a lot more involved. I would recommend not creating multiple wirelink outputs since they're all the same.

@Grocel
Copy link
Contributor

Grocel commented Dec 13, 2023

As far as I know, wirelinks are only usable with E2, so this will always exist for a wirelink input.
Wirelinks are just entities and they don't directly retain any information about Wiremod wires, so that's a lot more involved. I would recommend not creating multiple wirelink outputs since they're all the same.

That's fine for my part. I will apply your hint into my addon soon. I am not that familiar with the current Workshop release scheduling nowadays, but I think it will be quite a while until the next "stable" releases. So I will have to account for the older live version as well.

return this
end

e2function wirelink entity:createWirelink()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the point of this function?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mimics the old entity:wirelink() that would create a wirelink output. You can do the same with the Wire tool, but I guess some people wanted to generate wirelinks using E2 instead.

Copy link
Contributor

@thegrb93 thegrb93 Dec 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not add back the old behavior to entity:wirelink instead of adding this new function?

Copy link
Member Author

@Denneisk Denneisk Dec 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see it as necessary. You don't create entity outputs when doing entity. I don't believe E2 users are using the wirelink output since they just needed to use entity:wirelink() to even get the wirelink, so there is no point in using the wirelink output on the entity.

return this
end

e2function wirelink entity:createWirelink()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't fix #2940. You need to revert the change. We don't break backwards compatibility for literally no reason. This is just saving a one liner. My idea was to deprecate this, then add e:getWirelink() for the new behavior.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The wirelink being created isn't even the problem, it's the valid check on wirelinks expecting an extended field on the entity to be set, because wirelinks have to be extended for no reason.

return this
end

e2function wirelink entity:createWirelink()
Copy link
Contributor

@Fasteroid Fasteroid Dec 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, this doesn't fix #2940, please revert the behavior of e:wirelink()

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I literally tested it, it's fixed in this PR.

Copy link
Contributor

@Fasteroid Fasteroid Dec 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nevermind, actually tested and it really is fixed... somehow.

@@ -28,7 +30,6 @@ end

local function validWirelink(self, ent)
if not IsValid(ent) then return false end
if not ent.extended then return false end
if not isOwner(self, ent) then return false end
return true
end
Copy link
Member Author

@Denneisk Denneisk Dec 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the cause of #2940. It's not a backwards compatibility problem, it was an oversight. There's no purpose for entities to store this flag if you're using it as a wirelink; there are no unique restrictions for wirelinks. Wirelinks are just entities.

If you can give me a good reason why someone would use the E2-generated wirelink output versus directly using the returned wirelink object, I'll concede, but you're arguing for bad code style.

Copy link
Contributor

@Grocel Grocel Dec 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be honest extended isn't even a good name for marking a wirelink. A field wirelinkExist or something would have been better. Changing it however could break BC to addons.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be honest extended isn't even a good name for marking a wirelink. A field wirelinkExist or something would have been better. Changing it however could break BC to addons.

hasWirelink would be best imo

@Denneisk
Copy link
Member Author

@Vurv78 @thegrb93 Do either of you have anything more to say?

@thegrb93 thegrb93 merged commit 8ab3bc1 into wiremod:master Dec 14, 2023
1 check failed
@thegrb93
Copy link
Contributor

thegrb93 commented Dec 14, 2023

Is #2941 able to be closed then?

@Denneisk
Copy link
Member Author

Yes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

E2 :wirelink() broken backwards-compat
5 participants