There's currently no available Lua script method for setting cursors. They can only be set via action part in editor.
As for the currently held item...
... will return the currently held item or nil (empty). I recommend adding :getName() to the end of the line though so that it only returns the string name of the item instead of the entire id, tableid & name etc.
To set the cursor via a script you would need to create some called by other actions which contain set cursor action parts. You would need to name them something relevant so that when you execute a function it would update the cursor based on the returned string of the currently held item name.
local itm = nil
function cursorLoop()
if not game.UsedItem:isEmpty()
if game.UsedItem:getName() ~= itm then
itm = game.UsedItem:getName(); startAction(Actions["cur_" .. itm])
end
elseif game.UsedItem:isEmpty() and itm ~= nil then
itm = nil; startAction("Actions[cur_default]") -- replace default with name of default cursor
end
end
registerEventHandler("mainLoop", "cursorLoop")
Long story short: you need to create some called by other actions somewhere in your ved & add the prefix
cur_ to them followed by the exact name of each item. Remember that table / object names are case sensitive. As for the script... what that is doing is listening out for when an item is held & if the item is not the same as the variable itm then it updates the variable to the new item then calls the relevant called by other action to set the cursor. I know this is a pain in the arse method, but without being able to set cursors directly via Lua script, it's about the only way you can sort this out at the minute.