> For the complete documentation index, see [llms.txt](https://stigmax.gitbook.io/tfs-guide/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://stigmax.gitbook.io/tfs-guide/interface-actions/actions-scripting.md).

# Scripting

### Script Structure

> #### *onUse(player, item, fromPosition, target, toPosition, isHotkey)*
>
> **Parameters**:
>
> * **player**: Player who is using the item.
> * **item**: Item which is being clicked on by the player.
> * **fromPosition**: Position of where the item is clicked from.
> * **target**: The item/creature the item is used on (use with, like a fishing rod). If the item does not have the `use with` flag, `target` is equal to `item`.
> * **toPosition**: Position of where the target is located.
> * **isHotkey**: True if the item was used from hotkeys, otherwise false.
>
> **Return Value**:
>
> * true: Will allow the usage of the item, no message will be sent.
> * false: Will not use the item, player will be sent a cancel message containing the words "You cannot use this object."

### Example

```markup
<!-- Registration for the script below -->
<action itemid="2148" script="change_gold.lua" />
```

```lua
-- data/actions/scripts/change_gold.lua
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if player:getName() == "Delusion" then
        item:transform(2160)
        return true
    end
    return false -- Anybody who is not me will not be able to use the item!
end
```
