首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >Lua码楼堡垒之夜问题与重复功能

Lua码楼堡垒之夜问题与重复功能
EN

Stack Overflow用户
提问于 2021-10-27 09:42:56
回答 2查看 248关注 0票数 0

嗨,当我被要求的时候,我问了一个问题,我有我的整个代码。

这段代码是通过在我的MB4光速上按下MB5和G502来构建墙壁和地板的:

代码语言:javascript
运行
复制
----------------
-- Boutton 4 sol ou sol et toit - MB4 floor or floor and roof
----------------

                if (event == "MOUSE_BUTTON_PRESSED" and arg == 4) then
                  PlayMacro("PlusReso")

                  if not IsMouseButtonPressed(3) then
                    FastSleep(1)
                    PressAndReleaseKey("F2")-- Sol - Floor
                       FastSleep(1)
                    PressKey("F6")-- Construire - Place Building
                       FastSleep(1)

                  end

                  if IsMouseButtonPressed(3) then
                    PressAndReleaseKey(7)
                    FastSleep(1)
                    -- Petite Boucle - Little Loop
                    for i=1, 20 do
                    for j=1, 5 do
                    PressAndReleaseKey("F4")-- Toit - Roof
                       FastSleep(1)
                    PressKey("F6")-- Construire - Place Building
                       FastSleep(1)
                    end
                    for j=1, 5 do
                    PressAndReleaseKey("F2")-- Sol - Floor
                       FastSleep(1)
                    PressKey("F6")-- Construire - Place Building
                       FastSleep(1)
                    end
                    end

                  end

                  elseif (event == "MOUSE_BUTTON_RELEASED" and arg == 4) then
                    if not IsMouseButtonPressed(5) then
                    ReleaseKey("F6")
                    PressAndReleaseKey(7) -- Alterner les raccourcis - Switch Quickbar
                    PlayMacro("MoinsReso")
                    end

                end

----------------
-- Boutton 5 mur ou sol et mur - MB5 wall or wall and floor
----------------

                if (event == "MOUSE_BUTTON_PRESSED" and arg == 5) then
                    PlayMacro("PlusReso")

                    if IsMouseButtonPressed(4) then
                    repeat
                    FastSleep(1)
                    PressAndReleaseKey("F2")-- Sol - Floor
                    FastSleep(1)
                    PressKey("F6")-- Construire - Place Building
                    FastSleep(1)

                    FastSleep(1)
                    PressAndReleaseKey("F1")-- Mode construction Mur
                    FastSleep(1)
                    PressKey("F6")-- Construire - Place Building
                    FastSleep(1)
                    until not IsMouseButtonPressed(4)
                    ReleaseKey("F6")
                    PressAndReleaseKey(7) -- Alterner les raccourcis - Switch Quickbar
                    end

                    if not IsMouseButtonPressed(4) then
                    repeat
                    FastSleep(1)
                    PressAndReleaseKey("F1")-- Mode construction Mur
                    FastSleep(1)
                    PressKey("F6")-- Construire - Place Building
                    FastSleep(1)
                    until not IsMouseButtonPressed(5)
                    if not IsMouseButtonPressed(4) then
                    ReleaseKey("F6")-- Construire - Place Building
                    PressAndReleaseKey(7) -- Alterner les raccourcis - Switch Quickbar
                    PlayMacro("MoinsReso")
                    end
                    end
                end

我的第一段代码更简单,在MB4和MB5上有一个重复循环,但是当按下这两个循环时,它们就不能一起工作了。

就像这样:

如果MB4按下重复楼板,直到不按MB4

如果MB按下重复楼板,直到未按MB5

在此之前,我只是使用MB4和MB5上的宏来构建。这很好,但当我移动我的鼠标非常快的时候,一些墙壁或地板没有建造。Lua允许我有一个非常快速的建筑经验。

那么,我怎么能让两个循环一起重复呢?我遗漏了什么?

第二个问题是宏观增减dpi (PlusReso和MoinsReso)。它很好,但有时我仍然停留在高dpi后,释放了我的所有鼠标臀部,使它无法瞄准。

我们是否可以编写一个简单的代码来增加和减少dpi,而不使用宏,并且在释放一个或几个按钮后,确保不会仍然停留在高dpi中?

谢谢

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2021-10-27 10:35:41

,那么我怎么能让两个循环一起重复呢?

代码语言:javascript
运行
复制
if event == "MOUSE_BUTTON_PRESSED" and (arg == 4 or arg == 5) then
   Sleep(10)
   local MB4 = IsMouseButtonPressed(4)
   local MB5 = IsMouseButtonPressed(5)
   if MB4 or MB5 then
      PlayMacro("PlusReso")
      repeat
         local RMB = IsMouseButtonPressed(3)

         if MB4 then
            PressAndReleaseKey("F2")-- Sol - Floor
            FastSleep(1)
            PressKey("F6")-- Construire - Place Building
            FastSleep(1)
         end

         if MB5 then
            PressAndReleaseKey("F1")-- Mode construction Mur
            FastSleep(1)
            PressKey("F6")-- Construire - Place Building
            FastSleep(1)
         end

         if RMB then
            PressAndReleaseKey("F4")-- Toit - Roof
            FastSleep(1)
            PressKey("F6")-- Construire - Place Building
            FastSleep(1)
         end

         MB4 = IsMouseButtonPressed(4)
         MB5 = IsMouseButtonPressed(5)
      until not (MB4 or MB5)
      ReleaseKey("F6")
      PressAndReleaseKey(7) -- Alterner les raccourcis - Switch Quickbar
      PlayMacro("MoinsReso")
   end
end
票数 1
EN

Stack Overflow用户

发布于 2021-11-03 08:26:02

这是最后的代码。我使用"rctrl“,它的工作几乎完美,快速,没有任何问题的建设。当人民币被按下时,我在MB4和MB6上添加了几个动作,给了我两个动作,每个鼠标按钮都按下人民币。我不得不用人民币向MB5添加相同的操作,否则我就有了一个问题,比如停止循环或新闻部问题!如果需要的话,我可以采取其他行动。

唯一的问题是,在使用代码的reste进行编辑时,有时我仍然停留在较高的DPI (通常是在游戏中,而不是在creatif中),但这是另一个问题。

谢谢你们这些石头;)

代码语言:javascript
运行
复制
   if event == "MOUSE_BUTTON_PRESSED" and (arg == 4 or arg == 5 or arg == 6) then
   
        FastSleep(10)
        local MB4 = IsMouseButtonPressed(4)
        local MB5 = IsMouseButtonPressed(5)
        local MB6 = IsModifierPressed("rctrl")
   
       if MB4 or MB5 or MB6 then
          PlayMacro("PlusReso")
        repeat
            local RMB = IsMouseButtonPressed(3)

            if MB4 then
                PressAndReleaseKey("F2")-- Sol - Floor
                FastSleep(1)
                PressKey("F6")-- Construire - Place Building
                FastSleep(1)
            end

            if MB5 then
                if not RMB then
                PressAndReleaseKey("F1")-- Mur - Wall
                FastSleep(1)
                PressKey("F6")-- Construire - Place Building
                FastSleep(1)
                end
            end
         
            if MB6 then
                PressAndReleaseKey("F3")-- Escalier - Stair
                FastSleep(1)
                PressKey("F6")-- Construire - Place Building
                FastSleep(1)
            end

            if RMB and MB4 then
                PressAndReleaseKey("F4")-- Toit - Roof
                FastSleep(1)
                PressKey("F6")-- Construire - Place Building
                FastSleep(1)
            end
            
            if RMB and MB5 then
                PressAndReleaseKey("F1")-- Mur - Wall
                FastSleep(1)
                PressKey("F6")-- Construire - Place Building
                FastSleep(1)
            end
            
            if RMB and MB6 then
                PressAndReleaseKey("F3")-- Escalier - Stair
                FastSleep(1)
                PressKey("F6")-- Construire - Place Building
                FastSleep(1)
                
                PressAndReleaseKey("F4")-- Toit - Roof
                FastSleep(1)
                PressKey("F6")-- Construire - Place Building
                FastSleep(1)
                
                PressAndReleaseKey("F2")-- Sol - Floor
                FastSleep(1)
                PressKey("F6")-- Construire - Place Building
                FastSleep(1)
                
            end
            
                MB4 = IsMouseButtonPressed(4)
                MB5 = IsMouseButtonPressed(5)
                MB6 = IsModifierPressed("rctrl")
                
          until not (MB4 or MB5 or MB6)
            ReleaseKey("F6")
            PressAndReleaseKey(7) -- Alterner les raccourcis - Switch Quickbar
            PlayMacro("MoinsReso")
       end
    end
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/69736284

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档