Skip to content

Commit

Permalink
Add safehouse logs
Browse files Browse the repository at this point in the history
  • Loading branch information
outdead committed Feb 23, 2022
1 parent be37219 commit 8c33bca
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 17 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,14 @@ This mod does not work in single player mode. Therefore, it must be installed on
```
There can be `connected`, `levelup` and `tick` events.

### _safehouse.txt
```text
[23-02-22 17:31:51.126] 76561190000000000 "outdead" take safehouse 10909,9397,11,11 owner="outdead".
[23-02-22 18:04:53.263] 76561190000000000 "outdead" release safehouse 10909,9397,11,11 owner="outdead" members=["rez"].
[23-02-22 17:40:16.922] 76561190000000000 "outdead" remove player from safehouse 10909,9397,11,11 owner="outdead" target="rez".
[23-02-22 17:39:09.932] 76561190000000000 "outdead" join to safehouse 10880,9401,8,11 owner="rez".
```

## Warning
Log Extender is under development and is being tested on the server [Last Day](https://last-day.wargm.ru). You can join our server or use the mod on your own server.
If you think you have found a bug, write about it in the [bug reporting topic](https://steamcommunity.com/workshop/filedetails/discussion/1844524972/1638668751263547005/)
Expand Down
61 changes: 44 additions & 17 deletions src/lua/client/LogExtender.lua
Original file line number Diff line number Diff line change
Expand Up @@ -328,15 +328,6 @@ LogExtender.DumpSafehouse = function(player, action, safehouse, target)
local area = {}
local owner = player:getUsername()

--if instanceof(safehouse, 'IsoGridSquare') then
-- local zone = safehouse:getZone()
-- area = {
-- Top = zone:getX() .. "x" .. zone:getY(),
-- Bottom = zone:getX()+zone:getHeight() .. "x" .. zone:getY()+zone:getWidth(),
-- zone = zone:getX() .. "," .. zone:getY() .. "," .. zone:getHeight() .. "," .. zone:getWidth()
-- };
--end

if instanceof(safehouse, 'SafeHouse') then
owner = safehouse:getOwner();
area = {
Expand All @@ -348,9 +339,26 @@ LogExtender.DumpSafehouse = function(player, action, safehouse, target)

message = message .. ' ' .. area.zone
message = message .. ' owner="' .. owner .. '"'

if action == "release safehouse" then
message = message .. ' members=['

local members = safehouse:getPlayers();
for j = 0, members:size() - 1 do
local member = members:get(j)

if member ~= owner then
message = message .. '"' .. member .. '"'
if j ~= members:size() - 1 then
message = message .. ','
end
end
end
message = message .. ']'
end
else
message = message .. ' ' .. '0,0,0,0'
message = message .. ' owner="' .. '' .. '"'
message = message .. ' ' .. '0,0,0,0' -- TODO: What can I do?
message = message .. ' owner="' .. player:getUsername() .. '"'
end

if target ~= nil then
Expand Down Expand Up @@ -406,7 +414,15 @@ LogExtender.OnTakeSafeHouse = function()
originalOnTakeSafeHouse(worldobjects, square, player)

local character = getSpecificPlayer(player)
LogExtender.DumpSafehouse(character, "take safehouse", square, nil)
local safehouse = nil

local safehouseList = SafeHouse.getSafehouseList();
for i = 0, safehouseList:size() - 1 do
safehouse = safehouseList:get(i);
break;
end

LogExtender.DumpSafehouse(character, "take safehouse", safehouse, nil)
end
end

Expand All @@ -430,23 +446,31 @@ LogExtender.OnReleaseSafeHouseCommand = function()
local command = ISChat.instance.textEntry:getText();
if command == "/releasesafehouse" then
local character = getSpecificPlayer(0)
LogExtender.DumpSafehouse(character, "release safehouse", nil, nil)
local safehouse = nil

local safehouseList = SafeHouse.getSafehouseList();
for i = 0, safehouseList:size() - 1 do
safehouse = safehouseList:get(i);
break;
end

LogExtender.DumpSafehouse(character, "release safehouse", safehouse, nil)
end

onCommandEnteredOriginal(self)
end
end

LogExtender.OnRemovePlayerFromSafehouse = function()
local onCommandEnteredOriginal = ISChat.onCommandEntered;
local onRemovePlayerFromSafehouseOriginal = ISSafehouseUI.onRemovePlayerFromSafehouse;

ISSafehouseUI.onRemovePlayerFromSafehouse = function(self, button, player)
if button.internal == "YES" then
local character = getPlayer()
LogExtender.DumpSafehouse(character, "remove player from safehouse", button.parent.ui.safehouse, button.parent.ui.selectedPlayer)
end

onCommandEnteredOriginal(self, button, player)
onRemovePlayerFromSafehouseOriginal(self, button, player)
end
end

Expand Down Expand Up @@ -579,12 +603,11 @@ LogExtender.OnGameStart = function()
end

if SandboxVars.LogExtender.TakeSafeHouse then
--LogExtender.OnTakeSafeHouse()
LogExtender.OnTakeSafeHouse()
end

if SandboxVars.LogExtender.ReleaseSafeHouse then
LogExtender.OnReleaseSafeHouse()
LogExtender.OnReleaseSafeHouseCommand()
end

if SandboxVars.LogExtender.RemovePlayerFromSafehouse then
Expand All @@ -596,4 +619,8 @@ LogExtender.OnGameStart = function()
end
end

if SandboxVars.LogExtender.ReleaseSafeHouse then
LogExtender.OnReleaseSafeHouseCommand()
end

Events.OnGameStart.Add(LogExtender.OnGameStart);

0 comments on commit 8c33bca

Please sign in to comment.