This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
Sewbacca's profile picture

A question to shell.setCompletionFunction

Started by Sewbacca, 07 April 2016 - 06:20 PM
Sewbacca #1
Posted 07 April 2016 - 08:20 PM
I programmed a new edit and set the alias.
I tried to set the completion function:
shell.setCompletionFunction(customEditPath, shell.getCompletionInfo()['rom/programs/edit'])
What did I wrong?

And by the way, how works the set completion function?
EveryOS #2
Posted 07 April 2016 - 08:33 PM

function shell.setCompletionFunction( sProgram, fnComplete )
  tCompletionInfo[ sProgram ] = {
	 fnComplete = fnComplete
   }
end
Edited on 07 April 2016 - 08:44 PM
Sewbacca #3
Posted 07 April 2016 - 11:44 PM

function shell.setCompletionFunction( sProgram, fnComplete )
  tCompletionInfo[ sProgram ] = {
	 fnComplete = fnComplete
   }
end

Why my completion doesn't work?

shell.setCompletionFunction(customEditPath, shell.getCompletionInfo()['rom/programs/edit'])
Edited on 07 April 2016 - 09:45 PM
EveryOS #4
Posted 08 April 2016 - 12:33 AM
sewbacca said:
and how works the set completion function?
KingofGamesYami #5
Posted 08 April 2016 - 02:28 AM
When a variable is prefixed by fn, that means it's supposed to be a function. Furthermore, if a function name includes function in it, there's a pretty good chance that it wants a function.

TL;DR: Give it a function, not the completion info for 'rom/programs/edit'
Bomb Bloke #6
Posted 08 April 2016 - 03:53 AM
TL;DR: Give it a function, not the completion info for 'rom/programs/edit'

The completion info for 'rom/programs/edit' is, in fact, a function.

Relevant code:

shell.setCompletionFunction( sProgram, fnComplete )

shell.getCompletionInfo()

"rom/programs/edit" key in tCompletionInfo table gets set

So I guess the question is, "what's the value of customEditPath"? Is a path set to it?
CoderPuppy #7
Posted 08 April 2016 - 05:02 AM
The completion info for 'rom/programs/edit' is, in fact, a function.

No, the completion info is a table with an "fnComplete" key.

This should work (untested):

shell.setCompletionFunction(customEditPath, shell.getCompletionInfo()['rom/programs/edit'].fnComplete)
Bomb Bloke #8
Posted 08 April 2016 - 05:06 AM
*headdesk*

Yes, I'd say you've got it. :)/>
Sewbacca #9
Posted 08 April 2016 - 09:26 PM
The completion info for 'rom/programs/edit' is, in fact, a function.

No, the completion info is a table with an "fnComplete" key.

This should work (untested):

shell.setCompletionFunction(customEditPath, shell.getCompletionInfo()['rom/programs/edit'].fnComplete)

Doesn't work: table expected got function
Dragon53535 #10
Posted 08 April 2016 - 09:55 PM
That code should work, can you show us what your code looks like?