How build order action tags for one mouse button (SOLVED)

Hello

I have 7 triggers for left mouse button, but action order different in on_input function depending on the triggers names.

How build this order?
Order in Editor:
image

Order in function request:
hash: [useObjectClick]
hash: [folderClick]
hash: [chairClick]
hash: [cabinetClick]
hash: [cupBigClick]
hash: [actionClick]

I’m totally guessing, but it’s probably semi-random and not something you can control, like the order of messages, init functions, etc. What are you trying to do?

I trying use different triggers in one on_input function. Example -
3 object clicks and 1 default walk action.

If order not correct - hero can walk before use object

Ah, so you have actions of different priority? If I understand correctly, can’t you just run your code, in order, in one on_input call? As in something like:

function on_input(self, action_id, action)
	if action_id == hash("click") and action.pressed then
		if isPositionWalkable(action.screen_x, action.screen_y) then
			walk()
		elseif self.mouse_colliding_object then
			use_object()
		elseif self.mouse_colliding_folder then
			open_folder()
		elseif . . .
1 Like

@ross.grams Beat me to it!

You’d have to make a count within the on_input function. Input triggers act like a baseball player. They catch it from outfield (Your devices, mouse, keyboard, etc) and throw it back to the pitcher (The input function). Not much else besides the positioning (for mouse inputs) and etc.

So, you’d have to do this within the on_input function, for just one action; the mouse_click.

function init(self)
    msg.post("." "acquire_input_focus") -- This tells the game to send input information to this script

function on_input(self, action_id, action)
    if action_id == "mouse_click" then
        mouse_presses = mouse_presses + 1
        if mouse_presses == 3 then
            object_move = true
            mouse_presses = 0
        end
    end
end

This is just an example to show you along what lines to go. You’d have to design the script yourself to your personal needs.

P.S: I notice you’re trying to use the triggers as different object presses. It doesn’t work that way. The triggers only receive the information coming from your devices, not the game. You’d have to then use that information to see if a folder, cabinet, chair, cup, or use was underneath the pointer at that point.

2 Likes

Yes you right and Thank you.

I right undertsand - you hint about make one trigger and some external checks and not make mass trigggers?

1 Like

I think count mouse clicks not good idea, because it 3 click not one. I need one click for different actions.

And about incoming information from my device - I understand it, but different order created depending on triggers name and I think it not problem add for it ID, not only name, and create right order by user.

PS: I think it simple LUA table in Defold, but I can make mistake.

You should not rely on the order in which the actions are defined in the input bindings. As others have pointed out, you need to handle this in your game logic.

Yeah I change logic. how @ross.grams hint.