Skip to content
This repository was archived by the owner on Dec 4, 2020. It is now read-only.

Commit b1fe7fc

Browse files
committed
Merge branch 'enhance-execution' into release
2 parents 0f12d94 + 6470b92 commit b1fe7fc

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

scripts/commands/exec.lua

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,12 @@ function onTrigger(player, str)
2525
local old_os = os
2626
os = nil
2727

28+
-- Define "player" and "target" inside the string for use by the caller
29+
local define_player = "local player = GetPlayerByName(\"" .. player:getName() .. "\"); "
30+
local define_target = "local target = player:getCursorTarget(); "
31+
2832
-- Ensure the command compiles / is valid..
29-
local scriptObj, err = loadstring(str)
33+
local scriptObj, err = loadstring(define_player .. define_target .. str)
3034
if (scriptObj == nil) then
3135
player:PrintToPlayer("Failed to load the given string.")
3236
player:PrintToPlayer(err)
@@ -37,7 +41,7 @@ function onTrigger(player, str)
3741
-- Execute the string..
3842
local status, err = pcall(scriptObj)
3943
if (status == false) then
40-
player:PrintToPlayer(err)
44+
player:PrintToPlayer("Error calling: " .. str .. "\n" .. err)
4145
end
4246

4347
-- Restore the os table..

0 commit comments

Comments
 (0)