• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Problema adressing variables from other obj

W

Warianos

Guest
Hey guys, im trying to make a script that earns exp and tests if is is enought to lvl up 1 or more times if the exp is way larger.

//EarnExp(exp)

exp0 = argument0;
level = obj_player.actualLevel;
actualExp = obj_player.actualExp + exp0;
expMax = obj_player.expMax;
while(actualExp >= expMax){
expMax = round(level*log10(level)*10 + 10);
playerLevel +=1;
actualExp -=expMax;
}

The problem is that obj_player.variable isn´t working... i would like to know a way to make this possible to change players Create variables from different sources like mob killing, exploration, quests etc.

Thanks guys


It was a typo, sorry guys, and thanks
 
Last edited by a moderator:
M

MissCheeseDanish

Guest
Where's playerLevel set? Did you mean obj_player.actualLevel?
And is there a specific line where obj_player.variable isn't working?
Also, maybe rearrange the lines within the while statement? Because right now you have it so actualExp equals actualExp minus the new value of expMax, and that might cause you some problems in the future.


Try this out:
Code:
// Level up

exp0 = argument0;
obj_player.actualExp += exp0;
if (obj_player.actualExp >= obj_player.expMax) {
    obj_player.actualLevel += 1;
    obj_player.actualExp-= obj_player.expMax;
    obj_player.expMax= round(obj_player.actualLevel*log10(obj_player.actualLevel)10 + 10);
}
 
W

Warianos

Guest
Where's playerLevel set? Did you mean obj_player.actualLevel?
And is there a specific line where obj_player.variable isn't working?
Also, maybe rearrange the lines within the while statement? Because right now you have it so actualExp equals actualExp minus the new value of expMax, and that might cause you some problems in the future.


Try this out:
Code:
// Level up

exp0 = argument0;
obj_player.actualExp += exp0;
if (obj_player.actualExp >= obj_player.expMax) {
    obj_player.actualLevel += 1;
    obj_player.actualExp-= obj_player.expMax;
    obj_player.expMax= round(obj_player.actualLevel*log10(obj_player.actualLevel)10 + 10);
}
thanks for the reply! thats a good idea :) It works now
 
Top