• 0

    posted a message on Resource Counting

    Thank you for your assistance, that will actually work quite nicely. I've realized since then how ridiculous it was for me to spending so much time on something that had little impact on the game. I guess the reason I was even asking this question is more of how to solve this problem for the sake of learning rather than needing the problem fixed. Thank you for pointing out that habit as well. I'm not sure why I started doing that.

    Posted in: Triggers
  • 0

    posted a message on Resource Counting

    Dialog Updater
        Options: Action, Create Thread
        Return Type: (None)
        Parameters
            Player = 0 <Integer>
        Grammar Text: Dialog Updater(Player)
        Hint Text: (None)
        Custom Script Code
        Local Variables
            i = 0 <Integer>
            Movement Number = 0 <Integer>
            Time = 0.001 <Real>
            Update Frequency = 0.0 <Real>
            Should Be = (("ActualMinerals" + (String(Player))) from the Global data table) <Integer>
            Shown = (("MineralsShown" + (String(Player))) from the Global data table) <Integer>
        Actions
            General - If (Conditions) then do multiple (Actions)
                If Then Else
                    General - Else if (Conditions) then do (Actions)
                        Else If
                            ("Mutex" from the Global data table) == false
                        Then
                            Data Table - Save true as "Mutex" in the Global data table
                    General - Else if (Conditions) then do (Actions)
                        Else If
                            ("Mutex" from the Global data table) == true
                        Then
                            General - Skip remaining actions
            Variable - Set Movement Number = (Should Be - Shown)
            General - If (Conditions) then do multiple (Actions)
                If Then Else
                    General - Else if (Conditions) then do (Actions)
                        Else If
                            Movement Number != 0
                        Then
                            Variable - Set Update Frequency = (Time / (Real((Abs(Movement Number)))))
            General - While (Conditions) are true, do (Actions)
                Conditions
                    Movement Number > 0
                Actions
                    Data Table - Save ((("MineralsShown" + (String(Player))) from the Global data table) + 1) as ("MineralsShown" + (String(Player))) in the Global data table
                    Dialog - Set (("Minerals" + (String(Player))) from the Global data table) text to (Text((("MineralsShown" + (String(Player))) from the Global data table))) for (All players)
                    Variable - Set Movement Number = ((("ActualMinerals" + (String(Player))) from the Global data table) - (("MineralsShown" + (String(Player))) from the Global data table))
                    General - If (Conditions) then do multiple (Actions)
                        If Then Else
                            General - Else if (Conditions) then do (Actions)
                                Else If
                                    Movement Number != 0
                                Then
                                    Variable - Set Update Frequency = (Time / (Real((Abs(Movement Number)))))
                    General - Wait Update Frequency Game Time seconds
            General - While (Conditions) are true, do (Actions)
                Conditions
                    Movement Number < 0
                Actions
                    Data Table - Save ((("MineralsShown" + (String(Player))) from the Global data table) - 1) as ("MineralsShown" + (String(Player))) in the Global data table
                    Dialog - Set (("Minerals" + (String(Player))) from the Global data table) text to (Text((("MineralsShown" + (String(Player))) from the Global data table))) for (All players)
                    Variable - Set Movement Number = ((("ActualMinerals" + (String(Player))) from the Global data table) - (("MineralsShown" + (String(Player))) from the Global data table))
                    General - If (Conditions) then do multiple (Actions)
                        If Then Else
                            General - Else if (Conditions) then do (Actions)
                                Else If
                                    Movement Number != 0
                                Then
                                    Variable - Set Update Frequency = (Time / (Real((Abs(Movement Number)))))
                    General - Wait Update Frequency Game Time seconds
            Data Table - Save false as "Mutex" in the Global data table

    I'm not exactly sure how to post the code so that it's formatted nicely, sorry... "Minerals" is the name of the dialog label that shows the minerals. "ActualMinerals" is the number of minerals the player has and "MineralsShown" is the number of minerals that is shown on the label. The reason I need such a small wait is: as the Movement Number (or change in minerals) gets larger, the wait should get smaller in order to increase the update frequency. That way a deposit of 5 minerals will take the same amount of time to show as a withdrawal of 300. This way of going about it seems extremely inefficient, so I'm definitely open to another idea.

    Posted in: Triggers
  • 0

    posted a message on Resource Counting

    Today I was working on a Team Melee map. In an effort to overcome a problem where the resources/supply couldn't be seen by other team members, I decided to create my own resource panel through the usage of dialog functions.

    I'm stuck trying to make the mineral/gas count increment or decrement to the total. I created function that would take .001 seconds and then divide that by the change in resources that needed to occur. I used that number in a wait function contained in a loop that would add one to the dialog box label. This made it to where large transactions of resources would take the same amount of time to reach the total as the small ones. The overall affect was nice, except when the change in resources got too large. The number would be too small for the wait function (it bottoms out after .0001 seconds). Is there a function that takes care of this already, or another wait function that deals with smaller intervals of times?

    I realize that my approach isn't the most elegant, but I can't really think of another way. It's not really a big deal, I could have the number of resources just be displayed, but I would like to be able to replicate the original panel. Any help would be much appreciated.

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