Jump to content


Photo

scripting fun?


    2 replies to this topic

    #1 cytime1000

    cytime1000

      Member

    • Members
    • PipPip
    • 13 posts

      Posted 30 November 2013 - 04:07 PM

      Can scripting still be done like below if so how or must create a addon attempted to get working and failed:

       

      In case anyone wants to mess around with the scripting capabilities of 4.0, please use this thread to report fun things/problems you come across.
      
      If you want to give it a shot, use the following console command:
      
      runscript RunScriptFile(GetAddonDirectory()..'/FILENAME.lua')
      
      (replacing FILENAME with the name of your script file placed in your Windower\Addon folder)
      
      Also, an updated version of Azaril's "Smart Cure" function in examples.lua (that actually works tongue.gif )
      
      --
      -- Example function to cast the best cure for the situation.
      --
      function SmartCure()
      
              -- Get the local player.
              local Player = GetPlayer();
             
              -- List of cure spells.
              local Cures = { { Name = "Cure V", RequiredMP = 135 },
                                              { Name = "Cure IV", RequiredMP = 88 },
                                              { Name = "Cure III", RequiredMP = 46 },                                
                                              { Name = "Cure II", RequiredMP = 24 },
                                              { Name = "Cure", RequiredMP = 8 } };
                                             
              if(Player ~= nil) then
             
                      -- Get the players current MP.
                      local CurrentMP = Player:GetMagicPoints();
                     
                      -- Check each cure to see if it can be used.
                      for i = 1, #Cures do
                     
                              -- Check that the player has enough MP.
                              if(CurrentMP >= Cures[i].RequiredMP) then
                     
                                      -- TODO: Check if the target is the local player or alliance member
                                      --               and use a lower cure if the cure will overheal.
                                     
                                      -- Cast the spell.
                                      local command = "/ma \"" .. Cures[i].Name .. "\" <t>";
                                      Log(command);
                                      SendInput(command);
                                     
                                      return;
                             
                              end
                     
                      end
                     
                      Log("Not enough MP to cast cure!");
                     
              end
      
      end
      
      -- 
      -- Register the SmartCure function to the "cure" console command.
      --
      Alias("cure", SmartCure);
      

       



      #2 Arcon

      Arcon

        Advanced Member

      • Windower Staff
      • 1189 posts
      • LocationMunich, Germany

      Posted 30 November 2013 - 05:00 PM

      That is from a different Windower (looks like Azaril's "recent" project, although I'm not familiar with it). It will work, but the function needs to be adjusted:

      _addon.name = 'SomeAddon'
      _addon.author = 'You'
      _addon.version = '0.0.0.1'
      
      function cure()
          -- Get the local player.
          local player = windower.ffxi.get_player();
      
          -- List of cure spells.
          local cures = { { name = "Cure V", required_mp = 135 },
                          { name = "Cure IV", required_mp = 88 },
                          { name = "Cure III", required_mp = 46 },                                
                          { name = "Cure II", required_mp = 24 },
                          { name = "Cure", required_mp = 8 } };
      
          if player then
              -- Get the players current MP.
              -- Check each cure to see if it can be used.
              for name, required_mp in ipairs(cures) do
                  -- Check that the player has enough MP.
                  if player.mp >= required_mp then
                      -- TODO: Check if the target is the local player or alliance member
                      --       and use a lower cure if the cure will overheal.
      
                      -- Cast the spell.
                      windower.send_command('input /ma "'..name..'" <t>');
      
                      return;
                  end
              end
      
              windower.add_to_chat(207, "Not enough MP to cast cure!");
          end
      end
      
      windower.send_command('alias cure lua i SomeAddon cure');

       

      This needs to be put in a file Windower/addons/SomeAddon/SomeAddon.lua. To load it then just enter //lua load SomeAddon, as you'd load any other addon.



      #3 cytime1000

      cytime1000

        Member

      • Members
      • PipPip
      • 13 posts

        Posted 30 November 2013 - 05:26 PM

        Thanks






        1 user(s) are reading this topic

        0 members, 1 guests, 0 anonymous users