Skip to content

Commit

Permalink
Handle outputs created by AddOutput, need them for transitioning
Browse files Browse the repository at this point in the history
  • Loading branch information
ZehMatt committed Jun 3, 2024
1 parent 548c0f1 commit b4e2dd3
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
2 changes: 2 additions & 0 deletions gamemode/gametypes/hl2ep2/mapscripts/ep2_outland_08.lua
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ MAPSCRIPT.InputFilters = {}
MAPSCRIPT.EntityFilterByClass = {}
MAPSCRIPT.EntityFilterByName = {
["spawnitems"] = true,
["velsensor_car_superjump_01"] = true,
["velsensor_car_superjump_00"] = true,
}

MAPSCRIPT.GlobalStates = {
Expand Down
4 changes: 2 additions & 2 deletions gamemode/sh_vehicles.lua
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ if SERVER then
end

-- Akward hack to know if an NPC passenger is inside. We handle this with our AcceptInput hook.
vehicle:Fire("AddOutput", "OnCompanionEnteredVehicle !self,LambdaCompanionEnteredVehicle,0,-1", "0.0")
vehicle:Fire("AddOutput", "OnCompanionExitedVehicle !self,LambdaCompanionExitedVehicle,1,-1", "0.0")
vehicle:Input("AddOutput", NULL, NULL, "OnCompanionEnteredVehicle !self,LambdaCompanionEnteredVehicle,,0,-1")
vehicle:Input("AddOutput", NULL, NULL, "OnCompanionExitedVehicle !self,LambdaCompanionExitedVehicle,,1,-1")

-- We only get a model next frame, delay it.
util.RunNextFrame(function()
Expand Down
18 changes: 16 additions & 2 deletions gamemode/sv_inputoutput.lua
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ function GM:AcceptInput(ent, inputName, activator, caller, value)
for _, v in pairs(filters) do
if v == inputName then
DbgPrint(ent, "Filtered input: " .. entName .. " -> " .. inputName)

return true
end
end
Expand All @@ -49,7 +48,6 @@ function GM:AcceptInput(ent, inputName, activator, caller, value)
local res = cb(ent, inputName, activator, caller, value)
if res == true then
DbgPrint(ent, "Filtered input: " .. entName .. " -> " .. inputName)

return true
end
end
Expand All @@ -73,4 +71,20 @@ function GM:AcceptInput(ent, inputName, activator, caller, value)
return true
end

-- Deal with AddOutput.
if inputName == "AddOutput" then
-- Split outputname and output parameters.
local outputName, outputParams = string.match(value, "(%w+)%s+(.*)")

-- AddOutput uses double point instead of comma, replace that.
outputParams = string.gsub(outputParams, ":", ",")

print(ent, "AddOutput", outputName, outputParams)

ent.EntityOutputs = ent.EntityOutputs or {}
local outputs = ent.EntityOutputs[outputName] or {}
table.insert(outputs, outputParams)
ent.EntityOutputs[outputName] = outputs
end

end

0 comments on commit b4e2dd3

Please sign in to comment.