|
 |
| Author |
Message |
|
Domino
|
Posted: 16 May, 2012
|
|
Joined: 26 Feb, 2009 Posts: 2996
|
Hi, Maybe im having a blonde moment, im having problems with this peice of code. Code: function UpdateMeshIconPositions(Unit) local MeshIcons = GetUnitMeshIcons(Unit) local TotalIcons = table.getsize(MeshIcons) local MeshNum = 1 WARN('Total Icons ' .. repr(TotalIcons)) for id, MeshIconId in MeshIcons do local MeshIcon = GetEntityById(MeshIconId) if MeshIcon then local Offsets = MeshIcon:GetOffsets() local NewOffsetX = Offsets[1] * MeshNum local NewOffsetY = Offsets[2] WARN('NewOffsetX --> ' .. repr(NewOffsetX)) MeshIcon:SetParentOffset(Vector(NewOffsetX,NewOffsetY,0)) MeshNum = MeshNum + 1 end end end what is does is set some meshes out in a line from the initial position like so: cba however i want them to be abc they basicly go left from a to c instead of right from a to c i know why it does this, its because the initial position is a negative offset Code: WARNING: Total Icons 3 WARNING: NewOffsetX --> -0.375 WARNING: NewOffsetX --> -0.75 WARNING: NewOffsetX --> -1.125 what i need to do with the 2 and 3rd offsets is make them go positive so they go to the right of the last position, as you can see the offsets are all negative numbers, which is correct for the code, it takes the initial offset and times it by the iteration of the loop, how do i get the correct offset going to the right? Thx.
_________________ Domino. ______________
Last edited by Domino on 16 May, 2012, edited 1 time in total.
|
|
| Top |
|
 |
|
Domino
|
Posted: 16 May, 2012
|
|
Joined: 26 Feb, 2009 Posts: 2996
|
Solved it with this, Code: function UpdateMeshIconPositions(Unit) local MeshIcons = GetUnitMeshIcons(Unit) local TotalIcons = table.getsize(MeshIcons) local NumPerRow = 3 local NumColums = 1 local MeshNum = 1 local NewOffsetY = 0 for id, MeshIconId in MeshIcons do local MeshIcon = GetEntityById(MeshIconId) if MeshIcon then local Offsets = MeshIcon:GetOffsets() local NewOffsetX = Offsets[1] * MeshNum if NewOffsetY == 0 then NewOffsetY = Offsets[2] end if MeshNum > NumPerRow then MeshNum = 1 NumColums = NumColums + 1 NewOffsetY = Offsets[2] + math.abs(Offsets[1] * (NumColums -1)) end if MeshNum == 1 then NewOffsetX = Offsets[1] * MeshNum else NewOffsetX = Offsets[1] + math.abs(Offsets[1] * (MeshNum -1)) end MeshIcon:SetParentOffset(Vector(NewOffsetX,NewOffsetY,0)) MeshNum = MeshNum + 1 end end end Offsets is the initial offsets in table form { 1,1,0 } it produces this, the little icons above the commander. 
_________________ Domino. ______________
|
|
| Top |
|
 |
|
phong1892
|
Posted: 19 May, 2012
|
|
Joined: 31 Mar, 2011 Posts: 128 Location: Hanoi, Vietnam
|
Hi Domino, it's very very cool stuff. I like it very much  . Make it modular so I can use it in my mod, please.
|
|
| Top |
|
 |
|
Domino
|
Posted: 20 May, 2012
|
|
Joined: 26 Feb, 2009 Posts: 2996
|
Hi, they are modular, everything in DMS is modular  all you need to do is create a mesh and textures, put the mesh in your mods folder in /mods/yourmodname/meshes/intelfieldmeshes/yourmeshname/these icons use a spec table for there params it looks like this.. { FieldRemove = false, VizTable = { FocusPlayer = true, Enemy = false, Allied = true, Neutral = true, }, Size = 1.0, MeshScale = 1.0, ScaleMult = 0.50 }for intel fields, we can add params to the inel table spec to auto add an icon and remove it, but i also made functions to manually add icons, AddUnitMeshIcon = function(self, Spec, Time) AddUnitMeshIcon(self, Spec, Time) end, RemoveUnitMeshIcon = function(self, IconName) RemoveUnitMeshIcon(self, IconName) end,if time is nil/false or 0 then the icon will never be removed until you remove it, if a time is specified, then the icon is removed in x time (seconds) automaticly.
_________________ Domino. ______________
|
|
| Top |
|
 |
|
phong1892
|
Posted: 20 May, 2012
|
|
Joined: 31 Mar, 2011 Posts: 128 Location: Hanoi, Vietnam
|
|
Don't understand about it very much. I'm busy for now and I'll study it later. My idea: Every unit have its own mesh icon above. The mesh icon is displayed when we select unit so that if we deselect unit, it will disappear. The mesh icon also disappear when camera zoom > IconFadeZoom. Bonus(not important): I want to have some small stars when unit become veteran between mesh icon and unit mesh.
I'm very thankful if you show me how to solve it. Thank you
|
|
| Top |
|
 |
|
Domino
|
Posted: 20 May, 2012
|
|
Joined: 26 Feb, 2009 Posts: 2996
|
|
Hi,
i can add that to DMS is you want, it wont be in this release, but i can put it on the list for the next release.
Dave.
_________________ Domino. ______________
|
|
| Top |
|
 |
|
phong1892
|
Posted: 21 May, 2012
|
|
Joined: 31 Mar, 2011 Posts: 128 Location: Hanoi, Vietnam
|
Domino wrote: Hi,
i can add that to DMS is you want, it wont be in this release, but i can put it on the list for the next release.
Dave. Sure, make it on the air in the next release please. Thank you so much 
|
|
| Top |
|
 |
 |
 |
|