From 35fac26fd45ebc9d769bc67dc509b026458e2c4e Mon Sep 17 00:00:00 2001 From: David Cernat Date: Wed, 11 Jul 2018 00:32:59 +0300 Subject: [PATCH] [Commands] Clean up /setcollision command --- scripts/commandHandler.lua | 15 ++++++++------- scripts/menu/help.lua | 2 +- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/scripts/commandHandler.lua b/scripts/commandHandler.lua index e4356cba7d..dd394d7af2 100644 --- a/scripts/commandHandler.lua +++ b/scripts/commandHandler.lua @@ -689,26 +689,27 @@ function commandHandler.ProcessCommand(pid, cmd) frametimeMultiplier = inputValue / WorldInstance.defaultTimeScale end - elseif cmd[1] == "setcollision" and cmd[2] ~= nil and cmd[3] ~= nil and admin then + elseif cmd[1] == "setcollision" and admin then local collisionState - if cmd[3] == "on" then + if cmd[2] ~= nil and cmd[3] == "on" then collisionState = true - elseif cmd[3] == "off" then + elseif cmd[2] ~= nil and cmd[3] == "off" then collisionState = false else - tes3mp.SendMessage(pid, "Not a valid argument. Use /setcollision on/off (on/off)\n", false) + tes3mp.SendMessage(pid, "Not a valid argument. Use /setcollision on/off\n", false) return false end local categoryInput = string.upper(cmd[2]) + local categoryValue = enumerations.objectCategories[categoryInput] - if enumerations.objectCategories[categoryInput] == 0 then + if categoryValue == enumerations.objectCategories.PLAYER then tes3mp.SetPlayerCollisionState(collisionState) - elseif enumerations.objectCategories[categoryInput] == 1 then + elseif categoryValue == enumerations.objectCategories.ACTOR then tes3mp.SetActorCollisionState(collisionState) - elseif enumerations.objectCategories[categoryInput] == 2 then + elseif categoryValue == enumerations.objectCategories.PLACED_OBJECT then tes3mp.SetPlacedObjectCollisionState(collisionState) if cmd[4] == "on" then diff --git a/scripts/menu/help.lua b/scripts/menu/help.lua index d8ce0682f1..5cbce2b382 100644 --- a/scripts/menu/help.lua +++ b/scripts/menu/help.lua @@ -238,7 +238,7 @@ Menus["help admin page 2"] = { color.White .. "Set the enforced log level for a particular player\n" .. color.Yellow .. "/setphysicsfps /default\n" .. color.White .. "Set the physics framerate for a particular player\n" .. - color.Yellow .. "/setcollision on/off (on/off)\n" .. + color.Yellow .. "/setcollision on/off\n" .. color.White .. "Set the collision state for an object category (PLAYER, ACTOR or PLACED_OBJECT), " .. "with the third optional argument affecting whether placed objects use actor-like collision", buttons = {