diff options
author | Elias Fleckenstein <eliasfleckenstein@web.de> | 2020-10-18 16:18:07 +0200 |
---|---|---|
committer | Elias Fleckenstein <eliasfleckenstein@web.de> | 2020-10-18 16:18:07 +0200 |
commit | 1a7d3d8188d3f484b6c3f0f05fd057d543a34725 (patch) | |
tree | eeb487998aa86e01c9a7d55d4ff1156cc598b349 /builtin/client/util.lua | |
parent | 1e4f3549292472323d49ffad4e856ba60dd81e0c (diff) | |
download | dragonfireclient-1a7d3d8188d3f484b6c3f0f05fd057d543a34725.tar.xz |
Extended ClientObjectRef; Improved CrystalPvP
Diffstat (limited to 'builtin/client/util.lua')
-rw-r--r-- | builtin/client/util.lua | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/builtin/client/util.lua b/builtin/client/util.lua index 895609288..4a6a72d72 100644 --- a/builtin/client/util.lua +++ b/builtin/client/util.lua @@ -20,3 +20,21 @@ function core.parse_relative_pos(param) if success then pos = vector.round(vector.add(core.localplayer:get_pos(), pos)) end return success, pos end + +function core.switch_to_item(item) + for index, stack in ipairs(core.get_inventory("current_player").main) do + if stack:get_name() == item then + core.localplayer:set_wield_index(index - 1) + return true + end + end + return false +end + +function core.get_pointed_thing() + local pos = core.camera:get_pos() + local pos2 = vector.add(pos, vector.multiply(core.camera:get_look_dir(), 5)) + local ray = core.raycast(pos, pos2, true, true) + + return ray:next() +end |