• 0

    posted a message on Galaxy++ editor

    So much to do, so little time :( I got some less optional projects demanding time as well..

    The error server should be back up - sorry about that.

    @Slarti: Go

    The reason initializers are in one trigger pr initializer is the limit on the ammount of stuff that can be done in one trigger. With loops and stuff, I have no way of know how much stuff one initializer is doing. Putting them all into one trigger could reach the limit.

    @Kueken531: Go

    If you look at some generated dialog code, you will find a secret unannounced cast :)

    Foo* pFoo = ...;
    v = ##pFoo;//This will return an int if Foo is an array based pointer, and a string otherwise
    pFoo = #Foo*#v;//The other way
    

    I didn't add it to the documentation, or announce it in a changelog, because I kind of dislike it, but it is needed in some situations.

    Posted in: Third Party Tools
  • 0

    posted a message on Galaxy++ editor

    What is the difference between TruncI(fixed) and FixedToInt(fixed)?
    if you write int i = (int) f; it will insert a call to FixedToInt.
    I don't think I will create an implicit conversion from fixed to int, since as you say, we lose information.

    Posted in: Third Party Tools
  • 0

    posted a message on Unit gets within range of unit type

    When you add an event to a trigger, it is something which is done with a statment of it's own, in a method of its own. Therefore, if you try to refer to triggering unit from an event, it will in most cases (all GUI cases) make no sense. The events are added at one point, and then they are fixed. If any variables are used in the event, it will only be the value at the time the event is registered that counts. When you're in GUI, events are added at the start of the map.

    Anyway.. what you should do is make an event such as what you have done pr tower. Like so

    Events
            Unit - Any Unit Enters within 21.0 of (Position of Xel'Naga Tower [132.00, 127.00])
            Unit - Any Unit Enters within 21.0 of (Position of Xel'Naga Tower [121.00, 127.00])
            ...
    

    If you have a whole lot of towers, it is possible to make a bit of custom script code to add all the towers, but for pure GUI, that would be the approach.

    Posted in: Triggers
  • 0

    posted a message on Galaxy++ editor

    I still have no problems, if I add the code in an initializer along with your code. I did make an error in the code I posted previously though.. The array is not created.. The first statement should be

    PlayerData*[] test = new PlayerData*[2]();
    

    Maybe that is your problem too.

    Posted in: Third Party Tools
  • 0

    posted a message on Galaxy++ editor

    I might need more of your code than that. When I run the following script

    Trigger MeleeInitialization
    {
        events
        {
            TriggerAddEventMapInit(MeleeInitialization);
        }
        actions
        {
            PlayerData*[] test;
        
            test[0] = new PlayerData();
            test[1] = new PlayerData();    
            test[0]->heroLimit = 5;
            test[1]->heroLimit = 10;
            TriggerDebugOutput(1, StringToText(test[1]->heroLimit), true);
            TriggerDebugOutput(1, StringToText(test[0]->heroLimit), true);
        }
    }
    
    class PlayerData
    {
        int heroLimit;
    }
    

    It outputs 10, 5 as expected. Same thing if I declare PlayerData as a struct - though if you only use it in dynamic contexts, use classes.

    Also, you don't really need the StringToText calls.. As long as you didn't define an overload for the function that takes ints in second parameter, the compiler will convert it to text on its own.

    Posted in: Third Party Tools
  • 0

    posted a message on Galaxy++ editor

    Thx :)

    No, I don't really have a master plan as to what features are to come.. I kind of take it one step at the time. For next one, I'm adding reliable null pointer checks, nested namespaces, and probably some bugs because of all of this rewriting. I also think I'll allow sync/async invokes on more than just global methods.

    Posted in: Third Party Tools
  • 0

    posted a message on Galaxy++ editor

    Woo! Today it is one year since the first release of the editor. :)

    I had hoped to get next version out for today, but those nested namespaces requires a hell of a lot of rewriting..

    Posted in: Third Party Tools
  • 0

    posted a message on Galaxy++ editor

    You can't. There is no way for me to reliably send parameters to triggers when their event is fired, so It would be hard to tell the trigger what class object it is currently in. Therefore, triggers inside structs/classes are not possible. You could argue that it should still be possible with static methods, but it currently isn't.

    When I need something like that, I usually have a list of all allocated classes (Add to the list in the constructor, and remove from it in the deconstructor). Then I make a global trigger, that runs through each allocated object, and does what it needs to do. Like this

    using Collections
    
    Initializer
    {
        Test.Instances = new ArrayList<Test*>();
    }
    
    class Test
    {
        //I uploaded a library containing the arraylist
        static ArrayList<Test*>* Instances;
        
        int i;
        bool runTriggerOnMe;
        
        Test(int i, bool runTriggerOnThis)
        {
            Instances->Add(this);
            this->i = i;
            runTriggerOnMe = runTriggerOnThis;
        }
        
        ~Test()
        {
            Instances->Remove(this);
        }
    }
    
    Trigger TestTrigger
    {
        events
        {
            TriggerAddEventUnitStartedAttack(TestTrigger, null);
        }
        actions
        {
            int count = Test.Instances->Count;//No need to call this each iteration - unless you modify the collection
            for (int i = 0; i < count; i++)
            {
                Test* test = Test.Instances->Get(i);
                if (test->runTriggerOnMe)
                {
                    //Do stuff
                }
            }
        }
    }
    
    Posted in: Third Party Tools
  • 0

    posted a message on Galaxy++ editor

    Well.. yes, but it is because your variable is a pointer (although you have to make it a pointer when you use classes). You can make pointers to other stuff as well, and then you also have to use * or ->. Like

    void foo()
    {
        int* pVar = new int();
        *pVar = 2;
        bar(pVar);
        pVar->Print();
        delete pVar;
    }
    
    void bar(int* pInt)
    {
       *pInt = *pInt + 40;
    }
    
    enrich int
    {
        void Print()
        {
            UIDisplayMessage(PlayerGroupAll(), c_messageAreaSubtitle, this);
        }
    }
    

    This can be used when any modifications other methods make to your variable should be saved. When you run foo, 42 will be displayed on screen.

    Posted in: Third Party Tools
  • 0

    posted a message on Galaxy++ editor

    Your test variable is of the type Test*. This is a pointer to an object of type Test. Since it is a pointer, it is neither a struct nor a class. You have to follow the pointer and then do the .

    (*test).Add = 1;
    

    Another way of writing the exact same thing is

    test->Add = 1;
    

    You could have enriched Test*, so that test.Add makes sense.

    enrich Test*
    {
        int Add
        {
            set
            {
                this->Add = value + 2;
            }
        }
    }
    

    That is why it is telling you it has to be a struct, class or something which is enriched.

    Posted in: Third Party Tools
  • 0

    posted a message on Galaxy++ editor

    Void is not a valid type for a property. I assume you mean it to be int in this case. Also, in a class, the this keyword will be a pointer to the current object. Sho you should use this->i instead of this.i.
    Actually, you don't even need to write this, since you don't have any conflicting local variables, you can just write i instead of this->i.

    class Test {
        public int i = 0;
        public Test (int n) {
            i = n;
        }
        
        public int Add {
            set {
            i = i + value;
            }
        }
        
        public string Print {
            get {
                return IntToString(i);
            }
        }
    }
    
    Posted in: Third Party Tools
  • 0

    posted a message on Bank files

    Save the time each player has played a hero into an array variable, then run through the variable, get the max index, and get the hero based on that index...
    Something like

    Untitled Trigger 001
        Events
        Local Variables
            P = 0 <Integer>
        Conditions
        Actions
            General - For each integer P from 1 to 12 with increment 1, do (Actions)
                Actions
                    int[HeroCount] Arr:
                    Arr[0] = Akery[P];
                    Arr[1] = Darosa[P];
                    ...
                    int biggestIndex = 0;
                    for (int i = 1; i < heroCount; i++)
                        if (Arr[i] > Arr[biggestIndex])
                            biggestIndex = i;
                    switch (biggestIndex)
                    {
                        case 0:
                            //Do stuff for Akery..
                            break;
                        case 1:
                            //Do stuff for Darosa
                            break;
                        ....
                    }
    

    I apolagize for the galaxy++ code.. I can't be bothered to convert it to GUI atm. I hope you get what I mean anyway..

    Posted in: Triggers
  • 0

    posted a message on Galaxy++ editor

    Actually, as it is, you can write

    namespace Foo
    struct Bar
    {
        static int Derp;
    }
    

    To get your Foo.Bar.Derp.

    Anyway.. it seems weird to me to use a struct just to get a naming prefix - that seems to be the function of namespaces, so I think something like c# style namespaces might be better

    namespace Foo
    {
        namespace Bar
        {
            static int Derp;
        }
    }
    
    Posted in: Third Party Tools
  • 0

    posted a message on Galaxy++ editor
    Quote from Mexaprone: Go

    As it is now, the implementation of: struct Foo { struct Bar { static int Derp = 0; } }

    Could easily be converted to Foo_Bar_Derp when compiled, instead of:

    struct Foo { Bar bar; }

    struct Bar { static int Derp; }

    Not only does that create less readable code, but also a longer time to write the code, and would be compiled differently (would it not? Assuming we talk about no level of optimization right now)?

    I'm not sure I follow your point here. As it is now, you can't nest structs/classes. Also, in the second code you would not be able to use foo.bar.Derp, since Derp is a static variable, and must be used with Bar.Derp (or, in next version, with Derp from inside Bar).

    Posted in: Third Party Tools
  • 0

    posted a message on Galaxy++ editor

    Nested namespaces and structs/classes.. Well, it is certainly possible to implement, but it would take a lot of time to do, and it is really only a convenience. I think I will prioritize other features for now, such as being able to do reliable null checks for pointers. But progress on that is slow at the moment due to a school project.

    Dahm. I'm very sorry about breaking your code.. That change was a mistake, and I will fix it for the next update.

    I'll also make it possible to copy errors as text with ctrl c.

    Posted in: Third Party Tools
  • To post a comment, please or register a new account.