Is it possible to achieve the exact same thing with the TextTimeFormat function as I did?
I don't think that it will correctly differentiate between singular and plural.
Also it won't add ","s and "and"s at the right places.
Great work. The code looks pretty clean, too. I don't think that further optimization is needed (I don't know if Galaxy has some sort of auto-optimization, but I guess not), because it is already nearly as fast as using "Mouse World Pos". Maybe it can be changed, so that the cos() and sin() values are only recomputed, when the angle of the camera axis actually changes, otherwise there are only few multiplications to save.
Projecting world to UI coordinates sounds more interesting indeed. I played with the thought of using this once for an UI that pops up "on top" of a unit, but that idea had some disadvantages. I would be interesting what people would come up with.
This function converts an integer value in seconds into a string of the form:
h hours, m minutes and s seconds
depending on the value, results as
1 hour
3 hours and 1 minute
1 hour, 10 minutes and 1 second
2 hours and 10 seconds
20 minutes and 42 seconds
...
are automatically generated.
SecondsToTextOptions:FunctionReturnType:TextParametersSeconds=0<Integer>GrammarText:SecondsToText(Seconds)HintText:(None)CustomScriptCodeLocalVariablesh=0<Integer>m=0<Integer>s=0<Integer>result=NoText<Text>ActionsVariable-Sets=SecondsGeneral-If(Conditions)thendo(Actions)elsedo(Actions)Ifs>=3600ThenVariable-Seth=(s/3600)Variable-Sets=(smod3600)Variable-Setresult=((Text(h))+" hour")General-If(Conditions)thendo(Actions)elsedo(Actions)Ifh>1ThenVariable-Setresult=(result+"s")ElseElseGeneral-If(Conditions)thendo(Actions)elsedo(Actions)Ifs>=60ThenVariable-Setm=(s/60)Variable-Sets=(smod60)General-If(Conditions)thendo(Actions)elsedo(Actions)Ifh>0ThenGeneral-If(Conditions)thendo(Actions)elsedo(Actions)Ifs>0ThenVariable-Setresult=(result+", ")ElseVariable-Setresult=(result+" and ")ElseVariable-Setresult=((result+(Text(m)))+" minute")General-If(Conditions)thendo(Actions)elsedo(Actions)Ifm>1ThenVariable-Setresult=(result+"s")ElseElseGeneral-If(Conditions)thendo(Actions)elsedo(Actions)IfOrConditionsh>0m>0ThenVariable-Setresult=(result+" and ")ElseVariable-Setresult=(result+((Text(s))+" second"))General-If(Conditions)thendo(Actions)elsedo(Actions)Ifs>1ThenVariable-Setresult=(result+"s")ElseGeneral-Returnresult
Then you would need to use a dialog with a text on it. I don't know of a way to get a Timer's value, so you would need a periodic event to count the seconds that have passed.
Where the Camera Target is the result of the unprojection, when the UI Coordinate is (resolution.x/2; resolution.y/2).
Imagine the screen is a plane in the 3D space. You can get the world coordinate from the screen coordinate as follows:
You need to calculate a vector relative to this plane using the ui coordinate and the fov.
This vector is then scaled by the distance and rotated using the pitch and yaw values.
Add this vector to the camera's position and you have the world coordinate.
The only problem here is that you don't have the camera position, but the camera's target. You can convert between them, but there should be a way to calculate the world coordinate using the target position directly.
EDIT: SexLethal's solution is resolution/fov independent, but requires a calibration (which is a good idea as there is no way of getting the user's resolution as far as I know)
Afaik "Point from XY" just creates a point object with the coordinates x and y. What he is trying to achieve is unproject screen coordinates to world coordinates.
If you want to get the position of your cursor in the world space, than there are already functions for that. Otherwise, I think that things might get a bit more complicated. What are you trying to achieve exactly?
I am trying to make a spell that does absolutely nothing. I just want to click the spell button, then get a unit-target cursor and select another unit.
The rest is done in a trigger.
What I tried was creating an ability with Effect - Target and set the following values:
I get a crosshair when using the ability, but if I move the cursor over a unit, it doesn't get highlighted. I also don't know how to receive the targeted unit in the trigger.
Thanks in advance.
EDIT: I found out, that the highlighting doesn't work, because my target units are civilians, why is that and how can I fix this?
EDIT2: removing the "untargetable" flag makes the targeting work.
EDIT3: "Triggering Ability Target Unit" is the unit that is targeted.
0
But it will also result in this: 1 hours, 1 minutes, 1 seconds
where my algorithm will give the following result: 1 hour, 1 minute and 1 second
let minutes = 0, then it will result in (if you manually remove the minutes): 1 hours, 1 seconds
my algorithm: 1 hour and 1 second
It just looks less technical and is easier to read.
0
Is it possible to achieve the exact same thing with the TextTimeFormat function as I did? I don't think that it will correctly differentiate between singular and plural. Also it won't add ","s and "and"s at the right places.
0
If they do not want, why force them to do?
0
My favourite is the carrier model, but all the others look great, too. Awesome work.
0
Why not use the UI coordinates of the mouse directly (those are integers)?
0
Great work. The code looks pretty clean, too. I don't think that further optimization is needed (I don't know if Galaxy has some sort of auto-optimization, but I guess not), because it is already nearly as fast as using "Mouse World Pos". Maybe it can be changed, so that the cos() and sin() values are only recomputed, when the angle of the camera axis actually changes, otherwise there are only few multiplications to save.
Projecting world to UI coordinates sounds more interesting indeed. I played with the thought of using this once for an UI that pops up "on top" of a unit, but that idea had some disadvantages. I would be interesting what people would come up with.
0
@Topic: (Auto-)backups and version control systems (SVN, Git, ...) are the only way to deal with such problems.
0
I have had several problems using "idle units of player" and "unit becomes idle". Those don't seem to work properly in many cases.
0
This function converts an integer value in seconds into a string of the form:
depending on the value, results as
are automatically generated.
I hope this might be of use for someone ;)
0
Then you would need to use a dialog with a text on it. I don't know of a way to get a Timer's value, so you would need a periodic event to count the seconds that have passed.
Here is an example:
0
Things that need to be considered are:
Where the Camera Target is the result of the unprojection, when the UI Coordinate is (resolution.x/2; resolution.y/2).
Imagine the screen is a plane in the 3D space. You can get the world coordinate from the screen coordinate as follows:
The only problem here is that you don't have the camera position, but the camera's target. You can convert between them, but there should be a way to calculate the world coordinate using the target position directly.
EDIT: SexLethal's solution is resolution/fov independent, but requires a calibration (which is a good idea as there is no way of getting the user's resolution as far as I know)
0
Afaik "Point from XY" just creates a point object with the coordinates x and y. What he is trying to achieve is unproject screen coordinates to world coordinates.
0
If you want to get the position of your cursor in the world space, than there are already functions for that. Otherwise, I think that things might get a bit more complicated. What are you trying to achieve exactly?
0
Like this?
0
Hi,
I am trying to make a spell that does absolutely nothing. I just want to click the spell button, then get a unit-target cursor and select another unit. The rest is done in a trigger.
What I tried was creating an ability with Effect - Target and set the following values:
I get a crosshair when using the ability, but if I move the cursor over a unit, it doesn't get highlighted. I also don't know how to receive the targeted unit in the trigger.
Thanks in advance.
EDIT: I found out, that the highlighting doesn't work, because my target units are civilians, why is that and how can I fix this?
EDIT2: removing the "untargetable" flag makes the targeting work.
EDIT3: "Triggering Ability Target Unit" is the unit that is targeted.
Problem solved ;)