Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Jan 2012
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    problem with my code PLEASE help

    hi im a long time wow player ive tinkered with lua before and scripted bosses but was always frightened about add-ons as never messed with xml I've just had a go at writing my first one surprise surprise it didn't work and now we get to the root of my problem i was hoping some of you very clever people could help anyway here's the offending code hope you can spot my mistake and ty

    Code:
    <Ui>
    	<Frame name="WoWProFit_MainFrame" parent="UIParent">
    			enableMouse="true"
    			moveable="true">
    		<Anchors>
    			<Anchor point="CENTER" />
    		</Anchors>
    		<Size>
    			<AbsDimension x="160" y="20" />
    		</Size>
    		<Backdrop	bgFile="Interface\Tooltips\UI-Tooltip-Background"
    					edgeFile="Interface\Tooltips\UI-Tooltip-Border"
    					tile="true">
    			<EdgeSize>
    				<AbsValue val="16" />
    			</EdgeSize>
    			<TileSize>
    				<AbsValue val="16" />
    			</TileSize>
    			<BackgroundInsets>
    				<AbsInset left="4" right="3" top="4" bottom="3" />
    			</BackgroundInsets>
    			<Color r="0.2" g="0.2" b="0.2" a="0.7" />
    		</Backdrop>
    		
    		<Frames>
    			<Button name="$parent_Button">
    				<Size>
    					<AbsDimension x="15" y="15" />
    				</Size>
    				<Anchors>
    					<Anchor point="TOPLEFT">
    						<Offset>
    							<AbsDimension x="3" y="-3" />
    						</Offset>
    					</Anchor>
    				<Anchors>
    				<NormalTexture file="Interface\Minimap\TRACKING\OBJECTICONS">
    					<TexCoords left="0" right="0.125" top="0" bottom="0.5" />
    				</NormalTexture>
    				<HighlightTexture>
    					<Textcoords left="0.125" right="0.25" top="0" bottom="0.5" />
    				</HighlightTexture>
    				<Scripts>
    					<OnClick>
    						WoWProFit_Button_OnClick()
    					</OnClick>
    				</Scripts>					
    			</Button>
    		</Frames>
    		
    		<Layers>
    			<Layer level="ARTWORK">
    				<FontString name="$parent_Goldstring"
    							inherits="SystemFont_Small"
    							text="0"
    							justifyH="TOP"
    							justifyH="RIGHT">
    					<Size>
    						<AbsDimention x="0" y="10" />
    					</Size>
    					<Anchors>
    						<Anchor point="TOPLEFT">
    							<Offset>
    								<AbsDimention x="20" y="-5" />
    							</Offset>
    						</Anchor>
    					</Anchors>
    					<color r="1" g="1" b="0" a="1" />
    				</FontString>
    			
    				<Texture	name="$parent_GoldTex"
    							file="Interface\MoneyFrame\UI-GoldIcon">
    					<Size>
    						<AbsDimention x="10" y="10" />
    					</Size>
    					<Anchors>
    						<Anchor point="TOPLEFT"
    								relativeTo="$parent_Goldstring"
    								relativePoint="TOPRIGHT"
    							<Offset>
    								<AbsDimention x="2 y="0" />
    							</Offset>
    						</Anchor>
    					</Anchors>
    				</Texture>
    				
    				<FontString name="$parent_SilverString"
    							inherits="SystemFont_Small"
    							text="0"
    							justifyV="TOP"
    							justifyH="RIGHT">
    					<Size>
    						<AbsDimention x="0" y="10" />
    					</Size>
    					<Anchors>
    						<Anchor point="TOPLEFT"
    								relativeTo="$paretnt_Goldtex"
    								relativePoint="TOPRIGHT">
    							<Offset>
    								<AbsDimention x="2" y="0" />
    							</Offset>
    						</Anchor>
    					</Anchors>
    					<Color r="1" g="1" b="0" a="1" />
    				</FontString>
    				
    				<Texture	name="$parent_SilverTex"
    							file="Interface\MoneyFrame\UI-SilverIcon">	
    					<Size>
    						<AbsDimention x="2" y="0" />
    					</Size>
    					<Anchors>
    						<Anchor point="TOPLEFT"
    								relativeTo="$parent_SilverString"
    								relativePoint="TOPRIGHT">
    							<Offset>
    								<AbsDimention x="2" y="0" />
    							</Offset>
    						</Anchor>
    					</Anchors>
    				</Texture>
    				
    				<FontString name="$parent_copperString"
    							inherits="SystemFont_Small"
    							text="0"
    							justifyV="TOP"
    							justifyH="RIGHT">
    					<Size>
    						<absDimension x="0" y="10" />
    					</Size>
    					<Anchors>
    						<Anchor point="TOPLEFT"
    								relativeTo="$parent_SilverTex"
    								relativePoint="TOPRIGHT">
    							<Offset>
    								<AbsDimentsion x="2" y="0" />
    							</Offset>
    						</Anchor>
    					</Anchors>
    					<color r="1" g="1" b="0" a="1" />
    				</FontString>
    				
    				<Texture	name="$parent_CopperTex"
    							file="Interface\MoneyFrame\UI-CopperIcon">
    					<Size>
    						<AbsDimension x="10" y="10" />
    					</Size>
    					<Anchors>
    						<Anchor point="TOPLEFT"
    								relative="$parent_CopperString"
    								relativePoint="TOPRIGHT">
    							<Offset>
    								<AbsDimension x="2" y="0" />
    							</Offset>
    						</Anchor>
    					</Anchors>
    				</Texture>
    			</Layer>
    		</Layers>
    		
    		<Scripts>
    			<OnLoad>
    				WoWProFit_OnLoad
    			</OnLoad>
    			<OnEvent>
    				WoWProFit_OnEvent()
    			</OnEvent>
    			<OnMouseDown>
    				WoWProFit_OnMouseDown()
    			</OnMaousDown>
    			<OnMouseUp>
    				WoWProFit_OnMouseUp()
    			</OnMouseUp>
    		</Scripts>
    	</Frame>
    </Ui>
    I don't know if you need the script or not so ill post it too
    here's my lua file
    Code:
    WoWProFit_LastMoney = 0
    WoWProFit_MadeProfit = false
    WoWProFit_History = {}
    
    function WoWProFit_OnMouseDown()
    	WoWProFit_MainFrame:StartMoving()
    end
    
    function WoWProFit_OnMouseUp()
    	WoWProFit_MainFrame:StopMovingOrSizing()
    end
    
    function WoWProFit_OnLoad()
    	WoWProFit_LastMoney = GetMoney()
    	WoWProFit_ChangeSize()
    	WoWProFit_MainFrame:RegisterEvent("PLAYER_MONEY")
    end
    
    function WoWProFit_ChangeSize()
    	local width = 65
    	width = width + WoWProFit_MainFrame_GoldStringWidth()
    	width = width + WoWProFit_MainFrame_SilverStringWidth()
    	width = width + WoWProFit_MainFrame_CopperStringWidth()
    	
    	WoWProFit_MainFrame:SetWidth(width)
    end
    
    function WoWProFit_OnEvent()
    	if event == "PLAYER_MONEY" then
    		if not WoWproFit_MadeProfit then
    		table.insert(WoWProFit_History, 1, 0)
    		WoWProFit_MadeProfit = true
    		end
    	
    		local difference = GetMoney() - WoWProFit_LastMoney
    		WoWProFit_History[1] = WoWProFit_History[1] + difference
    		WoWProFit_LastMoney = GetMoney()
    		
    		local gold, silver, copper = WoWProFit_ReturnMoney(WoWProFit_History[1])
    		
    		WoWProFit_MainFrame_GoldString:SetText(gold)
    		WoWProFit_MainFrame_SilverString:SetText(silver)
    		WoWProFit_MainFrame_CopperString:SetText(copper)
    		
    		WoWProFit_ChangeSize()
    		
    		if WoWProFit_History[1] < 0 then
    			WoWProFit_MainFrame_GoldString:SetTextColour(1,0,0)
    			WoWProFit_MainFrame_SilverString:SetTextColour(1,0,0)
    			WoWProFit_MainFrame_CopperString:SetTextColour(1,0,0)
    		elseif WoWProFit_History[1] > 0 then
    			WoWProFit_MainFrame_GoldString:SetTextColour(0,1,0)
    			WoWProFit_MainFrame_SilverString:SetTextColour(0,1,0)
    			WoWProFit_MainFrame_CopperString:SetTextColour(0,1,0)
    		else
    			WoWProFit_MainFrame_GoldString:SetTextColour(1,1,0)
    			WoWProFit_MainFrame_SilverString:SetTextColour(1,1,0)
    			WoWProFit_MainFrame_CopperString:SetTextColour(1,1,0)
    		end
    	end
    end
    
    function WoWProFit_ReturnMoney(money)
    	local absMoney = abs(money)
    	local gold = floor(absMoney / 10000)
    	local silver = floor((absMoney - gold*10000) / 100)
    	local copper = absMoney - gold*10000 - silver*100
    	return gold, silver, copper
    end
    
    function WoWProFit_Button_OnClick()
    		local alltime = 0
    		
    		for k,v in pairs(WoWProFit_History) do
    			alltime = alltime + v
    		end
    		
    		local gold,silver,copper = WoWProFit_ReturnMoney(alltime)
    		
    		if alltime < 0 then
    			DEFAULT_CHAT_FRAME:AddMessage("WoWProFit - All time |cFFFF0000deficit|r:")
    		else
    			DEFAULT_CHAT_FRAME:AddMessage("WoWProFit - All time |cFF00FF00profit|r:")
    			end
    			
    			DEFAULT_CHAT_FRAME:AddMessage(  "|cFFFFFF00" .. gold ..
    											" |cFFAAAAAA" .. silver ..
    											" |cFF993300" .. copper)
    end
    a small message to the moderators PLEASE accept this post as I'm tearing my hair out
    and to the geniuses that frequent this site a thank you in advance
    Last edited by AndyPipkin; 01-21-2012 at 12:55 PM.

  • #2
    New to the CF scene
    Join Date
    Jan 2012
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    not even a reply please help

  • #3
    Supreme Overlord Spookster's Avatar
    Join Date
    May 2002
    Location
    Marion, IA USA
    Posts
    6,273
    Thanks
    4
    Thanked 83 Times in 82 Posts
    You never explained what the problem was or what you were expecting to happen verses what actually happened. Are there error or warning messages?
    Spookster
    CodingForums Supreme Overlord
    All Hail Spookster

  • #4
    New to the CF scene
    Join Date
    Jan 2012
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    the problem is it wont show in game ive tested the lua and there was one error which i have fixed


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •