Added new entity info_custommessage
Allows map editors to concatenate a sequence of strings and then displays it using one of the pre-existing messaging entities, useful for A = B/C messages. Keys: displayentity(targetname) : The entity used to display the message, can be a targetname of a class game_text, point_worldhint or point_zsmessage zsmessagemode(choices) : If using a point_zsmessage, select the method of display with this key "0" : "Centred HUD Message" "1" : "Corner Human HUD Message" "2" : "Corner Zombie HUD Message" string01(string) : Part 01 of the full string string##(string) : Part ## of the full string, there can be up to 99 of these. Inputs: displaystrings(string): Concatenates and displays the full string using the attached entity setstring##(string) : Sets part ## of the full string, there can be up to 99 of these. Outputs: OnDisplayed : Called when the message has successfully displayed.
This commit is contained in:
parent
5b96000830
commit
ffe67db5e4
1 changed files with 69 additions and 0 deletions
|
@ -0,0 +1,69 @@
|
|||
ENT.Type = "point"
|
||||
|
||||
function ENT:Initialize()
|
||||
if not self.Initialized then -- Why is KeyValue() called before Initialize()?
|
||||
self.PartStrings = {}
|
||||
self.Initialized = true
|
||||
self.DisplayTarget = self.DisplayTarget or ""
|
||||
self.ZSMessageMode = self.ZSMessageMode or 0
|
||||
end
|
||||
end
|
||||
|
||||
function ENT:Think()
|
||||
end
|
||||
|
||||
function ENT:DisplayStrings()
|
||||
local FullString = ""
|
||||
for k,v in pairs(self.PartStrings) do
|
||||
FullString = FullString .. v
|
||||
end
|
||||
for k,v in pairs(ents.FindByName(self.DisplayTarget)) do
|
||||
local EntityClass = v:GetClass()
|
||||
if EntityClass == "game_text" then
|
||||
v:Input("AddOutput", self, self, "message "..FullString)
|
||||
v:Input("Display", self, self, FullString)
|
||||
elseif EntityClass == "point_zsmessage" then
|
||||
if self.ZSMessageMode == "1" then
|
||||
v:Input("sethumanhudmessage", self, self, FullString)
|
||||
elseif self.ZSMessageMode == "2" then
|
||||
v:Input("setzombiehudmessage", self, self, FullString)
|
||||
else
|
||||
v:Input("message", self, self, FullString)
|
||||
end
|
||||
elseif EntityClass == "point_worldhint" then
|
||||
v:Input("sethint", self, self, FullString)
|
||||
end
|
||||
end
|
||||
self:Input("OnDisplayed", self, self, FullString)
|
||||
end
|
||||
|
||||
function ENT:AcceptInput(name, activator, caller, args)
|
||||
name = string.lower(name)
|
||||
if string.sub(name, 1, 2) == "on" then
|
||||
self:FireOutput(name, activator, caller, args)
|
||||
elseif string.sub(name, 1, 9) == "setstring" then
|
||||
self:KeyValue(string.sub(name, 4,11),args)
|
||||
elseif name == "displaystrings" then
|
||||
self:DisplayStrings()
|
||||
end
|
||||
end
|
||||
|
||||
function ENT:KeyValue(key, value)
|
||||
key = string.lower(key)
|
||||
if string.sub(key, 1, 6) == "string" then
|
||||
if not self.Initialized then
|
||||
self.PartStrings = {}
|
||||
self.Initialized = true
|
||||
end
|
||||
local part = tonumber(string.sub(key,7,8))
|
||||
if part ~= nil then
|
||||
self.PartStrings[part] = value
|
||||
end
|
||||
elseif key == "displayentity" then
|
||||
self.DisplayTarget = value
|
||||
elseif key == "zsmessagemode" then
|
||||
self.ZSMessageMode = value
|
||||
elseif string.sub(key, 1, 2) == "on" then
|
||||
self:AddOnOutput(key, value)
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue