Skip to content

Commit

Permalink
fix: datapacks tools actions
Browse files Browse the repository at this point in the history
  • Loading branch information
majestyotbr committed Aug 24, 2024
1 parent 65c58b0 commit 34ab14e
Show file tree
Hide file tree
Showing 20 changed files with 80 additions and 0 deletions.
8 changes: 8 additions & 0 deletions data-canary/scripts/actions/tools/crowbar.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
local crowbar = Action()

function crowbar.onUse(player, item, fromPosition, target, toPosition, isHotkey)
return ActionsLib.useCrowbar(player, item, fromPosition, target, toPosition, isHotkey)
end

crowbar:id(3304)
crowbar:register()
8 changes: 8 additions & 0 deletions data-canary/scripts/actions/tools/machete.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
local machete = Action()

function machete.onUse(player, item, fromPosition, target, toPosition, isHotkey)
return ActionsLib.useMachete(player, item, fromPosition, target, toPosition, isHotkey)
end

machete:id(3308)
machete:register()
8 changes: 8 additions & 0 deletions data-canary/scripts/actions/tools/pick.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
local pick = Action()

function pick.onUse(player, item, fromPosition, target, toPosition, isHotkey)
return ActionsLib.usePick(player, item, fromPosition, target, toPosition, isHotkey)
end

pick:id(3456)
pick:register()
8 changes: 8 additions & 0 deletions data-canary/scripts/actions/tools/rope.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
local rope = Action()

function rope.onUse(player, item, fromPosition, target, toPosition, isHotkey)
return ActionsLib.useRope(player, item, fromPosition, target, toPosition, isHotkey)
end

rope:id(3003, 646)
rope:register()
8 changes: 8 additions & 0 deletions data-canary/scripts/actions/tools/scythe.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
local scythe = Action()

function scythe.onUse(player, item, fromPosition, target, toPosition, isHotkey)
return ActionsLib.useScythe(player, item, fromPosition, target, toPosition, isHotkey)
end

scythe:id(3453)
scythe:register()
8 changes: 8 additions & 0 deletions data-canary/scripts/actions/tools/shovel.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
local shovel = Action()

function shovel.onUse(player, item, itemEx, fromPosition, target, toPosition, isHotkey)
return ActionsLib.useShovel(player, item, itemEx, fromPosition, target, toPosition, isHotkey)
end

shovel:id(3457, 5710)
shovel:register()
8 changes: 8 additions & 0 deletions data-canary/scripts/actions/tools/spoon.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
local spoon = Action()

function spoon.onUse(player, item, fromPosition, target, toPosition, isHotkey)
return ActionsLib.useSpoon(player, item, fromPosition, target, toPosition, isHotkey)
end

spoon:id(3468)
spoon:register()
23 changes: 23 additions & 0 deletions data-canary/scripts/actions/tools/toolgear.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
local toolGear = Action()

function toolGear.onUse(player, item, fromPosition, target, toPosition, isHotkey)
if math.random(100) > 5 then
return ActionsLib.onUseRope(player, item, fromPosition, target, toPosition, isHotkey)
or ActionsLib.onUseShovel(player, item, fromPosition, target, toPosition, isHotkey)
or ActionsLib.onUsePick(player, item, fromPosition, target, toPosition, isHotkey)
or ActionsLib.onUseMachete(player, item, fromPosition, target, toPosition, isHotkey)
or ActionsLib.onUseCrowbar(player, item, fromPosition, target, toPosition, isHotkey)
or ActionsLib.onUseSpoon(player, item, fromPosition, target, toPosition, isHotkey)
or ActionsLib.onUseScythe(player, item, fromPosition, target, toPosition, isHotkey)
or ActionsLib.onUseKitchenKnife(player, item, fromPosition, target, toPosition, isHotkey)
else
player:say("Oh no! Your tool is jammed and can't be used for a minute.", TALKTYPE_MONSTER_SAY)
player:addAchievementProgress("Bad Timing", 10)
item:transform(item.itemid + 1)
item:decay()
end
return true
end

toolGear:id(9594, 9596, 9598)
toolGear:register()
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions src/canary_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,7 @@ void CanaryServer::loadModules() {
modulesLoadHelper(g_modules().loadFromXml(), "modules/modules.xml");

logger.debug("Loading datapack scripts on folder: {}/", datapackName);
modulesLoadHelper(g_scripts().loadScripts(datapackFolder + "/scripts/lib", true, false), datapackFolder + "/scripts/libs");
// Load scripts
modulesLoadHelper(g_scripts().loadScripts(datapackFolder + "/scripts", false, false), datapackFolder + "/scripts");
// Load monsters
Expand Down

0 comments on commit 34ab14e

Please sign in to comment.