gg修改器怎么编写lua脚本

gg修改器怎么编写lua脚本,gg修改器编写Lua脚本的例子

  1. 从搜索冻结值的数10.搜索前7次的结果被冻结为8的值。
gg.searchNumber(10, gg.TYPE_DWORD)

local t = gg.getResults(7)

for i, v in ipairs(t) do

t[i].value = 8

t[i].freeze = true

end

gg.addListItems(t)
2. 脚本重新启动之间保存输入

```handlebars
local configFile = gg.getFile()...cfg

local data = loadfile(configFile)

if data ~= nil then data = data() end

local input = gg.prompt({Please input something}, data)

if input == nil then os.exit() end

gg.saveVariable(input, configFile)
  1. 通过点击执行动作GG图标
function doAction()

local ret = gg.alert(Here some action, OK, Cancel, Exit)

if ret == 3 then os.exit() end -- exit from the script

end


gg.setVisible(false)

while true do

if gg.isVisible() then

gg.setVisible(false)

doAction()

end

gg.sleep(100)

end
  1. 执行多个动作与multiChoice
local t = gg.multiChoice({
          
   A, B, C, D})

if t == nil then

   gg.alert(Canceled)

else

   if t[1] then

       gg.alert(do A)

   end

   if t[2] then

       gg.alert(do B)

   end

   if t[3] then

       gg.alert(do C)

   end

   if t[4] then

       gg.alert(do D)

   end

end

local t = gg.prompt({
          
   A, B, C, D}, nil, {
          
   checkbox, checkbox, checkbox, checkbox})

if t == nil then

   gg.alert(Canceled)

else

   if t[1] then

       gg.alert(do A)

   end

   if t[2] then

       gg.alert(do B)

   end

   if t[3] then

       gg.alert(do C)

   end

   if t[4] then

       gg.alert(do D)

   end

end

本源码来自http://www.miaozan.art/show.asp?id=1451
经验分享 程序员 微信小程序 职场和发展