View Single Post
11-14-16, 10:44 AM   #1
Darken5
A Murloc Raider
Join Date: Nov 2016
Posts: 7
help needed: trying to compact some code (and its not working)

Gotten back to workin on an old addon of mine. FinalFantasylization. Plays music based on where you are and what youre doing. (Still only works in WotLK atm, will worry about that later). Been trying to compact the zone detection section.

Here's the github for all the current code: (this bit works fine in WotLK)
https://github.com/Darken5/FinalFant...Route-to-3.3.0

Heres the code im workin on compacting: (this works)
http://pastebin.com/XCZb6ehw
Snippet:
Lua Code:
  1. --'==========================================================================================      
  2. --'  Starting Areas: Sunstrider Isle, Eversong Woods ( Blood Elf Starting Area )
  3. --'==========================================================================================
  4.                
  5.         if not ( IsResting() ) and (  factionEnglish == F["Horde"] ) and (  ZoneName == Z["Eversong Woods"] ) and ( ( SubZoneName == SZ["The Sunspire"] ) or ( SubZoneName == SZ["Sunstrider Isle"] ) or ( SubZoneName == SZ["Falthrien Academy"] ) or ( SubZoneName == SZ["Shrine of Dath'Remar"] ) ) and FinalFantasylization_IsPlaying == false then
  6.             if FinalFantasylization_InStarterAreaSunstriderIsle == false then
  7.                 FinalFantasylization_debugMsg(FFZlib.Color.Aqua .. PlayerIn.. SubZoneName..", "..ZoneName)
  8.                 FinalFantasylization_StarterAreaSunstriderIsle()
  9.             end
  10.             FinalFantasylization_IsPlaying = true
  11.             FinalFantasylization_InStarterAreaSunstriderIsle = true
  12.         elseif (  factionEnglish == F["Alliance"] ) and (  ZoneName == Z["Eversong Woods"] ) and ( ( SubZoneName == SZ["The Sunspire"] ) or ( SubZoneName == SZ["Sunstrider Isle"] ) or ( SubZoneName == SZ["Falthrien Academy"] ) or ( SubZoneName == SZ["Shrine of Dath'Remar"] ) ) and FinalFantasylization_IsPlaying == false then
  13.             if FinalFantasylization_InStarterAreaSunstriderIsle == false then
  14.                 FinalFantasylization_debugMsg(FFZlib.Color.Crimson .. PlayerInHostileTown .. SubZoneName..", "..ZoneName.. PlayerInHostile)
  15.                 FinalFantasylization_HostileTowns()  -- Music call for all towns you are hostile in.
  16.             end
  17.             FinalFantasylization_IsPlaying = true
  18.             FinalFantasylization_InStarterAreaSunstriderIsle = true
  19.         else
  20.             FinalFantasylization_InStarterAreaSunstriderIsle = false
  21.         end

Heres the compacted code: (this doesn't work)
http://pastebin.com/XpbSgvZL
Snippet:
Lua Code:
  1. --'==========================================================================================      
  2. --' Starting Areas: Sunstrider Isle, Eversong Woods ( Blood Elf Starting Area )
  3. --'==========================================================================================
  4.         if not ( IsResting() ) and ( ZoneName == Z["Eversong Woods"] ) and ( ( MinimapZoneName == SZ["The Sunspire"] ) or ( SubZoneName == SZ["Sunstrider Isle"] ) or ( SubZoneName == SZ["Falthrien Academy"] ) or ( SubZoneName == SZ["Shrine of Dath'Remar"] ) ) and FinalFantasylization_IsPlaying == false then
  5.             if FinalFantasylization_InStarterAreaSunstriderIsle == false then
  6.                 if ( factionEnglish == F["Horde"] ) then
  7.                     FinalFantasylization_debugMsg(FFZlib.Color.Aqua .. PlayerIn.. SubZoneName..", "..ZoneName)
  8.                     FinalFantasylization_StarterAreaSunstriderIsle()
  9.                 else
  10.                     FinalFantasylization_debugMsg(FFZlib.Color.Crimson .. PlayerInHostileTown .. SubZoneName..", "..ZoneName.. PlayerInHostile)
  11.                     FinalFantasylization_HostileTowns() -- Music call for all towns you are hostile in.
  12.                 end
  13.                 FinalFantasylization_IsPlaying = true
  14.                 FinalFantasylization_InStarterAreaSunstriderIsle = true
  15.             end
  16.             FinalFantasylization_InStarterAreaSunstriderIsle = false
  17.         end

problem i'm having is the compacted code keeps changing the song played. Example, using the above snippet, it'll play "Sunstrider Isle" then about 2 seconds later plays "Eversong Woods" (which is further down the list), and then back again. If not in a subzone detected by FFz, it'll just repeat the music set for the zone.

i've also tried: (my 1st attempt)
Lua Code:
  1. --'==========================================================================================      
  2. --'  Starting Areas: Sunstrider Isle, Eversong Woods ( Blood Elf Starting Area )
  3. --'==========================================================================================
  4.                
  5.         if not ( IsResting() ) and (  ZoneName == Z["Eversong Woods"] ) and ( ( SubZoneName == SZ["The Sunspire"] ) or ( SubZoneName == SZ["Sunstrider Isle"] ) or ( SubZoneName == SZ["Falthrien Academy"] ) or ( SubZoneName == SZ["Shrine of Dath'Remar"] ) ) and FinalFantasylization_IsPlaying == false then
  6.             if FinalFantasylization_InStarterAreaSunstriderIsle == false then
  7.                 if (  factionEnglish == F["Horde"] ) then
  8.                     FinalFantasylization_debugMsg(FFZlib.Color.Aqua .. PlayerIn.. SubZoneName..", "..ZoneName)
  9.                     FinalFantasylization_StarterAreaSunstriderIsle()
  10.                 else
  11.                     FinalFantasylization_debugMsg(FFZlib.Color.Crimson .. PlayerInHostileTown .. SubZoneName..", "..ZoneName.. PlayerInHostile)
  12.                     FinalFantasylization_HostileTowns() -- Music call for all towns you are hostile in.
  13.                 end
  14.                 FinalFantasylization_IsPlaying = true
  15.                 FinalFantasylization_InStarterAreaSunstriderIsle = true
  16.             else
  17.                 FinalFantasylization_InStarterAreaSunstriderIsle = false
  18.             end
  19.         end


Any help in understanding why the compacted code doesn't work would be VERY much appreciated.

Last edited by Darken5 : 11-14-16 at 11:03 AM. Reason: more input, highlight lua
  Reply With Quote