04/15/14, 01:42 AM | #1 |
Question in regards to string.lower
Code:
function Harvest.IsValidBottle(name) for k, v in pairs(Harvest.bottle) do d("v name :" .. v) d("name :" .. name) if v == name then return true end end return false end The entire function:
Warning: Spoiler
Code:
function Harvest.OnLootReceived( eventCode, receivedBy, objectName, stackCount, soundCategory, lootType, lootedBySelf ) if not Harvest.PlayetInteracting or not lootedBySelf then if Harvest.settings.debug then if not Harvest.PlayetInteracting then d("Not Harvesting") end if not lootedBySelf then d("Not Looted by self") end end return end local zone, x, y = Harvest.GetLocation() local itemId _, _, _, itemId = ZO_LinkHandler_ParseLink( objectName ) --name, color, type, id, +19 other attributes itemId = tonumber( itemId ) if Harvest.settings.debug then d("OnLootReceived ItemNumber:" .. itemId) d("OnLootReceived ItemName" .. objectName) end local profession = Harvest.GetProfessionType(itemId, objectName) if (profession < 1) then if Harvest.settings.debug then d("Valid profession information Not found!") end return end Harvest.saveData( zone, x, y, profession, objectName, itemID ) Harvest.RefreshPins( profession ) end Code:
_, _, _, itemId = ZO_LinkHandler_ParseLink( objectName ) --name, color, type, id, +19 other attributes Code:
function Harvest.IsValidBottle(name) for k, v in pairs(Harvest.bottle) do d("v name :" .. v) d("name :" .. string.lower(name)) if v == string.lower(name) then return true end end return false end Code:
:hFFFFFF:item:1187:1:13:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:hclear waterh |
|
04/15/14, 06:33 AM | #2 | |
Warning: Spoiler
lua Code:
Last edited by Garkin : 04/15/14 at 06:42 AM. Reason: Added info. |
||
04/15/14, 09:03 AM | #3 |
I received a nice PM from ins as well. Thanks ins. He suggested the same thing that that it may have changed since beta. I have a question though. The above code snipit suggests using text, color, zo_strsplit(':', data) The original routine has "_, _, _, itemId = ZO_LinkHandler_ParseLink( objectName )"
To me, not understanding lua all that much, means that ZO_LinkHandler_ParseLink (onjectname) is assigining 4 variables. The first three are "_, _, _," and the fourth is itemID. I have seen some routines that say things like, 'for _, node in pairs( nodes ) do'. What does '_' that mean? Nil? |
|
04/15/14, 09:31 AM | #4 |
http://mirven.github.io/underscore.lua/
Kinda mentions it. I'd be interested to know why it should be used though. It *seems* like it's a local throwaway variable? Kinda like each function automatically has "local _" declared at the start? |
|
04/15/14, 10:31 AM | #5 |
"_" is dummy variable - http://www.lua.org/pil/5.2.html
|
|
04/15/14, 01:55 PM | #6 | |
|
And no, there is no workaround, because even if you manage to not convert the Hs, in the end your strlower will wreck havoc upon the item name once you have UTF-8 characters in it. Last edited by Iyanga : 04/15/14 at 02:00 PM. |
|
04/15/14, 04:14 PM | #7 |
_ is just as valid a variable name as x, or myVar, or THIS_AWESOME_VARIABLE_NAME.
It is used conventionally as a throwaway variable by many authors, assigning it to values we don't care about. Since we don't care about them, it doesn't matter if they get overwritten. It is good practice to declare this _ variable as local. |
|
04/15/14, 05:14 PM | #8 | |
I made "ZO_LinkHandler_ParseLink( objectName )" assign all 22 variables and it's still assigning the same information. 1: The item name 2: The color. Which is 3 bytes in Hex like ffffff or 2DC50E 3: The type: so far a string 'item' for what I have tested with. 4: The ItemId 5: Unknown, but it's 13 for most of what I have seen. Then +18 other attributes which are usually 0. Request, I need a routine to break #5 into flags. Can anyone help me with that? Such that it displays: {0x0001} 'Unknown1' {0x0002} 'Unknown2' {0x0004} 'Unknown3' {0x0008} 'Unknown4' {0x0010} 'Unknown5' {0x0020} 'Unknown6' {0x0040} 'Unknown7' {0x0080} 'Unknown8' I don't need the number in brackets, that's for clarification. Last edited by Sharlikran : 04/15/14 at 05:22 PM. |
||
04/15/14, 05:50 PM | #9 |
During my testing of my gatherer addon I have noticed a pattern to the case differences.
Nodes ( Iron Ore, Jute, Maple ) etc. Are harvestable fixed objects in the game. Items ( iron ore, raw jute, maple) are the items you receive by harvesting from them. So far, it has consistently been, objects = mix case, items = lower case. This means that they can be stored in the same table, with apparently the same key values and me treated differently. EG. Harvests[zone][node] = Nodes that were harvested. ( Harvests["Auridon"]["Iron Ore"] ) Harvests[zone][item] = Items harvested from nodes. ( Harvests["Auridon"]["iron ore"] ) That bit of information aside ... If the item link is anything remotely like the ones in wow you will probably find that they will be markers such as quality, type, filterType, enchants, traits etc. To figure them out look at multiple items with identical stats, and then ones with 1 or 2 different but the same in themselves. Ultimately you will see a bigger picture there. |
|
04/15/14, 06:25 PM | #10 |
Thanks for sharing that. I mean this wholeheartedly, in that proper variable naming is important. I think I see a lot of things with variables like 'item', rather then 'NodeName', 'NodeNumber', 'ItemName', 'ItemNumber' and so on. I'll have to review that and the API Functions to make sure I'm really evaluating things correctly.
I'll have to look at the API functions a little closer, because I want the None Numbers and the Node Names, not Item Numbers and Item Names. Last edited by Sharlikran : 04/15/14 at 06:30 PM. |
|
04/15/14, 08:19 PM | #11 |
There are no node numbers. The node information you get from the interaction functions. But interactions are only tracked via an Update routine. There are no events currently at least that track interactions. A sample of my update routine that checks for interaction follows. But please note that I have noticed some flaws in the interaction results resulting in several checks before processing the information as valid.
Lua Code:
For say a mine (Iron Ore) the action would be "Mine" and the name would be "Iron Ore". For a tree limb ( Maple ) the action would be "Cut" and the name would be "Maple". For most others it is "Collect" or "Gather". Occasionally however, I have had the "Use" of a crafting station show up as INTERACTION_HARVEST instead of a more appropriate interaction. |
|
04/16/14, 09:36 AM | #12 |
Warning: Spoiler
Code:
-- Returns true if the player is Harvesting function Harvest.IsPlayerHarvesting() local InteractionType = GetInteractionType() if (InteractionType == INTERACTION_HARVEST) then return true end return false end -- Returns true if the player is Fishing function Harvest.IsPlayerFishing() local InteractionType = GetInteractionType() if (InteractionType == INTERACTION_FISH) then return true end return false end -- Returns true if the player is Reading a Book function Harvest.IsPlayerReading() local InteractionType = GetInteractionType() if (InteractionType == INTERACTION_BOOK) then return true end return false end -- Returns true if the player is Lockpicking function Harvest.IsPlayerLockpicking() local InteractionType = GetInteractionType() if (InteractionType == INTERACTION_LOCKPICK) then return true end return false end -- Returns True when Unknown. -- This will not return true when using a blacksmith -- Provisioning or clothing workstation function Harvest.HarvestProvisioning() local InteractionType = GetCraftingInteractionType() if InteractionType == CRAFTING_TYPE_PROVISIONING then return true end return false end -- returns false when InteractionType is Invalid or Provisioning -- True when it is a ALCHEMY, BLACKSMITHING, CLOTHIER -- ENCHANTING, or WOODWORKING function Harvest.ValidCraftingType() local InteractionType = GetCraftingInteractionType() if (InteractionType == (CRAFTING_TYPE_INVALID or CRAFTING_TYPE_PROVISIONING) ) then return false end return true end -- Returns True when Player is interacting with an Object -- and doing any one of the following -- Lockpicking -- Harvesting -- Reading -- Fishing function Harvest.IsPlayerBusy() if ( IsPlayerInteractingWithObject() and ( Harvest.IsPlayerLockpicking() or Harvest.IsPlayerReading() or Harvest.IsPlayerFishing() or Harvest.IsPlayerHarvesting() ) ) then return true end return false end I have a rather complex way of figuring out what the player is doing. The only routine I have not figured out is, "function Harvest.HarvestProvisioning()" I made that to track when a player is using the provisioning station. However, it doesn't fire at that time, nor does it fire when looting a Barrel. I don't use function Harvest.ValidCraftingType() yet because I'm not sure what the constants apply to. I have other complex ways to check if the type of the item is invalid based on the Node Name. However it's not refined yet and still needs a lot of work. The basic idea is that I use the ID Numbers from Esohead and some Node Names. Shinni mentioned that using names may not be a good idea since they may change, however, these are basic names like Barrel, Crate, so they shouldn't change. Also I am looking into using GetLootTargetInfo() InteractTargetType and GetLootItemLink. Last edited by Sharlikran : 04/16/14 at 02:29 PM. |
|
04/16/14, 11:22 PM | #13 | ||
|
Some extra info on the Linkhandler Parselink on items.
Example: Code:
[[|H3A92FF:item:45147:04:16:26582:4:16:0:0:0:0:0:0:0:0:0:9:0:0:0:0|hhide boots of magicka^p|h]], [[|H3A92FF:item:45147:04:12:26580:4:12:0:0:0:0:0:0:0:0:0:4:0:0:0:0|hrawhide boots of health^p|h]], 2. Colour 3. "item" type(?) 4. ItemID 5. unknown (Could be related to item Quality-ish, See 3 on Green items, 4-11 on Blue, 49 on Named, 50 on Unique) 6. LEVEL Requirement (Verified) 7. Related to enchant (Type) (Verified) 8. Related to Enchant (Strength) (Verified) 9. Related to Enchant (Strenght) (Verified) 10 11 12 13 14 15 16 17 18 19. Style (Verified) (34= Imperial) 20 21. Bound or not (1 if bound) (Verified) 22 CHARGES on Weapon (Verified) 23 For 7 and 8. Note; Items with "#5 "Qualityish" at 50=> Named item will not show anything in 7-8. Also you can not enchant these items.)
26847 - Disease Resist 26578 - REduce Targets Armor by xx for xx seconds 26579 - Adds XX Max Stamina 26580 - Adds Health 26581 - Adds Health Recovery 26582 - Adds Magicka 26583 - Adds Magicka REcovery 26586 - Adds Poison Resistance 26587 - Deals Poison Damage 26588 - Adds Stamina 26589 - Adds Stamina Recovery 26590 - Vampire Slaying (Deals x fire damage to vampires) 26591 - Reduce targets Power by xx for xx seconds 5365 - Adds Frost Damage 26844 - Adds Shock Damage 26848 - Adds Flame Damage For 19 and 21 see example below:
Weapon damage SCALES depending on the "LEVEL" Requirement (#6) Last edited by ins : 04/17/14 at 12:30 AM. |
||
04/17/14, 03:04 AM | #14 |
I did some more testing using the lootindex that is passed to GetLootItemLink() for ZO_LinkHandler_ParseLink. I had the most reliable results, consistently, without UI Exceptions, when I used the following two functions.
Code:
local _, _, itemType, itemId = ZO_LinkHandler_ParseLink( GetLootItemLink(lootindex) ) local TargetNodeName, TargetInteractionType, TargetActionName = GetLootTargetInfo() Granted I am curious about writing a separate lua file to add to HarvestMap that parses the Item link, to use ins' new found information. Aside from that, I think I can finally determine what is happening with the player, and how I am going to handle it. |
|
04/17/14, 05:47 AM | #15 | |
ITEM_LINK_TYPE = "item" ACHIEVEMENT_LINK_TYPE = "achievement" CHARACTER_LINK_TYPE = "character" CHANNEL_LINK_TYPE = "channel" BOOK_LINK_TYPE = "book" DISPLAY_NAME_LINK_TYPE = "display" URL_LINK_TYPE = "url" |
||
04/17/14, 04:30 PM | #16 |
You're awesome, ins. I had noticed a few things in there (level, itemID, and what changed with an enchant), but you've discovered more than me.
It would also be really nice to build a table of enchant IDs. |
|
04/20/14, 12:54 PM | #17 |
|
Added my first Wiki Entry. Probably not following any formatting guidelines though.
http://wiki.esoui.com/ZO_LinkHandler_CreateLink |
ESOUI » Developer Discussions » Lua/XML Help » Question in regards to string.lower |
«
Previous Thread
|
Next Thread
»
|
Display Modes |
Linear Mode |
Switch to Hybrid Mode |
Switch to Threaded Mode |
|
|