Jump to content




[Question]


14 replies to this topic

#1 cptdeath58

  • Members
  • 139 posts
  • LocationError 404: Could not find.

Posted 07 May 2014 - 12:12 AM

I have been trying to use the
os.pullEvent() = os.pullEventRaw()
in 1.56 but returns Unexcepted Symbol.
Is it supported in 1.56 or has it not been implemented?

#2 Bomb Bloke

    Hobbyist Coder

  • Moderators
  • 7,099 posts
  • LocationTasmania (AU)

Posted 07 May 2014 - 12:16 AM

Brackets.

#3 cptdeath58

  • Members
  • 139 posts
  • LocationError 404: Could not find.

Posted 07 May 2014 - 12:31 AM

View PostBomb Bloke, on 07 May 2014 - 12:16 AM, said:

Brackets.
What about them?
Please explain...

#4 Bomb Bloke

    Hobbyist Coder

  • Moderators
  • 7,099 posts
  • LocationTasmania (AU)

Posted 07 May 2014 - 12:34 AM

They shouldn't be there. You're trying to set the result of calling one function to the result of calling another - getting rid of the brackets will make it so that you're setting one function pointer to match that of another.

#5 HometownPotato

  • Members
  • 62 posts

Posted 07 May 2014 - 01:11 AM

Remove the parenthesis is what he means, so:
os.pullEvent = os.pullEventRaw;

So you set os.pullEvent to the os.pullEventRaw function, since calling it only returns what the function returns which will give you problems and not what you want.

#6 cptdeath58

  • Members
  • 139 posts
  • LocationError 404: Could not find.

Posted 07 May 2014 - 09:41 PM

View PostBomb Bloke, on 07 May 2014 - 12:34 AM, said:

They shouldn't be there. You're trying to set the result of calling one function to the result of calling another - getting rid of the brackets will make it so that you're setting one function pointer to match that of another.

View PostHometownPotato, on 07 May 2014 - 01:11 AM, said:

Remove the parenthesis is what he means, so:
os.pullEvent = os.pullEventRaw;

So you set os.pullEvent to the os.pullEventRaw function, since calling it only returns what the function returns which will give you problems and not what you want.

Oh, For the record Brackets [], Parenthesis ()
Thank you, HometownPotato

Edited by cptdeath58, 07 May 2014 - 09:42 PM.


#7 TheOddByte

    Lazy Coder

  • Members
  • 1,607 posts
  • LocationSweden

Posted 07 May 2014 - 09:46 PM

View Postcptdeath58, on 07 May 2014 - 09:41 PM, said:

Oh, For the record Brackets [], Parenthesis ()
That's good that you noticed that, Also when overriding the old os.pullEvent function you should create a backup of the old one
old_pullEvent = os.pullEvent -- Backup the old function
os.pullEvent = os.pullEventRaw -- Override it
os.pullEvent = old_pullEvent -- Restore it
This is good if you later want to restore the old one, otherwise you will always have ctrl+t prevention( if this is set as startup )

#8 Dog

  • Members
  • 1,179 posts
  • LocationEarth orbit

Posted 07 May 2014 - 09:53 PM

Out of curiosity, could you not also localize a variable so everything is restored when the program quits and exits (assuming you don't need to disable this somewhere within the program itself for other reasons)?
local os.pullEvent = os.pullEventRaw
Even if the program errored out, the reassignment would also 'go away' since it is local within the scope of the program, right?

Edited by Dog, 07 May 2014 - 09:55 PM.


#9 TheOddByte

    Lazy Coder

  • Members
  • 1,607 posts
  • LocationSweden

Posted 07 May 2014 - 09:55 PM

View PostDog, on 07 May 2014 - 09:53 PM, said:

Out of curiosity, could you not also localize a variable so everything is restored when the program quits and exits?
local os.pullEvent = os.pullEventRaw
Even if the program errored out, the reassignment would also 'go away' since it is local within the scope of the program, right?
Well if I'm correct that will error since you can't actually localize os.pullEvent

#10 cptdeath58

  • Members
  • 139 posts
  • LocationError 404: Could not find.

Posted 07 May 2014 - 09:55 PM

posssibly..

#11 Dog

  • Members
  • 1,179 posts
  • LocationEarth orbit

Posted 07 May 2014 - 09:56 PM

View PostTheOddByte, on 07 May 2014 - 09:55 PM, said:

Well if I'm correct that will error since you can't actually localize os.pullEvent
Ahh...well so much for my genius plan :)

Edited by Dog, 07 May 2014 - 09:56 PM.


#12 CometWolf

  • Members
  • 1,283 posts

Posted 07 May 2014 - 10:06 PM

It would error yes. Preferably you'd make a local os table containing the pullEvent function, then set that up to index to the global os table. However this will only affect direct usage of pullEvent within your script. Pre-defined functions like read would still point to the global version, so you'd be better of just overwriting that really.

#13 cptdeath58

  • Members
  • 139 posts
  • LocationError 404: Could not find.

Posted 07 May 2014 - 10:08 PM

isn't local used for setting variables?

#14 Bomb Bloke

    Hobbyist Coder

  • Moderators
  • 7,099 posts
  • LocationTasmania (AU)

Posted 07 May 2014 - 10:13 PM

It is. A table or function pointer is stored in a variable, same as a number or a string.

View Postcptdeath58, on 07 May 2014 - 09:41 PM, said:

Oh, For the record Brackets [], Parenthesis ()

Heh. For the record, not everyone speaks "American" English.

#15 cptdeath58

  • Members
  • 139 posts
  • LocationError 404: Could not find.

Posted 08 May 2014 - 09:47 PM

View PostBomb Bloke, on 07 May 2014 - 10:13 PM, said:

It is. A table or function pointer is stored in a variable, same as a number or a string.

View Postcptdeath58, on 07 May 2014 - 09:41 PM, said:

Oh, For the record Brackets [], Parenthesis ()

Heh. For the record, not everyone speaks "American" English.
Sorry, didn't know you spoke a different language. I'll keep that in mind for now on.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users