How did you make the window?AndakRainor wrote:Is there any way to deactivate the throwing of mouse item ? I made a small window where I would like to drag and drop items, but when I click on it the mouse item is thrown.
Here is a simple option that restricts throwing, but not dropping; and calls a function when clicked.
Code: Select all
useTrigger = true --auto-spawns a connected floor_trigger on the tile
windowActive = false
function click_action(bool)
if bool then
--_________________________ Change script to suit
local item = getMouseItem()
if item then
hudPrint("You clicked the window with a "..item.go.name..".")
end
--_________________________
end
end
_createWindow = function(context)
if not context.mouseDown(2) and party.facing == self.go.facing
and party.x == self.go.x and party.y == self.go.y
and party.elevation == self.go.elevation --can be commented out
then
local dir, result = context.button(self.go.id.."window", 0, 0, context.width, context.height * .6)
if result then
click_action(context.mouseDown(3))
end
end
end
function _setWindowActive(bool)
windowActive = bool
print(bool)
end
function activate()
windowActive = true
end
function deactivate()
windowActive = false
end
function toggleWindowActive()
windowActive = not windowActive
end
if useTrigger then
self.go:spawn('floor_trigger').floortrigger:addConnector('onToggle', self.go.id, "toggleWindowActive")
end
Code: Select all
defineObject{
name = "party",
components = {
{
class = "Party",
onMove = function(self, dir) end,
onDrawGui = function(self, context) window2.script.createWindow(context) end,
},
{
class = "Light",
name = "torch",
range = 12,
},
},
editorIcon = 32,
placement = "floor",
}
Then position and face the script _entity to indicate the tile and direction where the window is. Activate the effect
either via script using one of the setter functions, or via the built in trigger/plate (which is automatically spawned by default).