PC-Logix / OpenSecurity

Security addon for OpenComputers
MIT License
46 stars 24 forks source link

[Bug] Magnetic card reader only pushes event every second time #141

Closed BDevGW closed 5 years ago

BDevGW commented 5 years ago

Describe the bug When using the magnetic card reader only every second use pushes the event.

In which environment did the Bug appear? Singleplayer

To Reproduce Steps to reproduce the behavior:

  1. Run program I've attached on a computer with attatched card reader
  2. Use a configurated magnetic card on the card reader a few times
  3. see how often it prints "event!"

Expected behavior Every time I click with my card the event should be pushed.

Screenshots / Code Snippet Not a screenshot but a shrot (20 sec) video: https://www.youtube.com/watch?v=UJXw8y2bC8U

event = require("event");

while(true) do
    event.pull();
    eventname, sender, player, data, uuid = event.pull("magData");
    io.write("event!");
end

Minecraft:

Additional context

ben-mkiv commented 5 years ago

probably because you have one event.pull() doing nothing, please try with this code

event = require("event");

while(true) do
    eventname, sender, player, data, uuid = event.pull("magData");
    io.write("event!");
end
BDevGW commented 5 years ago

tired, doesn't work :( Also event.pull() pulls every event so all magData events should be pulled too.

ben-mkiv commented 5 years ago

yes it pulls the event but doesnt store the data anywhere remove the first event.pull() in your code and it will work.

your code requires 2 events to fire so that it prints "event!"

btw. you can run dmesg on the openos console, to see what events fire.

BDevGW commented 5 years ago

Oh I misunderstood you, I added only the "magData" to the line... I'm sorry maybe I shouldn't code when I'm half asleep :/