Jump to content




os.queueEvent not working


  • You cannot reply to this topic
3 replies to this topic

#1 houseofkraft

  • Members
  • 170 posts
  • LocationUSA

Posted 16 January 2017 - 09:17 PM

Hello!

I was making an ACPI program for ComputerCraft and I tried to test it out by running it and pressing CTRL+S (not holding it) and it's supposed to queue "ACPI-SH" but it didn't! The PK variable did reset like normal though.

Code

Pastebin

Thanks!

#2 valithor

  • Members
  • 1,053 posts

Posted 16 January 2017 - 10:33 PM

How exactly are you checking if your event is being queued? And how are you checking if the pk table is being reset?

Do keep in mind when you do things like:

_G.pk = {}
local pk = _G.pk

You do not have 2 tables, you instead have 2 variables that point to the same table. Any changes made using one variable to the table happens to the other variable's table simply because they are the same table.

This makes things like the following redundant (You are setting _G.pk to itself since pk and _G.pk both point to the same table):

table.insert(pk,key)
_G.pk = pk

These things really wouldn't keep the programming from working, it is just useful things to know.

As best I can tell by reading through the code, the pk table is never actually reset. Whenever you try to reset the table you create a new local pk table (this is different from the local pk table at the top of your code), and set _G.pk to it. However, whenever you receive a new event you set _G.pk equal back to the local pk defined at the top of the code causing it to have all of the previous entries.

Edited by valithor, 16 January 2017 - 10:38 PM.


#3 houseofkraft

  • Members
  • 170 posts
  • LocationUSA

Posted 16 January 2017 - 10:39 PM

I'm checking how it's queued by making it so when the user presses a key it adds //KEYNUMBER// to the table. When it detects that it is //CTRL//R OR S// then it will queue the event and reset the table.

#4 valithor

  • Members
  • 1,053 posts

Posted 16 January 2017 - 10:41 PM

View Posthouseofkraft, on 16 January 2017 - 10:39 PM, said:

I'm checking how it's queued by making it so when the user presses a key it adds //KEYNUMBER// to the table. When it detects that it is //CTRL//R OR S// then it will queue the event and reset the table.

Seems we have a failure to communicate :)

What i meant is how are you making sure that os.queueEvent("ACPI-SH") is not actually queueing the event? Where do you check if the event is or is not queued, and how.





2 user(s) are reading this topic

0 members, 2 guests, 0 anonymous users