FANDOM


This page is under construction. The advanced topics goes deep into programming, and will be hard for me to organize. This warning will be removed upon completion of the page. Until then, use descretion on when to use the techniques below.


Advanced Mode

Since advanced gearswapping requires knowledge of the Lua programming language, I've decided to make this a separate page. If you're new to GearSwap, I would recommend you first visit the Basic/Intermediate  page. Here, we're going to learn how to program.


Below is an example of spell changing script. This will check user MP and compare it to spell cost. If spell cost is higher than user mp, then it'll choose the next lower tiered spell of the same name.

--------------------------------------------------------------------------
--------------------------------------------------------------------------

function pretarget(spell)
----makes it so script-based macros use <lastst>, rather than
----<stnpc>,<stpc>,etc. if this did not exist, then script-based
----macros will require user input to select the subtarget.
  if spell.target.raw:contains('<st') then
    target='<lastst>'
  end
--------------------------------------------------------------------------
end

--------------------------------------------------------------------------
--------------------------------------------------------------------------

function precast(spell)
----checks to see if target variable was defined
  if target==nil then
    target=spell.target.name
   end
--------------------------------------------------------------------------
----changes spells based on MP
  userhp=player.hp
  usermp=player.mp		----remapping built-in variables to custom ones.
  spellmp=spell.mp_cost
  spellname=spell.name
  if usermp < spellmp then
    cancel_spell()		----cancels last spell for scripted one below
    macro_convert()		----calls on the custom function "macro_convert"
    if spellname==nil then
      send_command('@input /echo MP is too low for this kind of spell')
    return
    end
    send_command('@input /ma "'..spellname..'" '..target)
  end
--------------------------------------------------------------------------
end

--------------------------------------------------------------------------
--------------------------------------------------------------------------

function macro_convert()
----custom function that chooses a lower tier spell of the same name.
  if spellname:endswith(' V') then
    spellname=(string.sub(spellname,-20,-3)..' IV')
  elseif spellname:endswith('IV') then
    spellname=(string.sub(spellname,-20,-4)..' III')
  elseif spellname:endswith('III') then
    spellname=(string.sub(spellname,-20,-5)..' II')
  elseif spellname:endswith('II') then
    spellname=string.sub(spellname,-20,-4)
   else spellname=nil
  end
  return spellname
--------------------------------------------------------------------------
end

--------------------------------------------------------------------------
--------------------------------------------------------------------------

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.