• 0

    posted a message on Time formatting

    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.

    Posted in: Trigger Libraries & Scripts
  • 0

    posted a message on Time formatting

    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.

    Posted in: Trigger Libraries & Scripts
  • 0

    posted a message on get fps of a player

    If they do not want, why force them to do?

    Posted in: Triggers
  • 0

    posted a message on Texture for a Reaver Model

    My favourite is the carrier model, but all the others look great, too. Awesome work.

    Posted in: Requests
  • 0

    posted a message on [Library] UI Screen To World Projection

    Why not use the UI coordinates of the mouse directly (those are integers)?

    Posted in: Trigger Libraries & Scripts
  • 0

    posted a message on [Library] UI Screen To World Projection

    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.

    Posted in: Trigger Libraries & Scripts
  • 0

    posted a message on Black Area on my map O.รด

    @Topic: (Auto-)backups and version control systems (SVN, Git, ...) are the only way to deal with such problems.

    Posted in: Terrain
  • 0

    posted a message on Why are functions not always available?

    I have had several problems using "idle units of player" and "unit becomes idle". Those don't seem to work properly in many cases.

    Posted in: Triggers
  • 0

    posted a message on Time formatting

    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.

    Seconds To Text
        Options: Function
        Return Type: Text
        Parameters
            Seconds = 0 <Integer>
        Grammar Text: Seconds To Text(Seconds)
        Hint Text: (None)
        Custom Script Code
        Local Variables
            h = 0 <Integer>
            m = 0 <Integer>
            s = 0 <Integer>
            result = No Text <Text>
        Actions
            Variable - Set s = Seconds
            General - If (Conditions) then do (Actions) else do (Actions)
                If
                    s >= 3600
                Then
                    Variable - Set h = (s / 3600)
                    Variable - Set s = (s mod 3600)
                    Variable - Set result = ((Text(h)) + " hour")
                    General - If (Conditions) then do (Actions) else do (Actions)
                        If
                            h > 1
                        Then
                            Variable - Set result = (result + "s")
                        Else
                Else
            General - If (Conditions) then do (Actions) else do (Actions)
                If
                    s >= 60
                Then
                    Variable - Set m = (s / 60)
                    Variable - Set s = (s mod 60)
                    General - If (Conditions) then do (Actions) else do (Actions)
                        If
                            h > 0
                        Then
                            General - If (Conditions) then do (Actions) else do (Actions)
                                If
                                    s > 0
                                Then
                                    Variable - Set result = (result + ", ")
                                Else
                                    Variable - Set result = (result + " and ")
                        Else
                    Variable - Set result = ((result + (Text(m))) + " minute")
                    General - If (Conditions) then do (Actions) else do (Actions)
                        If
                            m > 1
                        Then
                            Variable - Set result = (result + "s")
                        Else
                Else
            General - If (Conditions) then do (Actions) else do (Actions)
                If
                    Or
                        Conditions
                            h > 0
                            m > 0
                Then
                    Variable - Set result = (result + " and ")
                Else
            Variable - Set result = (result + ((Text(s)) + " second"))
            General - If (Conditions) then do (Actions) else do (Actions)
                If
                    s > 1
                Then
                    Variable - Set result = (result + "s")
                Else
            General - Return result
    

    I hope this might be of use for someone ;)

    Posted in: Trigger Libraries & Scripts
  • 0

    posted a message on How to make dialog box show certain value?

    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:

    Posted in: Triggers
  • 0

    posted a message on Convert UI coordinate to World

    Things that need to be considered are:

    • UI Coordinate
    • Screen resolution
    • Camera Target
    • Camera Distance
    • Camera FOV
    • Camera Pitch
    • Camera Yaw

    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)

    Posted in: Triggers
  • 0

    posted a message on Convert UI coordinate to World

    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.

    Posted in: Triggers
  • 0

    posted a message on Convert UI coordinate to World

    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?

    Posted in: Triggers
  • 0

    posted a message on How to make dialog box show certain value?

    Like this?

    Posted in: Triggers
  • 0

    posted a message on Dummy Spell (select unit)

    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:

    Editor - Editor Categories	Race:Terran,AbilityorEffectType:Units
    UI - Target Message	Select target
    Ability - Name	Possess
    Editor - Editor Suffix	
    Editor - Editor Prefix	
    Editor - Editor Description	
    Ability - Target Filters	(Required: Ground)
    Stats - Range	(5)
    Stats - Flags	Transient
    

    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 ;)

    Posted in: Data
  • To post a comment, please or register a new account.