I'm working on a Code completion control for my Lua IDE
https://github.com/AndersMalmgren/FreePIE
I'm using reflection to get the C# objects info accesable from scripts, but I also want to have Lua specific stuff in the list, like the math lib etc.
Are there any way of getting these? Would also like to get all keywords like if, then, end etc
Are there any way of getting these?
The manual contains everything, but you could also iterate through the global namespace on startup to get everything (you'll have to do this early, before you add anything to the namespace!). If something is a table, then it's also a namespace like string or table and you can iterate through that to get the methods.
local exclude = { _G = true, _VERSION = true, arg = true }
for name, value in pairs(_G) do
if not exclude[name] then
print(name)
if type(value) == 'table' then
for name, value in pairs(value) do
print('\t', name)
end
end
end
end
Produces the following:
string
sub
upper
len
gfind
rep
find
match
char
dump
gmatch
reverse
byte
format
gsub
lower
xpcall
package
preload
loadlib
loaded
loaders
cpath
config
path
seeall
tostring
print
os
exit
setlocale
date
getenv
difftime
remove
time
clock
tmpname
rename
execute
unpack
require
getfenv
setmetatable
next
assert
tonumber
io
lines
write
close
flush
open
output
type
read
stderr
stdin
input
stdout
popen
tmpfile
rawequal
collectgarbage
getmetatable
module
rawset
math
log
max
acos
huge
ldexp
pi
cos
tanh
pow
deg
tan
cosh
sinh
random
randomseed
frexp
ceil
floor
rad
abs
sqrt
modf
asin
min
mod
fmod
log10
atan2
exp
sin
atan
debug
getupvalue
debug
sethook
getmetatable
gethook
setmetatable
setlocal
traceback
setfenv
getinfo
setupvalue
getlocal
getregistry
getfenv
pcall
table
setn
insert
getn
foreachi
maxn
foreach
concat
sort
remove
newproxy
type
coroutine
resume
yield
status
wrap
create
running
select
gcinfo
pairs
rawget
loadstring
ipairs
dofile
setfenv
load
error
loadfile
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With