Jump to content


Vilvake

Member Since 01 Jul 2011
Offline Last Active May 09 2012 11:11 PM

Posts I've Made

In Topic: Menu position depending on location

14 April 2012 - 04:53 AM

Well the building is an object, right? So you would put the code in the mouse click event within the building object:

if (y < height_of_popup)
{
  //make menu lower
}
else
{
  //make menu normal height
}


duh, I need to use my head. Thanks!

In Topic: Menu position depending on location

14 April 2012 - 04:48 AM

So how would I exactly do that...
if (the buildings y value) < (height of popup menu){
whatever
}

what do I put where (the buildings y value) is? how do I check that?

sorry by the way, still new to all this

In Topic: Problem upgrading buildings

13 April 2012 - 09:11 PM


How about trying to use else if instead of a new block of if statement?


That seems to work for all buildings except my castle. I have tried coding it a hundred different ways, but I can't find my mistake! It either will go to level 2 or 3, seemingly randomly.

click event for obj_upgrade
switch(global.castlelvl){

    case 1: 
    if global.wood >= 500{
        global.wood -= 500;
            global.castlelvl = 2;
                global.buildslots += 5;
                    break;               
    }
    
    case 2:
    if global.wood >= 1000{
        if global.stone >= 1500{
            global.wood -= 1000;
                global.stone -=1500;
                    global.castlelvl = 3;
                        global.buildslots += 5;
                            break;
        }
}

    case 3:
    if global.wood >=4500{
        if global.stone >= 5000{
            global.wood -= 4500
                global.stone -= 5000;
                    global.castlelvl = 4;
                        global.buildslots += 5;
                            break;
            }
}

    case 4:
    if global.wood >= 9500{
        if global.stone >= 10000{
            global.wood -= 9500
                global.stone -= 10000;
                    global.castlelvl = 5;
                        global.buildslots += 5;
                            break;
            }
}

else

{

break

}

}




Try coding it like this:

Try using the "and" statement .. I notice how in case one the expression is if global.wood is greater than or equal to 5000 which also means it is a case 2 .. Make it so that it says if global.wood is greater than or equal to 5000 AND less than 10000.


Alright, thanks for that, I fixed the problem by limiting the amount of resources you can hold per castle level. Now I have another problem....

For my resource buildings at the top of the room, if you click them, half of their pop up menu goes outside the room and is unusable. How do I make it so that if the menu object is created partially or completely outside the room, it will instead be created below the building instead of above?

In Topic: Problem upgrading buildings

13 April 2012 - 06:37 PM

How about trying to use else if instead of a new block of if statement?


That seems to work for all buildings except my castle. I have tried coding it a hundred different ways, but I can't find my mistake! It either will go to level 2 or 3, seemingly randomly.

click event for obj_upgrade
switch(global.castlelvl){

    case 1: 
    if global.wood >= 500{
        global.wood -= 500;
            global.castlelvl = 2;
                global.buildslots += 5;
                    break;               
    }
    
    case 2:
    if global.wood >= 1000{
        if global.stone >= 1500{
            global.wood -= 1000;
                global.stone -=1500;
                    global.castlelvl = 3;
                        global.buildslots += 5;
                            break;
        }
}

    case 3:
    if global.wood >=4500{
        if global.stone >= 5000{
            global.wood -= 4500
                global.stone -= 5000;
                    global.castlelvl = 4;
                        global.buildslots += 5;
                            break;
            }
}

    case 4:
    if global.wood >= 9500{
        if global.stone >= 10000{
            global.wood -= 9500
                global.stone -= 10000;
                    global.castlelvl = 5;
                        global.buildslots += 5;
                            break;
            }
}

else

{

break

}

}




In Topic: Checking last clicked single instance

12 April 2012 - 04:40 PM

Thanks for the help everyone! Everything is working properly now.

edit- Just came across a problem! If I have enough resources to upgrade the woodcutter more than once, sometimes it will with a single click!
example- the woocutter is lvl 1 and I hit upgrade. Sometimes it will jump to lvl 3 or 4 immediately. I'm guessing this is probably an easy fix...

click event for obj_upgrade
if global.wood >= 100{
    with global.lastclicked{
        if lvl = 1{
            lvl += 1;
                global.wood -= 100;
    }
  }
}

if global.wood >= 200{
    with global.lastclicked{
        if lvl = 2{
            lvl += 1;
                global.wood -= 200;
    }
  }
}

if global.wood >= 300{
    with global.lastclicked{
        if lvl = 3{
            lvl += 1;
                global.wood -= 300;
    }
  }
}