[1.1.32] fast-transfer ignores LuaPlayer.selected = nil

Bugs that are actually features.
Post Reply
User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5206
Joined: Tue Jul 12, 2016 9:03 am
Contact:

[1.1.32] fast-transfer ignores LuaPlayer.selected = nil

Post by eradicator »

What?

Fast transfer (Ctrl+LMB) seems to be doing it's own collision box checking instead of respecting that the player has nothing selected.

Expected behavior

If the player has nothing selected then they shouldn't be able to fast-transfer.

Reproduction

Code: Select all

/c
script.on_event(defines.events.on_tick, function(e)
  for _, p in pairs(game.players) do
    p.selected = nil
    end
  end)
  1. Start a new game.
  2. Script force selection to nil. (command or demo mod)
    zz-bugtest-linked-control-test_0.0.1.zip
    (3.03 KiB) Downloaded 118 times
  3. Take a stack and insert it into the spaceship.
  4. Take the stack back out if you want.
Author of: Belt Planner, Hand Crank Generator, Screenshot Maker, /sudo and more.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.

Rseding91
Factorio Staff
Factorio Staff
Posts: 13204
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: [1.1.32] fast-transfer ignores LuaPlayer.selected = nil

Post by Rseding91 »

Thanks for the report however it doesn't ignore it. When the action runs there is a selected entity, then on_tick happens and it's cleared, the next tick it's re-found and the cycle repeats.

There's currently no way to fully disable entity selection since that's an intricate part of how the game functions.
If you want to get ahold of me I'm almost always on Discord.

Xorimuth
Filter Inserter
Filter Inserter
Posts: 625
Joined: Sat Mar 02, 2019 9:39 pm
Contact:

Re: [1.1.32] fast-transfer ignores LuaPlayer.selected = nil

Post by Xorimuth »

eradicator wrote:
Sun Apr 25, 2021 10:15 am
From my testing, it seems to work how you want it when you use `defines.events.on_selected_entity_changed` in a mod. Using it in the command input doesn't seem to do anything (maybe I'm doing this bit wrong?). I can reproduce your issues when I use `on_tick` though.
My mods
Content: Freight Forwarding | Spidertron Patrols | Spidertron Enhancements | Power Overload
QoL: Factory Search | Remote Configuration | Module Inserter Simplified | Wire Shortcuts X | Ghost Warnings

User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5206
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Re: [1.1.32] fast-transfer ignores LuaPlayer.selected = nil

Post by eradicator »

Xorimuth wrote:
Sun Apr 25, 2021 7:25 pm
From my testing, it seems to work how you want it when you use `defines.events.on_selected_entity_changed` in a mod.
That is actually exactly what I was doing when I first encountered the issue. Upon further testing that works for all items except for items with the infamous "only-in-cursor" flag. :roll: :cry:
Rseding91 wrote:
Sun Apr 25, 2021 5:51 pm
There's currently no way to fully disable entity selection
Game_view_settings does this as far as I know, but completely disabling it does not work for my usecase this time.
Rseding91 wrote:
Sun Apr 25, 2021 5:51 pm
Thanks for the report however it doesn't ignore it. When the action runs there is a selected entity, then on_tick happens and it's cleared, the next tick it's re-found and the cycle repeats.
At first I thought so too, but shouldn't that imply that on_tick is always too late to affect fast-transfer? Because I can do the exact opposite and enforce all fast transfers to go to one specific entity regardless of where the player clicks.

Code: Select all

/c
local ship = game.player.surface.find_entities_filtered{name = 'crash-site-spaceship'}[1]
script.on_event(defines.events.on_tick, function(e)
  for _, p in pairs(game.players) do p.selected = ship end
  end)
Also the demo mod additionally sets selected=nil on every possible input in the game using linked_game_control custom inputs. And a linked 'fast-transfer' input surely should be right before the actual transfer happens, right?

Code: Select all

for _, input in pairs(const.array_of_inputs) do
  script.on_event('on_linked_input_' .. (input:gsub('-','_')), function(e) 
    pprint('input:'..input)
    game.players[e.player_index].selected = nil
    end)
  end
Author of: Belt Planner, Hand Crank Generator, Screenshot Maker, /sudo and more.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.

User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5206
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Re: [1.1.32] fast-transfer ignores LuaPlayer.selected = nil

Post by eradicator »

Rseding91 wrote:
Sun Apr 25, 2021 5:51 pm
Would you please be so nice and confirm that you still consider this NaB after reading my second post/the demo mod? I kinda got the feeling that the on_tick example overshadowed the real issue.
Author of: Belt Planner, Hand Crank Generator, Screenshot Maker, /sudo and more.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.

Rseding91
Factorio Staff
Factorio Staff
Posts: 13204
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: [1.1.32] fast-transfer ignores LuaPlayer.selected = nil

Post by Rseding91 »

eradicator wrote:
Wed May 05, 2021 12:52 pm
Rseding91 wrote:
Sun Apr 25, 2021 5:51 pm
Would you please be so nice and confirm that you still consider this NaB after reading my second post/the demo mod? I kinda got the feeling that the on_tick example overshadowed the real issue.
I do still consider it not a bug.
If you want to get ahold of me I'm almost always on Discord.

User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5206
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Re: [1.1.32] fast-transfer ignores LuaPlayer.selected = nil

Post by eradicator »

Thanks for checking. I guess my understanding of events is just lacking then. Are linked control custom input events generally raised after the engine raised normal events for them then? [Edit: See post below]
Last edited by eradicator on Wed May 05, 2021 6:41 pm, edited 2 times in total.
Author of: Belt Planner, Hand Crank Generator, Screenshot Maker, /sudo and more.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.

User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5206
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Re: [1.1.32] fast-transfer ignores LuaPlayer.selected = nil

Post by eradicator »

Ok...so I did another test and now I understand. I did not expect the transfer event to happen an entire tick after the input.

Code: Select all

/c
local wait = false
script.on_event('on_linked_input_fast_entity_transfer', function(e)
  local p = game.players[e.player_index]
  game.print(e.tick .. ' Ctrl+LMB on ' .. ( p.selected and p.selected.name or 'nil'))
  p.selected = nil
  wait = true
  end)
  
script.on_event(defines.events.on_player_fast_transferred, function(e)
  local p = game.players[e.player_index]
  game.print(e.tick .. ' Fast transfer event on ' .. ( p.selected and p.selected.name or 'nil'))
  end)
  
script.on_event(defines.events.on_tick, function(e)
  if wait then
    for _, p  in pairs(game.players) do
      if p.selected == nil then
        game.print(e.tick .. ' Selected was nil for ' .. p.name)
      else
        game.print(e.tick .. ' Selected was '..p.selected.name..' for ' .. p.name)
        wait = false
        end
      end
    end
  end)
eventorder.png
eventorder.png (26.6 KiB) Viewed 1360 times
Author of: Belt Planner, Hand Crank Generator, Screenshot Maker, /sudo and more.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.

Post Reply

Return to “Not a bug”