• 0

    posted a message on Attempt to access forbidden object from code tainted by an AddOn
    Great, that was exactly what I was looking for.
    Posted in: Lua Code Discussion
  • 0

    posted a message on Attempt to access forbidden object from code tainted by an AddOn
    Since (approximately) 6.0.x some frames are "forbidden". Even looking at them will cause an error. Examples include "StoreFrame".

    I understand why they are especially protected.

    However, when iterating over global variables inevitabley these come up (imho they should not be global if they are forbidden) leading to errors.

    Is there a way to detect whether a frame is forbidden without triggering an error?

    Edit: The following works/works not
    type(StoreFrame) -- table
    type(StoreFrame.IsObjectType) -- function
    StoreFrame:IsObjectType() -- error
    Posted in: Lua Code Discussion
  • 0

    posted a message on My Work on a Lua IDE
    Thank you very much for this, it is awesome.
    There is one small issue though: I like to diffentiate between single and double quoted strings. I would like to have different markup for them, but I think this cannot be done right now. Could you include this or tell me how to do it?
    Posted in: Lua Code Discussion
  • 0

    posted a message on Moving FramerateLabel ... but it moves back!
    I found my mistake... really stupid:
    Turns out that "UIParent" and UIParent are not equal (we all knew that...).
    But unfortunately may check assumed that the relative frame was always a frame, but sometimes it is a string.
    Posted in: Lua Code Discussion
  • 0

    posted a message on Moving FramerateLabel ... but it moves back!
    Thanks Phanx.

    I was able to reproduce that indeed UIParent_ManageFramePosition is (at least one of) the cause.
    (Using
    FramerateLabel.SetPoint = function() ... error() ... end

    to get a stacktrace.)

    I'm still not sure why my approach does not work, but I will give your idea a try.
    Posted in: Lua Code Discussion
  • 0

    posted a message on Moving FramerateLabel ... but it moves back!
    Using a dual screen setup certain parts of the standard interface are ... very bad placed.
    I successfully moved the worldscreen to only one screen.
    However many things don't follow.
    One example is the FramerateLabel (for me I is shown with CTRL+R).
    By default it is anchored to BOTTOM, UIPARENT, BOTTOM, 0, 135 which happens to be in the middle (left-right) of the virtual screen. Unfortunately that corresponds to the exact place where the gap between the two physical screens is.



    Using (from memory)
    FramerateLabel:ClearAllPoints()
    FramerateLabel:SetPoint('BOTTOM', WorldFrame, 'BOTTOM', 0, 135)

    I can move this to a more suitable place.
    So far so good.

    However after some time the FramerateLabel moves back to the original position. This is what surprises me, because I could not find the cause.

    To find it I tried replacing FramerateLabel.SetPoint, but somehow this has not helped me.

    Edit 1:
    What I also know: This happens whenever I have a loading screen. also at some other times. Apparently some Blizzard code resets the anchors. I tried to solve this by replacing SetPoint, but apparently I am doing it wrong.

    Edit2:
    This is part of my code for the replacement function for SetPoint
    	if frame:GetName() == "FramerateLabel" then
    		ChatFrame1:AddMessage("A" .. (relativeFrame and relativeFrame.GetName and relativeFrame:GetName() or tostring(relativeFrame)))
    	end
    	local newRelativeFrame = relativeFrame
    	if relativeFrame == UIParent then
    		if frame:GetName() == "FramerateLabel" then
    			ChatFrame1:AddMessage("changing")	
    		end
    		newRelativeFrame = WorldFrame
    	else
    		if frame:GetName() == "FramerateLabel" then
    			ChatFrame1:AddMessage("not UIParent, not changing")
    		end
    	end
    	local original = originalSetPoint[frame]
    	assert(original)
    	if frame:GetName() == "FramerateLabel" then
    		ChatFrame1:AddMessage("B" .. (newRelativeFrame and newRelativeFrame.GetName and newRelativeFrame:GetName() or tostring(newRelativeFrame)))
    	end

    The strange thing is that I get

    A UIParent
    not UIParent, not changing
    B UIParent
    Posted in: Lua Code Discussion
  • 0

    posted a message on How to rotate a texture and fill
    The right image is not a 180° degree, it is either 90° or 270°, proably a typo.
    These four (0, 90, 180, 270) are all easy. You don't need much code for that.

    The non-rectangular angles are a bit more involved. Can you follow the math I posted? If not someone might be willing to do so for you.
    Posted in: Lua Code Discussion
  • 0

    posted a message on How to rotate a texture and fill
    So you want to crop a texture, e.g, from to bottom, but only from left to 40%.
    This is done with:
    :SetTexCoord(0, 0.4, 0, 1)

    this is equivalent to
    :SetTexCoord(0, 0,  0, 1,  1, 0,  0.4, 1)

    Unfortunately :SetRotation will probably overwrite this. But please try it.

    If you need to do a manual rotation you should first attempt to manually calculate the texture coords for a rotation.

    I don't want to do the math right now, please read
    http://wowpedia.org/SetTexCoord_Transformations
    and
    http://wowpedia.org/API_Texture_SetRotation



    Edit: I should point out, that I don't think what you want is possible this way. But unless you give an example picture of what you want I can't be sure.
    Posted in: Lua Code Discussion
  • 0

    posted a message on How to rotate a texture and fill
    I am a bit lost. What do you mean by fill? I assumed you mean stretches from border to border. That makes not much sense with rotation.
    Can you post a picture of what you want vs. what you got?

    Also your code is a bit without context. Textures normaly have no field Type or Subtexture.
    Posted in: Lua Code Discussion
  • 0

    posted a message on LibMapPins-1.0
    Quote from myrroddin
    I was actually thinking about this. Zygor gave me the idea of a library that handles traveling. IE: fastest, use every trick; lazy, use flight masters; scenic, mount up and go your own way. That sort of thing. If done, then it would definitely be a separate library.

    The point is, smaller libraries are easier to maintain. If blizz adds a new continent (which is probably only a question of time, Astrolabe needs to be changed. The coordinate translation part of LMP would also need to be changed. However the minimap/worldmap pin placement can probably stay the same, that does not depend on the actual zones or zone data.
    So splitting this might improve maintanabilty.

    Quote from myrroddin

    The X and Y in percent rather than 0-1 is because users are more familiar with that method. When looking at Mapster, Atlas, or other map, or TomTom, both cursor and player coordinates are given in percentages. It is just my way of keeping things simple.

    Maybe. But you should not confuse addon users with library users. The average TomTom user will probably never use your library directly. When defining specification for an API it is more important to care about authors, cause they will use the API. Astrolabe uses the range [0,1] for example.
    However, this is not something I feel strongly about. In the end its just a factor 100, as long as it is documented I can work with that.

    Quote from myrroddin

    areaID? What am I not knowing?

    Probably we mean the same thing:
    http://wowprogramming.com/docs/api/GetCurrentMapAreaID and http://wowpedia.org/MapID are the same. What I meant is we should add a reference, for example these two links, to the documentation so everyone understands what a "mapID" is.
    In particular we should point out that is neithera zoneIndex, a mapTextureName nor a localized map name.

    Quote from myrroddin

    I haven't tested to make certain, but that, and similar APIs, I had hoped, would still get applied when PLAYER_ENTERING_WORLD fires when the lib parses WorldMapPins and reattaches the pins to the world map. Of course, if WorldMapPins is wiped out, then all those APIs become rather useless, and can be deleted from the library.

    I am pretty sure that after a reload everything is gone from memory.

    Quote from myrroddin

    This API I am not happy with. The idea here was that in MyAddOn, you would indeed be able to find one pin among the possible hundreds or thousands. Something like "find me the repair guy in Shrine of Seven Stars". My goal was being able to hook into the travel system discussed above so you could set a waypoint directly to a single pin. But as I said, I am not happy with how it is turning out.

    I see. Well. You want to do a lookup. That makes sense. But I am not sure if thats the right way to do this. I would at least suggest to use another field.
    (LibMapMetaData has for example a class field, which is intended for classifying locations).

    Also I would think that for most cases an iterate method would be sufficient.
    We might also add a wrapper for a map reduce.
    However I still think you want to solve too many distinct problems with one library.

    Quote from myrroddin

    I am all ears. There is zero point in writing this if it doesn't work the way people would want it to work.

    Its difficult to estimate what people want.
    I am personally looking for two things:
    1.
    A way to transform zone coordinates to continent coordinates (where a continent is the largest area which can be travelled using free movement (including (flying) mounts, swimming, walking, excluding taxi, portals)). For example every instance (dungeon, raid, scenario, battleground, arena, ...) is a continent, as is Pandaria, Kalimdor, Outland, Northrend, The Eastern Kingdoms.
    Also the other way round: Given a location, find every map this is in.
    For example if you are in stormwing this would return at least a location in Stormwind, Elwynn forest and Eastern Kingdoms.

    2.
    An easy way to add information from LibMapMetaData to the worldmap and minimap.

    These two things do not have to be the same library.


    To understand why I need that, let me illustrate what addons I created:
    There is GraveLogMap, which is a map addon. It can display icons, lines and areas from LibMapMetaData.
    There is MapMetaData_OtherPlayers. It provides icons for the position of your group and guild members (the second using LibGuildPositions).
    There is MapMetaData_Quests which provides the locations of quests.
    Posted in: Libraries
  • 0

    posted a message on LibMapPins-1.0
    Some questions come to mind.
    1.
    Why is the Minimap/Worldmap pin handling and the coordinate translation one library?
    While pin placement needs coordinate translation to be usefull, coordinate translation does not need to know about pin management.
    Personally I would split this into two libraries, at least into two files.

    2.
    Concerning
    --- Place an icon on the world map frame.
    -- @paramsig icon, x, y, mapID[,mapFloor]
    -- @param icon Path to icon file (string)
    -- @param x Horizontal XX.xx coordinate for the icon (number)
    -- @param y Vertical YY.yy coordinate for the icon (number)
    -- @param mapID The mapID (number)
    -- @param mapFloor The map floor, default 0 (number) optional
    -- @usage -- Put an icon in Cleft of Shadow, Orgrimmar
    -- local pin = MyAddOn:CreatePinByMapID(icon, 22.84, 13.56, 321, 1)
    -- @return pin Shown on the world map, table of input values
    local function CreatePinByMapID(icon, x, y, mapID, mapFloor)

    2.1: I would suggest adding texture coordinates. When trying to reuse existing blizzard POI textures I noticed that many of them have a couple of icons per texture. Without texture coordinates they are unusable.
    2.2: why do you specify x and y in percent (i.e, range [0,100]) rather than range [0,1] as Astrolabe does? I think this might cause confusion. In anyway this should be documented more clearly, e.g.:
    -- @param x Horizontal XX.xx coordinate for the icon (number in range [0,100] where 0 is the leftmost part of the map and 100 is the rightmost part)
    

    2.3: For y coordinates it should be documented whether 0 is top or bottom.
    (For x this is also good, but less necessary, as X generally starts with 0 on the left side)
    2.4: You should probably add a reference to areaId for the mapID parameter.

    3.
    return error(major.. "You cannot attach a pin to this map", 2)
    

    I don't think error ever returns, the return keyword will never be executed.

    4.
    --- Set a world pin's height. Do not call :SetHeight() directly
    -- because UI reloads will forget the setting.
    -- @param pin The world pin to adjust
    -- @param height Number in pixels
    local function SetWorldPinHeight(pin, height)
    	local Pin = WorldMapPins[pin]
    	
    	if Pin then
    		Pin.height = height
    		Pin:SetHeight(height)
    		
    		WorldMapPins[pin] = Pin
    	end
    end

    I don't think I get what you are trying to tell me here.
    Of course after a reload everything is gone, unless you had savedvariables. But since this is a library, it does not have saved variables.
    So what purpose does saving the height have?

    5.
    --- Hide all world map pins and labels.
    -- @usage MyAddOn:HideAllWorldPins()
    local function HideAllWorldPins()
    

    What purpose could this function have? Is it intended to only hide the pins from one addon? (Doesn't look that way)
    If not, why should I care about other addon's pins? In fact, it might be annoying if some other addon hides my pins from time to time.
    I think this definitely needs to be limited to addon scope.

    6.
    local function FindWorldIcon(icon)

    This is a search by texture. Assuming some addon like Gatherer/GatherMate would use your library, this will, for example, return one copper node per zone.

    7.
    -- Need to show pins every time player reloads UI
    -- These are internal functions
    function lib:PLAYER_ENTERING_WORLD()
    

    Unless I am seriously overlooking something, this is pointless, as WorldMapPins will be an empty table after every reload.
    This is totally ok though, your library does not need to store pins, thats the addons responsibility.
    In fact it would be awkward if I decide to disable e.g. Gatherer, do a reload, and the ores/herbs wer still there.


    I hope you are not overwhelmed with the feedback.
    In general I think we need to invest a bit more time defining the purpose and API before implementing stuff.
    Posted in: Libraries
  • 0

    posted a message on LibMapPins-1.0
    Which functionality of Astrolabe do you intend to replace?
    Everything? The minimap stuff? The coordinate translation stuff?
    Posted in: Libraries
  • 0

    posted a message on Target direction
    While phanx is right that it cannot be done easily, or even exact at all, it is, with a lot of work possible to get a general idea.

    This is just a rough outline of what should be possible:
    You will need a couple of players in the area of your target. This could work in a battleground/raid, but probably not if you are solo.
    Every player can get its position and an estimate of the distance to the target.
    With this information you could potentially get a rough estimate of the position of the target.
    Your position and facing is easy to get, hence you can get the direction to the target.
    Posted in: Addon Ideas
  • 0

    posted a message on LibMapPins-1.0
    Also, you might want to have a look at a library I created for my personal use (and did not bother to upload yet as it is still in early stage).

    It does not display anything, it just a way for me to transfer data between my data source addons and my map addon. It is completely orthogonal to Astrolabe, and LibMapPins at its current stage.
    I am not sure where exactly you want to go with LibMapPins, so this is just to give you an idea what I did.
    http://www.wowace.com/paste/8623/
    Posted in: Libraries
  • To post a comment, please or register a new account.