-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
31 changed files
with
1,157 additions
and
180 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
76 changes: 76 additions & 0 deletions
76
gamemodes/terrortown/entities/entities/info_manipulate.lua
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,76 @@ | ||
--- | ||
-- @class ENT | ||
-- @desc Dummy entity to convert ZM info_manipulate traps to TTT ones | ||
-- @section InfoManipulate | ||
|
||
ENT.Type = "point" | ||
ENT.Base = "base_point" | ||
|
||
--- | ||
-- @realm server | ||
function ENT:Think() | ||
if not self.Replaced then | ||
self:CreateReplacement() | ||
|
||
self:Remove() | ||
end | ||
end | ||
|
||
--- | ||
-- Sets Hammer key values on an entity. | ||
-- @param string key The internal key name | ||
-- @param string value The value to set | ||
-- @realm server | ||
function ENT:KeyValue(key, value) | ||
if key == "OnPressed" then | ||
-- store raw, will be feeding this into the replacement's StoreOutput() | ||
self.RawOutputs = self.RawOutputs or {} | ||
|
||
self.RawOutputs[#self.RawOutputs + 1] = value | ||
elseif key == "Cost" then | ||
self[key] = tonumber(value) | ||
elseif key == "Active" or key == "RemoveOnTrigger" then | ||
self[key] = tobool(value) | ||
elseif key == "Description" then | ||
self[key] = tostring(value) | ||
end | ||
end | ||
|
||
--- | ||
-- @realm server | ||
function ENT:CreateReplacement() | ||
local tgt = ents.Create("ttt_traitor_button") | ||
|
||
if not IsValid(tgt) then return end | ||
|
||
self.Replaced = true | ||
|
||
-- feed in our properties into replacement as keyvals | ||
tgt:SetPos(self:GetPos()) | ||
tgt:SetKeyValue("targetname", self:GetName()) | ||
|
||
if not self.Active then | ||
-- start locked | ||
tgt:SetKeyValue("spawnflags", tostring(2048)) | ||
end | ||
|
||
if self.Description and self.Description ~= "" then | ||
tgt:SetKeyValue("description", self.Description) | ||
end | ||
|
||
if self.Cost then | ||
tgt:SetKeyValue("wait", tostring(self.Cost)) | ||
end | ||
|
||
if self.RemoveOnTrigger then | ||
tgt:SetKeyValue("RemoveOnPress", tostring(true)) | ||
end | ||
|
||
if self.RawOutputs then | ||
for k, v in pairs(self.RawOutputs) do | ||
tgt:SetKeyValue("OnPressed", tostring(v)) | ||
end | ||
end | ||
|
||
tgt:Spawn() | ||
end |
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
47 changes: 47 additions & 0 deletions
47
gamemodes/terrortown/entities/entities/ttt_credit_adjust.lua
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,47 @@ | ||
--- | ||
-- @class ENT | ||
-- @desc Handles player credit interactions with the map | ||
-- @section CreditAdjust | ||
|
||
ENT.Type = "point" | ||
ENT.Base = "base_point" | ||
|
||
ENT.Credits = 0 | ||
|
||
--- | ||
-- Sets Hammer key values on an entity. | ||
-- @param string key The internal key name | ||
-- @param string value The value to set | ||
-- @realm server | ||
function ENT:KeyValue(key, value) | ||
if key == "OnSuccess" or key == "OnFail" then | ||
self:StoreOutput(key, value) | ||
elseif key == "credits" then | ||
self.Credits = tonumber(value) or 0 | ||
|
||
if not tonumber(value) then | ||
ErrorNoHalt(tostring(self) .. " has bad 'credits' setting.\n") | ||
end | ||
end | ||
end | ||
|
||
--- | ||
-- Called when another entity fires an event to this entity. | ||
-- @param string name The name of the input that was triggered | ||
-- @param Entity activator The initial cause for the input getting triggered; e.g. the player who pushed a button | ||
-- @realm server | ||
function ENT:AcceptInput(name, activator) | ||
if name ~= "TakeCredits" then return end | ||
|
||
if IsValid(activator) and activator:IsPlayer() then | ||
if activator:GetCredits() >= self.Credits then | ||
activator:SubtractCredits(self.Credits) | ||
|
||
self:TriggerOutput("OnSuccess", activator) | ||
else | ||
self:TriggerOutput("OnFail", activator) | ||
end | ||
end | ||
|
||
return true | ||
end |
Oops, something went wrong.