forked from d1zzy/pvpgn
-
Notifications
You must be signed in to change notification settings - Fork 154
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Lua scripts pack. It is a part of PvPGN now.
First large implementation in Lua is Trivia Quiz Game (/quiz command) http://i.imgur.com/8QV3blt.png
- Loading branch information
Showing
36 changed files
with
7,534 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,17 @@ | ||
# TODO: add lua files here | ||
# copy all files from lua directory | ||
|
||
file(GLOB DEPLOY_FILES_AND_DIRS "${PROJECT_SOURCE_DIR}/lua/*") | ||
|
||
foreach(ITEM ${DEPLOY_FILES_AND_DIRS}) | ||
IF( IS_DIRECTORY "${ITEM}" ) | ||
LIST( APPEND DIRS_TO_DEPLOY "${ITEM}" ) | ||
ELSE() | ||
IF(NOT ${ITEM} MATCHES "CMakeLists.txt") | ||
LIST( APPEND FILES_TO_DEPLOY "${ITEM}" ) | ||
ENDIF(NOT ${ITEM} MATCHES "CMakeLists.txt") | ||
ENDIF() | ||
endforeach() | ||
|
||
INSTALL( FILES ${FILES_TO_DEPLOY} DESTINATION ${LOCALSTATEDIR}/lua ) | ||
INSTALL( DIRECTORY ${DIRS_TO_DEPLOY} DESTINATION ${LOCALSTATEDIR}/lua ) | ||
|
||
install(FILES | ||
DESTINATION ${LOCALSTATEDIR}/lua) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
--[[ | ||
Copyright (C) 2014 HarpyWar ([email protected]) | ||
This file is a part of the PvPGN Project http://pvpgn.pro | ||
Licensed under the same terms as Lua itself. | ||
]]-- | ||
|
||
|
||
-- Send text to user from server. Works like /announce, | ||
-- but directly to user and message text is not red. | ||
-- /redirect <username> <message> | ||
function command_redirect(account, text) | ||
|
||
local args = split_command(text, 2) | ||
|
||
if not args[1] or not args[2] then | ||
api.describe_command(account.name, args[0]) | ||
return 1 | ||
end | ||
|
||
-- get destination account | ||
local dest = api.account_get_by_name(args[1]) | ||
|
||
if next(dest) == nil or dest.online == "false" then | ||
api.message_send_text(account.name, message_type_error, account.name, "User '" ..args[1].. "' is offline") | ||
return 1 | ||
end | ||
|
||
api.message_send_text(dest.name, message_type_info, dest.name, args[2]) | ||
|
||
return 1 | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
--[[ | ||
Copyright (C) 2014 HarpyWar ([email protected]) | ||
This file is a part of the PvPGN Project http://pvpgn.pro | ||
Licensed under the same terms as Lua itself. | ||
]]-- | ||
|
||
|
||
-- | ||
-- Read file w3motd.txt line by line and send text to user | ||
-- | ||
|
||
local username = nil | ||
|
||
function command_w3motd(account, text) | ||
-- allow warcraft 3 client only | ||
if not (account.clienttag == "W3XP" or account.clienttag == "WAR3") then | ||
return 0 | ||
end | ||
|
||
username = account.name | ||
local data = file_load(config.motdw3file, w3motd_sendline_callback) | ||
|
||
return 1 | ||
end | ||
|
||
function w3motd_sendline_callback(line) | ||
api.message_send_text(username, message_type_info, nil, line) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
--[[ | ||
Copyright (C) 2014 HarpyWar ([email protected]) | ||
This file is a part of the PvPGN Project http://pvpgn.pro | ||
Licensed under the same terms as Lua itself. | ||
]]-- | ||
|
||
|
||
-- Config table can be extended here with your own variables | ||
-- values are preloaded from bnetd.conf | ||
config = { | ||
-- Quiz settings | ||
quiz = true, | ||
quiz_filelist = "misc, dota, warcraft", -- display available files in "/quiz start" | ||
quiz_competitive_mode = true, -- top players loses half of points which last player received; at the end top of records loses half of points which players received in current game | ||
quiz_max_questions = 100, -- from start to end | ||
quiz_question_delay = 5, -- delay before send next question | ||
quiz_hint_delay = 20, -- delay between prompts | ||
quiz_users_in_top = 15, -- how many users display in TOP list | ||
quiz_channel = nil, -- (do not modify!) channel when quiz has started (it assigned with start) | ||
|
||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
--[[ | ||
Copyright (C) 2014 HarpyWar ([email protected]) | ||
This file is a part of the PvPGN Project http://pvpgn.pro | ||
Licensed under the same terms as Lua itself. | ||
]]-- | ||
|
||
|
||
-- Get count of all online users | ||
function users_get_count() | ||
local count = 0 | ||
for id,username in pairs(api.server_get_users()) do | ||
count = count + 1 | ||
end | ||
return count | ||
end | ||
|
||
-- Get count of all server account | ||
function accounts_get_count() | ||
local count = 0 | ||
for id,username in pairs(api.server_get_users(true)) do | ||
count = count + 1 | ||
end | ||
return count | ||
end | ||
|
Oops, something went wrong.