GG脚本便捷库-API 很抱歉,因为许多原因这个东西已经停止更新了,但是作为刚接触编程的第一个作品,觉的很有意义,即使现在看来有很多bug哈哈,就留做纪念吧! github地址
这是一个可以快速写一个GG脚本的库(如果你掌握了他)
暂无
--[[
不用每次加载网络
不同脚本 不同库版本 不同应用 都可以
相比之前的方法会好很多
]]
function loadFrame(version,forc)
local Code="";
local nowtime=os.time();
local cfgpath="/sdcard/.zlib.cfg";
local PACKAGE=(gg.getTargetInfo(gg.getTargetPackage()).packageName);
local libpath=gg.EXT_STORAGE.."/Android/data/"..PACKAGE.."/files/.zlibrary"..version..".lib";
local isfile= loadfile(libpath);
local iscfg= loadfile(cfgpath);
local lver=tostring(version):gsub("%.","_");
local lpak=PACKAGE:gsub("%.","_");
local lpaklver=lpak.."_"..lver;
local libraryWeb="http://gg.zzerx.cn/library.php";
local libraryBakWeb="https://zzer.tk/library.php";
local tableprint = function(data)
local tstr="";
if data == nil then
print("table data is nil");
end
for k, v in pairs(data) do
tstr=tstr.."[\"".. k.."\"]="..v.."; ";
end
return "lib_updatetime={"..tstr.."}";
end
if not version then version="new"; end
if not forc then forc=nowtime; end
function writeCfg()
if not lib_updatetime then lib_updatetime={}; end
lib_updatetime[lpaklver]=nowtime;
cfginfo=io.open(cfgpath,"w+");
cfginfo:write(tableprint(lib_updatetime));
end
function getlibraryfornet()
isfile= io.open(libpath,"w+");
Code=gg.makeRequest(libraryWeb,nil,'v='..version).content or gg.makeRequest(libraryBakWeb,nil,'v='..version).content;
writeCfg();
if( Code=='')then Code='gg.toast("Get error!! gg-lua库获取失败")'; end
isfile:write(Code); isfile:close();cfginfo:close();
return Code;
end
function dolibfile()
getlibraryfornet(); dofile(libpath);dofile(cfgpath);
end;
if not isfile or not iscfg then getlibraryfornet();dofile(libpath);dofile(cfgpath);
else dofile(libpath);dofile(cfgpath);
end
if not zsearch then
print("#1 :Load error"); dolibfile();
elseif not lib_updatetime or not lib_updatetime[lpaklver] then
print("#2 :No configuration "); dolibfile();
elseif nowtime-lib_updatetime[lpaklver]>forc*86400 then
print("#3 :Be overdue"); dolibfile();
end
end
-------------上面看不懂就不用看------
loadFrame("3.1",11); --这里才是加载库版本方法
--和检查更新间隔
--检查更新不会提升版本!
--参数1设置nil默认加载最新版
--参数2设置-1则每次都加载网络
--(无需每次加载网络)
--(不同脚本调用不同库的时候会失效/ps:比如你自己加载的是3.1 别人脚本用的是3.0 他会默认加载你的 ,所以可能会导致一些不可预知的错误)
function loadFrame(vision,forc)
function refile(path)
io.open(path,"w"):write([[function zdc() ]]..getLibrary(vision)..[[ function tocheckz() to_check_z=' ]]..os.time()..[[' return to_check_z end end; io.open(]]..string.format('%q',path)..[[,"w"):write(string.dump(zdc,false));io.close()]])
io.close();pcall(loadfile(path));pcall(loadfile(path));
end
function getLibrary(vision)
if not vision then vision="new" end
local Code=gg.makeRequest('http://gg.zzerx.cn/library.php',nil,'v='..vision).content or gg.makeRequest('http://gg.zzerx.cn/library.php?v='..vision).content
if( Code=='')then Code='gg.alert("load error!! gg-lua库加载失败")'; end
return Code;
end
if(not forc)then forc=os.time() end
local path="/sdcard/.zlibrary.cfg"; --如果GG读取你的手机路径不是/sdcard/xxx 且导致此代码失效的情况 就修改这个路径(或者如果服务器出现问题直接复制群文件库版本代码到这个文件里面,在最后添加代码 function tocheckz() to_check_z=os.time() return to_check_z end )
if(not loadfile(path) or io.open(path,"r"):read('*a')=='')then
refile(path)
else
pcall(loadfile(path));
if not zsearch or not tocheckz or os.time()-tocheckz()>forc*86400 then
refile(path)
end
end
end
loadFrame(nil,15) --loadFrame(版本号,检查间隔).
-- (需要每次加载网络)
--[[只要涉及makeRequest获取gg.zzerx.cn的
数据,都有可能因服务器问题而获取失败。
]]
pcall(load(gg.makeRequest('http://gg.zzerx.cn/library.php',nil,'v=3.0').content or gg.makeRequest('http://gg.zzerx.cn/library.php?v=new').content))
-- v=版本号
-- v=nwe 默认加载最新版库
Before reading the documents, you need to know what these things represent,Maybe not.
英文符号 ' | ' 在库中,一般是用来进行不同的项目操作分隔 英文符号 ' _ ' 在库中,一般是用来进行一个项目内的不同参数分隔
z 和 _z 在库中是关键字变量 脚本中如重定义了此变量,库会报错(为什么用这么让人不愉快的一个变量当关键字?当时脑抽)
数值类型>>
D='DWROD' = 4
E='DOUBLE' = 64
Q='QWORD' = 32
F='FLOAT' = 16
W='WORD' = 2
B='BYTE' = 1
A='AUTO' = 127
X='XOR' = 8
内存范围简写>> B='REGION_BAD'; A='REGION_ANONYMOUS'; As='REGION_ASHMEM'; Ca='REGION_C_ALLOC'; Cb='REGION_C_BSS'; Cd='REGION_C_DATA'; Ch='REGION_C_HEAP'; Xa='REGION_CODE_APP'; Xs='REGION_CODE_SYS'; J='REGION_JAVA'; Jh='REGION_JAVA_HEAP'; O='REGION_OTHER'; PS='REGION_PPSSPP'; S='REGION_STACK';
SIGN简写>> SIGN和RAN之间用';'隔开 同样不要有空格 SIGN:E='SIGN_EQUAL'; =536870912 SIGN:FE='SIGN_FUZZY_EQUAL'; =536870912 SIGN:FG='SIGN_FUZZY_GREATER'; =67108864 SIGN:FL='SIGN_FUZZY_LESS'; =134217728 SIGN:FNE='SIGN_FUZZY_NOT_EQUAL'; =268435456 SIGN:GOE='SIGN_GREATER_OR_EQUAL'; =67108864 SIGN:LOE='SIGN_LESS_OR_EQUAL'; =134217728 SIGN:NE='SIGN_NOT_EQUAL'; =268435456 ['搜索修改']='[SIGN:E]12345D;123F::500_F' RAN简写>> RAN:搜索内存地址开始~搜索内存地址结束 默认 0~-1 ['搜索修改']='[SIGN:E;RAN:0x000066ff~0xffffffff]12345D;123F::500_F'