[Twinsen] [0.14.0] LuaControlBehavior::disabled not work for inserter

This subforum contains all the issues which we already resolved.
User avatar
Mooncat
Smart Inserter
Smart Inserter
Posts: 1196
Joined: Wed May 18, 2016 4:55 pm
Contact:

[Twinsen] [0.14.0] LuaControlBehavior::disabled not work for inserter

Post by Mooncat »

First of all, is LuaControlBehavior::disabled for detecting whether the entity (e.g. inserter) is disabled due to circuit signals? If not, then I got it wrong and it is not a bug. :P
(But then I will need an answer for this: [Implemented request] API for accessing the entity state (enabled/disabled))

Otherwise, please read:
This property always returns false no matter I wire or unwire the entity and set or unset conditions.

I am using this snippet to check whether my inserter entity is working:

Code: Select all

function is_inserter_enabled(inserter)
   local control = inserter.get_control_behavior()
   -- Does it have control behaviour? (Not connected = no control?)
   if control and control.valid then
      -- New API from Factorio 0.13.16
      if control.disabled == nil then
         print_to_all_players("Is control disabled? nil")
      else
         if control.disabled then
            print_to_all_players("Is control disabled? true")
            return false
         else
            print_to_all_players("Is control disabled? false")
            return true
         end
      end
   end
   
   -- No control? Because not connected to network?
   return true
end
I call this function in every tick.
If the entity has not been wired since it was placed, nothing is printed as expected.
But once the entity is wired, "Is control disabled? false" is printed. But I expected "Is control disabled? true" because vanilla inserters are disabled once they are wired without conditions.
Then, no matter I set or unset conditions, as well as unwire or wire again, the same message is printed.

In case you need print_to_all_players:

Code: Select all

function print_to_all_players(message)
   for _, player in pairs(game.players) do
      player.print(message)
   end
end
Last edited by Mooncat on Fri Aug 26, 2016 4:16 pm, edited 3 times in total.
Rseding91
Factorio Staff
Factorio Staff
Posts: 14281
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: [0.13.17] LuaControlBehavior::disabled always returns false

Post by Rseding91 »

The inserters aren't disabled because of the condition. They have no work to do because of the condition but the condition is not preventing the inserter from trying to do work.

The disabled read returns true when the condition its self disables the entity - the "enable/disable" radio option in an entity control behavior GUI.

An example: enable/disable transport belt when condition isn't met.
If you want to get ahold of me I'm almost always on Discord.
User avatar
Mooncat
Smart Inserter
Smart Inserter
Posts: 1196
Joined: Wed May 18, 2016 4:55 pm
Contact:

Re: [0.13.17] LuaControlBehavior::disabled always returns false

Post by Mooncat »

Rseding91 wrote:The inserters aren't disabled because of the condition. They have no work to do because of the condition but the condition is not preventing the inserter from trying to do work.

The disabled read returns true when the condition its self disables the entity - the "enable/disable" radio option in an entity control behavior GUI.

An example: enable/disable transport belt when condition isn't met.
Sorry, but I am not quite understand...
I have already set "enable/disable" operation mode for the inserter, and the red light of the circuit connector is on.
Or did I miss something that the inserter can actually work under special circumstances? :shock:
dontunderstand.png
dontunderstand.png (161.07 KiB) Viewed 6872 times
Before: when I use my old snippet, it stops generating iron plates right after I connect it with wire.
After: now I use LuaControlBehavior::disabled, but it never stops even if I set condition to it.

I tested it on transport belt, it works like how you said:
transportbelt.png
transportbelt.png (237.23 KiB) Viewed 6872 times
It is disabled right after I connect it with wire. (The 1-tick delay is fine.)

But it doesn't work like how I expected when I test it on inserter, with or without energy:
inserter.png
inserter.png (227.52 KiB) Viewed 6872 times
My little mod for testing:
luacontrolbehavior-disabled_0.0.1.zip
(1.24 KiB) Downloaded 204 times
(It just registers entities, then iterates them in every tick and prints messages.)
Last edited by Mooncat on Thu Aug 25, 2016 5:34 pm, edited 1 time in total.
User avatar
Mooncat
Smart Inserter
Smart Inserter
Posts: 1196
Joined: Wed May 18, 2016 4:55 pm
Contact:

Re: [0.13.17] LuaControlBehavior::disabled not work for inserter

Post by Mooncat »

Hi, any news on this bug or ... not-my-expected implementation?

I have updated to 0.13.18 but this is still the same.
Maybe I should request another API? Because I want to know when the inserter is disabled. :?
User avatar
Mooncat
Smart Inserter
Smart Inserter
Posts: 1196
Joined: Wed May 18, 2016 4:55 pm
Contact:

Re: [0.14.0] LuaControlBehavior::disabled not work for inserter

Post by Mooncat »

Updated the mod for testing to support Factorio 0.14.
Still waiting for the answer. :)
luacontrolbehavior-disabled_0.0.2.zip
(1.24 KiB) Downloaded 166 times
User avatar
Klonan
Factorio Staff
Factorio Staff
Posts: 5267
Joined: Sun Jan 11, 2015 2:09 pm
Contact:

Re: [0.14.0] LuaControlBehavior::disabled not work for inserter

Post by Klonan »

I think i have confirmed the,

Inserter never reads true on get_control_behaviour().disabled,
Whether logistic condition, circuit condition or otherwise



In this case, one condition is true, the other is false. Both control settings read disabled as false.
User avatar
Mooncat
Smart Inserter
Smart Inserter
Posts: 1196
Joined: Wed May 18, 2016 4:55 pm
Contact:

Re: [0.14.0] LuaControlBehavior::disabled not work for inserter

Post by Mooncat »

Thanks for the reply and confirmation!
Now I know it is a bug and can patiently wait for the fix. :D
Twinsen
Factorio Staff
Factorio Staff
Posts: 1348
Joined: Tue Sep 23, 2014 7:10 am
Contact:

Re: [Twinsen] [0.14.0] LuaControlBehavior::disabled not work for inserter

Post by Twinsen »

Fixed in Version: 0.14.3

Also Moved LuaControlBehavior::disabled to LuaGenericOnOffControlBehavior::disabled
User avatar
Mooncat
Smart Inserter
Smart Inserter
Posts: 1196
Joined: Wed May 18, 2016 4:55 pm
Contact:

Re: [Twinsen] [0.14.0] LuaControlBehavior::disabled not work for inserter

Post by Mooncat »

Thanks a lot! <3
Post Reply

Return to “Resolved Problems and Bugs”