-
-
Notifications
You must be signed in to change notification settings - Fork 638
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added a new method to register scripts by the map position and rework…
… on "registerLuaEvent" function (#317) With this modification, we can register action scripts without needing the action id/unique id or the item being on the map, as there is also a second parameter that creates the item (if it doesn't exist). * Added a small example script on how to use record mode by position (worldboard.lua) * A rework was performed on the "registerLuaEvent" function * New functions were created to improve the understanding and reading of the function code. Fixed somes bugs related to loading maps: * Added a "try/catch" to check if the map was loaded correctly (sending an error message if there is a problem, such as the wrongly named file or not found); * Added a boolean value "mainMap" so that some functions are only executed when loading the main map, avoiding duplications or errors. Being that: it was divided into four smaller functions; registerLuaItemEvent(event); registerLuaUniqueEvent(event); registerLuaActionEvent(event); registerLuaPositionEvent(event); Simple example of use: action:position({x = 4998, y = 5000, z = 7}, 19236) Small explanation: * The position parameter is obviously mandatory, the item id/name parameter is not mandatory, it can be used to create an item on the map without needing to edit the map, for scripts that need to check the id of the item inside them. Important notes: * If the item already exists in the position, a warning will be sent informing that the item already exists and cannot be created, this warning will only disappear if the id/name parameter is removed. * If the item doesn't exist (ie it's a wrong id or name), then the distro will tell you that the item is invalid. See our wiki page for more informations: https://github.com/opentibiabr/canary/wiki/revscriptsys
- Loading branch information
Showing
16 changed files
with
436 additions
and
121 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
local communicates = { | ||
"Welcome to Canary Server! Visit the organization to see all our work: https://github.com/opentibiabr", | ||
"Did you like it? Help support what we do here with a donation by visiting the link: https://docs.opentibiabr.org/donate/", | ||
"Visit our discord to ask questions or report issues: https://discord.com/invite/3NxYnyV" | ||
} | ||
|
||
local scriptConfig = { | ||
itemId = 19236, | ||
registerPositions = { | ||
{x = 4998, y = 5000, z = 7}, | ||
{x = 4971, y = 5300, z = 5}, | ||
{x = 4802, y = 5088, z = 7}, | ||
{x = 5518, y = 5126, z = 6}, | ||
{x = 5852, y = 5295, z = 5}, | ||
{x = 1940, y = 1345, z = 7}, | ||
{x = 4709, y = 4186, z = 7} | ||
} | ||
} | ||
|
||
local worldBoard = Action() | ||
|
||
function worldBoard.onUse(player, item, fromPosition, target, toPosition, isHotkey) | ||
-- If the item id is not the one on the worldboard, it will return here | ||
if item:getId() ~= scriptConfig.itemId then | ||
return false | ||
end | ||
|
||
for index, value in pairs(communicates) do | ||
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, value) | ||
end | ||
return true | ||
end | ||
|
||
-- Usage: action:position(position, itemId) | ||
-- Explanation: The variable "item id" is optional, the id or the name of the item can be added, the item will be created in the map if it does not exist. If it already exists on the map, it will send a warning informing (in the distro) so the id must be removed so that the warning disappears keeping only the position) | ||
for index, value in pairs(scriptConfig.registerPositions) do | ||
worldBoard:position(value, scriptConfig.itemId) | ||
end | ||
|
||
worldBoard:register() |
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
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
Oops, something went wrong.