1326 posts
Location
Error 404: Could not find.
Posted 07 May 2014 - 01: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?
7083 posts
Location
Tasmania (AU)
Posted 07 May 2014 - 01:16 AM
Brackets.
1326 posts
Location
Error 404: Could not find.
Posted 07 May 2014 - 01:31 AM
Brackets.
What about them?
Please explain…
7083 posts
Location
Tasmania (AU)
Posted 07 May 2014 - 01: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.
62 posts
Posted 07 May 2014 - 02: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.
1326 posts
Location
Error 404: Could not find.
Posted 07 May 2014 - 10:41 PM
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.
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 on 07 May 2014 - 08:42 PM
1852 posts
Location
Sweden
Posted 07 May 2014 - 10:46 PM
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 )
1220 posts
Location
Earth orbit
Posted 07 May 2014 - 10: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 on 07 May 2014 - 08:55 PM
1852 posts
Location
Sweden
Posted 07 May 2014 - 10:55 PM
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
1326 posts
Location
Error 404: Could not find.
Posted 07 May 2014 - 10:55 PM
posssibly..
1220 posts
Location
Earth orbit
Posted 07 May 2014 - 10:56 PM
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 on 07 May 2014 - 08:56 PM
1281 posts
Posted 07 May 2014 - 11: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.
1326 posts
Location
Error 404: Could not find.
Posted 07 May 2014 - 11:08 PM
isn't local used for setting variables?
7083 posts
Location
Tasmania (AU)
Posted 07 May 2014 - 11:13 PM
It is. A table or function pointer is stored in a variable, same as a number or a string.
Oh, For the record Brackets [], Parenthesis ()
Heh. For the record,
not everyone speaks "American" English.
1326 posts
Location
Error 404: Could not find.
Posted 08 May 2014 - 10:47 PM
It is. A table or function pointer is stored in a variable, same as a number or a string.
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.