Skip to content

Commit

Permalink
Add different notice method
Browse files Browse the repository at this point in the history
  • Loading branch information
jupitersh committed Jan 10, 2020
1 parent 6b125dc commit 2a22f51
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 9 deletions.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@ BTW, it will also print the user id of the doer in the server log so that you ca

## Changelog

**List of tweaks I made for version 1.1**
**Version 1.3.0**

- Add different notice method.

**Version 1.1**

- Add a option to turn off announcement, which means it only print it in the log file.

Expand Down
13 changes: 7 additions & 6 deletions modinfo.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "Breaking Warning"
description = "Announce when someone is hammering or light anything."
author = "辣椒小皇纸"
version = "1.2.1"
version = "1.3.0"
forumthread = ""

api_version = 10
Expand Down Expand Up @@ -30,13 +30,14 @@ configuration_options =
default = "zh",
},
{
name = "announce_ornot",
label = "Announce",
name = "notice_method",
label = "Notice Method",
hover = "",
options = {
{description = "Yes", data = true, hover = ""},
{description = "No", data = false, hover = ""},
{description = "Announce横幅公告", data = 1, hover = ""},
{description = "System Message聊天栏", data = 2, hover = ""},
{description = "None无", data = 0, hover = ""},
},
default = true,
default = 2,
},
}
8 changes: 6 additions & 2 deletions modmain.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@ local redskull = "󰀀"
local _ACTION_HAMMER = GLOBAL.ACTIONS.HAMMER.fn
GLOBAL.ACTIONS.HAMMER.fn = function(act)
if act.doer and act.target and act.target.components.workable.workleft == 1 then
if GetModConfigData("announce_ornot") then
if GetModConfigData("notice_method") == 1 then
GLOBAL.TheNet:Announce(redskull..common_string_warn..act.doer.name..common_string_hammer..act.target.name..redskull)
elseif GetModConfigData("notice_method") == 2 then
GLOBAL.TheNet:SystemMessage(redskull..common_string_warn..act.doer.name..common_string_hammer..act.target.name..redskull)
end
if act.doer.userid then
print(act.doer.name.."("..act.doer.userid..")"..common_string_hammer..act.target.name)
Expand All @@ -26,8 +28,10 @@ end
local _ACTION_LIGHT = GLOBAL.ACTIONS.LIGHT.fn
GLOBAL.ACTIONS.LIGHT.fn = function(act)
if act.doer and act.target then
if GetModConfigData("announce_ornot") then
if GetModConfigData("notice_method") == 1 then
GLOBAL.TheNet:Announce(redskull..common_string_warn..act.doer.name..common_string_light..act.target.name..redskull)
elseif GetModConfigData("notice_method") == 2 then
GLOBAL.TheNet:SystemMessage(redskull..common_string_warn..act.doer.name..common_string_light..act.target.name..redskull)
end
if act.doer.userid then
print(act.doer.name.."("..act.doer.userid..")"..common_string_light..act.target.name)
Expand Down

0 comments on commit 2a22f51

Please sign in to comment.