Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
766 B
3
Indexable
Never
local config = {
  mwId = 2129,
  flowerId = 2981,
  hotkey = "F29"
}

local mwTile = nil
onKeyPress(function(keys)
  if keys:lower() == config.hotkey:lower() then
    local tUnder = getTileUnderCursor()
    if not tUnder then return end
    if mwTile then
      mwTile:setText("")
      if mwTile == tUnder then
        mwTile = nil
        return
      end
      mwTile = tUnder
      mwTile:setText("FW")    
    else
      mwTile = tUnder
      mwTile:setText("FW")        
    end
  end  
end)

onRemoveThing(function(tile, thing)
  if tile == mwTile and thing:getId() == config.mwId then
    local flower = findItem(config.flowerId)
    if flower then
      g_game.move(flower, tile:getPosition(), 1)
    end
    mwTile:setText("")
    mwTile = nil
  end
end)