Thread Tools Display Modes
09-20-06, 04:06 AM   #1
jackpotmonkey
A Deviate Faerie Dragon
Join Date: Sep 2006
Posts: 10
Auto Resource Activation

I am attempting my first mod and have been searching around everywhere to find the components of scripting i need in order to have it do what i want. My intention is to make a mod that upon the player dieing and then either doing a corpse run or getting resurected the gathering tradeskill tracking of his choice loads after he is alive again (because i often forget to turn back on the tracking)
thus far though I have found really no mention of how to call the game to cast the tracking skills, Here is the coding i have so far:
Code:
--Slash Commands Defined
function AR_SLASH_SHOW()
    SlashCmdList["ARSHOW"] = AutoResourceShow;
    SLASH_ARSHOW1 = "/arshow";
end
function AutoResourceShow()
    local frame = getglobal("AutoResourceForm");
    if (frame:IsVisible()) then
        AR_Hide();
    else
        AR_Show();
    end
end
function AR_Hide()
    AutoResourceForm:Hide();
end
function AR_Show()
    AutoResourceForm:Show();
end
--Define TrackingStart Variable from GUI
function TrackingStart()
    local frame = getglobal("AutoResourceFormEnableTracking");
    if (ENABLE_TRACKING == "true") then
        TrackingType();
    end
end
--Define Tracking Types
function TrackingType()
    local frame = getglobal("AutoResourceFormTrackingType");
    if PLAYER_UNGHOST == "true" or PLAYER_ALIVE == "true" then
        if (TrackingType == "Herbs") then
            FIND_HERBS="true";
        elseif (TrackingType == "Ore") then
            FIND_MINERALS="true";
        else
            FIND_TREASURE="true";
        end
    end
end
function FIND_HERBS()
    if (FIND_HERBS == "true") then
        spell:GetLocalized("FIND_HERBS");
        UPDATE_TRADESKILL_RECAST();
    end
end
function FIND_MINERALS()
    if (FIND_MINERALS == "true") then
        spell:GetLocalized("FIND_MINERALS");
        UPDATE_TRADESKILL_RECAST();
    end
end
function FIND_TREASURE()
    if (FIND_TREASURE == "true") then
        spell:GetLocalized("FIND_TREASURE");
        UPDATE_TRADESKILL_RECAST();
    end
end
Note that i have a ComboBox with the name of:
Code:
$parentTrackingType
in the actual AutoResourcesFrame.xml with the "Herb, Ore, Treasure" listed unter the collection.
The window itself loads fine when the game is loaded, but does nothing, I can select to enable the mod, and selecte the tracking type but when I hit done and die and go about resurecting it doesn't turn on my selected skill.
Also Note that currently i have my "Close" button set as such:
Code:
<OnClick>this:RegisterEvent("TrackingStart");
And for the UI /LUA editing im using the WOW UI Designer (downloaded from this site).

I hope this makes sence im pretty tired and have been struggling with this all day, This project is a learning "Get my feet wet" project for a much bigger one I intend to do in the near future, I could really use a WoW spacific tutorial site beyond WoWWikki to get me going, hopefully the fix for the above mod is something one of you can help me with, and thankyou in advance for any advice, fixes, etc you can give :)

Last edited by jackpotmonkey : 09-20-06 at 04:55 AM.
  Reply With Quote
09-20-06, 08:25 AM   #2
Gello
A Molten Giant
AddOn Author - Click to view addons
Join Date: Jan 2005
Posts: 521
To activate a tracking ability you cast it. ie CastSpellByName("Find Minerals"). This means it requires a hardware event so you won't be able to turn it on in reaction to an event (PLAYER_ALIVE) or by time (OnUpdate).

It needs to be cast in reaction to an OnClick or a key binding or anything that's a response to one of those (UseAction).

What you can do is put up a transparent button that covers the whole screen, so that the next click will trigger your OnClick to cast a tracking. Like this:

Code:
<Button name="AutoTrackFrame" frameStrata="HIGH" hidden="true" enableMouse="true" parent="UIParent" setAllPoints="true">
  <Scripts>
    <OnLoad>
      this:RegisterEvent("PLAYER_ALIVE") -- spirit res or accepts res before release
      this:RegisterEvent("PLAYER_UNGHOST") -- res after being a ghost
      this:RegisterForClicks("LeftButtonDown","RightButtonDown")
    </OnLoad>
    <OnEvent>
      if not GetTrackingTexture() and not UnitIsDeadOrGhost("player") then
        this:Show() -- if nothing being tracked and player is not dead, show overlay button
      end
    </OnEvent>
    <OnClick>
      CastSpellByName("Find Minerals") -- bulk of mod would be to define which spell to cast "on res"
      this:Hide()
    </OnClick>
  </Scripts>
</Button>
Description of some of the tags:

<Button> -- button used instead of the usual <Frame> since we need OnClicks which don't work for frames and we can't RegisterForClicks to <Frames> on purpose.
frameStrata="HIGH" - this makes the frame appear over (most) everything else
setAllPoints="true" - this stretches the frame to completely cover the parent (UIParent)

this:RegisterForClicks("LeftButtonDown","RightButtonDown") - by default, buttons react to OnClick from left button only (when the mouse goes up, as if it's this:RegisterForClicks("LeftButtonUp")). This makes OnClick happen in reaction to the left or right mouse button going down.

The rest is probably self explanatory. The frame is usually hidden. When a PLAYER_ALIVE or PLAYER_UNGHOST happens, it checks if you're not dead and no tracking is up, and if so it shows the invisible button that covers the whole screen. Pressing down on left or right mouse button will cast a tracking skill.
  Reply With Quote
09-20-06, 10:15 AM   #3
jackpotmonkey
A Deviate Faerie Dragon
Join Date: Sep 2006
Posts: 10
Sweet that works thankyou, but how do I call the function defined in my LUA file to determine which type of tracking to use (based on the selection on the dropdown menu of the GUI) or do i have to script that into the XML aswell?
Like i said im pretty new at this heh.
Here is the code in my LUA
I called it by putting:
Code:
        <OnClick>
        if (event == "VARIABLES_LOADED") then
          TrackingStart();-- bulk of mod would be to define which spell to cast "on res"
        end
          this:Hide()
        </OnClick>
In place of CastSpellByName("Find Minerals")
The Combo box that AutoResourceFrameTrackingType refers to has 3 items in the collection: Herbs;Ore;Treasure; Of course i dont even know if that is how you are supposed to read from a combo box but obviously something isnt right because when i select my tracking type from the UI and checkmark enable (AutoResourceFrameEnableTracking is the checkbox defined in the XML) getting nothing again.

Code:
--Define TrackingStart Variable from GUI
function TrackingStart()
    local frame = getglobal("AutoResourceFrameEnableTracking");
    if (ENABLE_TRACKING == "true") then
        TrackingType();
    end
end
--Define Tracking Types
function TrackingType()
    local frame = getglobal("AutoResourceFrameTrackingType");
        if (AutoResourceFrameTrackingType == "Herbs") then
            CastSpellByName("Find Herbs");
        elseif (AutoResourceFrameTrackingType == "Ore") then
            CastSpellByName("Find Minerals");
        else
            CastSpellByName("Find Treasure");
        end
end

Last edited by jackpotmonkey : 09-20-06 at 10:31 AM.
  Reply With Quote
09-20-06, 01:17 PM   #4
Gello
A Molten Giant
AddOn Author - Click to view addons
Join Date: Jan 2005
Posts: 521
I can't help with the drop downs or combo box, sorry. I create my own custom frames.

However for this, in your shoes I'd have it note the current tracking when tracking changes, and then on res have it summon the last one. Something like:

Code:
<Button name="AutoTrackFrame" frameStrata="HIGH" hidden="true" enableMouse="true" parent="UIParent" setAllPoints="true">
  <Scripts>
    <OnLoad>
      this.Tracks = {
        ["Interface\\Icons\\Spell_Nature_Earthquake"] = "Find Minerals",
        ["Interface\\Icons\\INV_Misc_Flower_02"] = "Find Herbs",
        ["Interface\\Icons\\Racial_Dwarf_FindTreasure"] = "Find Treasure",
        ["Interface\\Icons\\Ability_Tracking"] = "Track Beasts",
        ["Interface\\Icons\\Spell_Holy_PrayerOfHealing"] = "Track Humanoids",
        ["Interface\\Icons\\Spell_Shadow_DarkSummoning"] = "Track Undead",
        ["Interface\\Icons\\Spell_Frost_SummonWaterElemental"] = "Track Elementals",
        ["Interface\\Icons\\Ability_Stealth"] = "Track Hidden",
        ["Interface\\Icons\\Spell_Shadow_SummonFelHunter"] = "Track Demons",
      }
      this.currentTracking = nil
      this:RegisterEvent("PLAYER_AURAS_CHANGED") -- fired when buffs, including tracking, changes
      this:RegisterEvent("PLAYER_ALIVE") -- spirit res or accepts res before release
      this:RegisterEvent("PLAYER_UNGHOST") -- res after being a ghost
      this:RegisterForClicks("LeftButtonDown","RightButtonDown")
    </OnLoad>
    <OnEvent>
      if event=="PLAYER_AURAS_CHANGED" then
        local track = GetTrackingTexture()
        if track and this.Tracks[track] then
          -- set this.currentTracking to the "Find X" currently being tracked
          this.currentTracking = this.Tracks[track]
        end
      elseif this.currentTracking and not GetTrackingTexture() and not UnitIsDeadOrGhost("player") then
        this:Show() -- if nothing being tracked and player is not dead, show overlay button
      end
    </OnEvent>
    <OnClick>
      if this.currentTracking then
        CastSpellByName(this.currentTracking) -- bulk of mod would be to define which spell to cast "on res"
      end
      this:Hide()
	</OnClick>
  </Scripts>
</Button>
When you change tracking, it looks up the icon and fetches the "spell name" of the tracking in this.currentTracking. When it goes to cast the tracking it casts the one it noted before.

No GUI to it and GUIs are fun to make, but as mentioned before I really have no experience with combo/dropdown boxes that would apply to anyone else.
  Reply With Quote
09-20-06, 02:49 PM   #5
Wikwocket
A Theradrim Guardian
AddOn Author - Click to view addons
Join Date: Jul 2005
Posts: 61
An alternative is a mod like this:
http://www.curse-gaming.com/en/wow/a...ckingmenu.html

Among other things, it will flash the tracking sphere after you rez, to remind you to activate a tracking type again.

It is very handy, and so effective that I often find myself clicking Find Herbs even when in a battleground!
  Reply With Quote
09-21-06, 12:15 PM   #6
jackpotmonkey
A Deviate Faerie Dragon
Join Date: Sep 2006
Posts: 10
That worked thanks!
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Auto Resource Activation


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off