-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add wiremod integration to card reader
- Loading branch information
Showing
4 changed files
with
102 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
|
||
if not WireLib then return end | ||
|
||
AddCSLuaFile() | ||
|
||
DEFINE_BASECLASS( "base_wire_entity" ) | ||
|
||
ENT.PrintName = "Glorified Card Reader Controller" | ||
ENT.WireDebugName = "Glorified Card Reader Controller" | ||
|
||
if CLIENT then return end | ||
|
||
function ENT:Initialize() | ||
self:PhysicsInit(SOLID_VPHYSICS) | ||
self:SetMoveType(MOVETYPE_VPHYSICS) | ||
self:SetSolid(SOLID_VPHYSICS) | ||
self:SetUseType(SIMPLE_USE) | ||
|
||
self.Inputs = WireLib.CreateInputs(self, {}) | ||
self.Outputs = WireLib.CreateOutputs(self, {"Sender [ENTITY]", "Merchant [ENTITY]", "Amount"}) | ||
|
||
self.WInputs = {} | ||
end | ||
|
||
function ENT:LinkEnt(CardReader) | ||
if not IsValid(CardReader) or CardReader:GetClass() != "glorifiedbanking_cardreader" then | ||
return false, i18n.GetPhrase("gbOnlyLinkReaders") | ||
end | ||
|
||
CardReader.OnTransfer = function(s, sender, merchant, amount) | ||
WireLib.TriggerOutput(self, "Sender", sender) | ||
WireLib.TriggerOutput(self, "Merchant", merchant) | ||
WireLib.TriggerOutput(self, "Amount", amount) | ||
end | ||
|
||
self:SetReader(CardReader) | ||
WireLib.SendMarks(self, {CardReader}) | ||
|
||
return true | ||
end | ||
function ENT:UnlinkEnt() | ||
if IsValid(self.CardReader) then | ||
self.CardReader.OnTransfer = function(s, sender, merchant, amount) end | ||
end | ||
|
||
self.CardReader = nil | ||
|
||
WireLib.SendMarks(self, {}) | ||
|
||
return true | ||
end | ||
|
||
function ENT:SetReader(CardReader) | ||
if not IsValid(CardReader) or CardReader:GetClass() != "glorifiedbanking_cardreader" then return false end | ||
|
||
self.CardReader = CardReader | ||
|
||
return true | ||
end | ||
|
||
duplicator.RegisterEntityClass("glorifiedbanking_cardreader_controller", WireLib.MakeWireEnt, "Data") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
|
||
WireToolSetup.setCategory("Input, Output/Glorified Banking") | ||
WireToolSetup.open("gbcardreader", "Card Reader Controller", "glorifiedbanking_cardreader_controller", nil, "Card Reader Controller") | ||
|
||
if CLIENT then | ||
language.Add("tool.wire_gbcardreader.name", i18n.GetPhrase("gbWireToolName")) | ||
language.Add("tool.wire_gbcardreader.desc", i18n.GetPhrase("gbWireToolDesc")) | ||
language.Add("tool.wire_gbcardreader.0", i18n.GetPhrase("gbWireToolStep1")) | ||
language.Add("tool.wire_gbcardreader.1", i18n.GetPhrase("gbWireToolStep2")) | ||
end | ||
|
||
WireToolSetup.BaseLang() | ||
WireToolSetup.SetupMax(2) | ||
|
||
TOOL.NoLeftOnClass = true | ||
TOOL.ClientConVar = { | ||
model = "models/jaanus/wiretool/wiretool_siren.mdl" | ||
} | ||
|
||
WireToolSetup.SetupLinking(true) | ||
|
||
function TOOL.BuildCPanel(panel) | ||
ModelPlug_AddToCPanel(panel, "Misc_Tools", "wire_gbcardreader", nil, 1) | ||
end | ||
|
||
WireToolSetup.close() |