Page 1 of 1
Help with code
Posted: Thu Aug 12, 2004 3:01 pm
by Aarrow
Can anyone help me with this code... kinda a noob, never really programed that much, etc.
What I'm trying to do is display if you're close enough to cast on something (If you are it will display 0, if not, it will display how much closer you need to be)
Code: Select all
${If[${Math.Calc[${Target.Distance}-${If[${Me.Gem[1].Range}==0,,${Me.Gem[1].Range}]}]}<=0,0,${Int[${Math.Calc[${Target.Distance}-${If[${Me.Gem[1].Range}==0,,${Me.Gem[1].Range}]}]}]}]}
Posted: Thu Aug 12, 2004 3:20 pm
by Mimatas
Holy block code, batman.
When I run into trouble with incredibly nested code like this, I do a few things:
1. format it, so it's easy to see which parenthese, brackets, etc. line up.
2. Make sure that the types being returned are the types being expected by the function in which this function is nested.
3. break it up. Use multiple lines of code, rather than just nesting it all into one, and see if it works. This way, you can more easily narrow down WHY it doesn't work.
Posted: Thu Aug 12, 2004 3:34 pm
by Cr4zyb4rd
Code: Select all
${If[${Math.Calc[${Target.Distance}-${Me.Gem[1].Range}]}>0,${Math.Calc[${Target.Distance}-${Me.Gem[1].Range}]},0]}
Posted: Thu Aug 12, 2004 3:50 pm
by Aarrow
Thanks Cr4zyb4rd.
I did almost the same thing right before I read your code, but wasn't sure if it was right or not...
Code: Select all
${If[${Math.Calc[${Target.Distance}-${Me.Gem[1].Range}]}<=0,0,${Math.Calc[${Target.Distance}-${Me.Gem[1].Range}]}]}
Going to test it now
Posted: Thu Aug 12, 2004 3:58 pm
by Aarrow
Works... Now the easy part, making it red if the target's out of range, yellow if it's in range, but out of sight, and green if it's inrange and I can cast on it.

Posted: Thu Aug 12, 2004 4:11 pm
by fryfrog
Is this going into a HUD or a UI? I think doing it in HUD is easy, but if you figure it out in UI please tell me :)
Posted: Thu Aug 12, 2004 4:13 pm
by Aarrow
UI, and sure I'll tell you how to do it.. When I'm done I'll post all the code (I'm using SOE's UI modded by SirCodeAlot). I'll probably post it there too...
Posted: Thu Aug 12, 2004 5:23 pm
by Drumstix42
The reason they're asking is because the UI doesn't like like less than and greater than signs in the code. It things it's another XML tag, but it's not.
Posted: Thu Aug 12, 2004 5:55 pm
by Aarrow
Told you I'm a noob... Thanks a lot

Posted: Thu Aug 12, 2004 11:12 pm
by No_Idea_At_All
Drumstix42 wrote:The reason they're asking is because the UI doesn't like like less than and greater than signs in the code. It things it's another XML tag, but it's not.
Actually I have not had a problem using the greater than sign, just the less than. So all your equations will have to take that into account.
Finally finished some graphics for my UI last night (and also fixed some errors) so hopefully when I get home I'll start posting it.
Although the distance thing is a good idea, I'll have to look into that :)
Posted: Fri Aug 13, 2004 1:14 am
by Aarrow
Well, I got it finished finally. Apparently SirCodeAlot is adding it into his next update... Anyway, here's the code
Code: Select all
<Label item="MQ_Spell1A">
<ScreenID>MQ_Spell1A</ScreenID>
<EQType>9999</EQType>
<Font>5</Font>
<TooltipReference>${Int[${If[${Math.Calc[${Target.Distance}-${Me.Gem[1].Range}]}>0,${Math.Calc[${Target.Distance}-${Me.Gem[1].Range}]},]}]}</TooltipReference>
<RelativePosition>true</RelativePosition>
<Location>
<X>95</X>
<Y>12</Y>
</Location>
<Size>
<CX>100</CX>
<CY>20</CY>
</Size>
<Text>100</Text>
<TextColor>
<R>255</R>
<G>0</G>
<B>0</B>
</TextColor>
<NoWrap>true</NoWrap>
<AlignCenter>false</AlignCenter>
<AlignRight>false</AlignRight>
<AlignLeft>true</AlignLeft>
</Label>
<Label item="MQ_Spell1B">
<ScreenID>MQ_Spell1B</ScreenID>
<EQType>9999</EQType>
<Font>5</Font>
<TooltipReference>${If[${Math.Calc[(${Target.Distance}-${Me.Gem[1].Range})*-1]}>0,${If[${Target.ID}==NULL,"",${If[${Target.LineOfSight}==FALSE,0,]}]},]}</TooltipReference>
<RelativePosition>true</RelativePosition>
<Location>
<X>95</X>
<Y>12</Y>
</Location>
<Size>
<CX>100</CX>
<CY>20</CY>
</Size>
<Text>100</Text>
<TextColor>
<R>255</R>
<G>255</G>
<B>0</B>
</TextColor>
<NoWrap>true</NoWrap>
<AlignCenter>false</AlignCenter>
<AlignRight>false</AlignRight>
<AlignLeft>true</AlignLeft>
</Label>
<Label item="MQ_Spell1C">
<ScreenID>MQ_Spell1C</ScreenID>
<EQType>9999</EQType>
<Font>5</Font>
<TooltipReference>${If[${Math.Calc[(${Target.Distance}-${Me.Gem[1].Range})*-1]}>0,${If[${Target.ID}==NULL,"",${If[${Target.LineOfSight}==TRUE,"Cast",]}]},]}</TooltipReference>
<RelativePosition>true</RelativePosition>
<Location>
<X>95</X>
<Y>12</Y>
</Location>
<Size>
<CX>100</CX>
<CY>20</CY>
</Size>
<Text>100</Text>
<TextColor>
<R>0</R>
<G>255</G>
<B>0</B>
</TextColor>
<NoWrap>true</NoWrap>
<AlignCenter>false</AlignCenter>
<AlignRight>false</AlignRight>
<AlignLeft>true</AlignLeft>
</Label>
That's it.. PM me when you get your UI up No_Idea_At_All, I'd like to check it out.