gpt4 book ai didi

c# - 从Lua引擎获取所有Lua库和关键字

转载 作者:行者123 更新时间:2023-11-30 14:35:36 25 4
gpt4 key购买 nike

我正在为我的 Lua IDE 开发代码完成控件

https://github.com/AndersMalmgren/FreePIE

我正在使用反射来获取可从脚本访问的 C# 对象信息,但我也想在列表中包含 Lua 特定的内容,例如数学库等。

有什么方法可以得到这些吗?还想获取所有关键字,如 if、then、end 等

最佳答案

Are there any way of getting these?

手册包含所有内容,但您也可以在启动时遍历全局命名空间以获取所有内容(您必须尽早执行此操作,然后再向命名空间添加任何内容!)。如果某物是一个表,那么它也是一个命名空间,例如 stringtable,您可以遍历它以获取方法。

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

产生以下内容:

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

关于c# - 从Lua引擎获取所有Lua库和关键字,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11832683/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com