#XP & Level up scripting for FORGE system

1 messages ยท Page 1 of 1 (latest)

meager surge
#

Good day, evening or night, hope you're doing okay, i'm writting this because i could really use a hand, i'm quite inexperienced at programming, and i'm trying to make a script that not only grants XP to a token, but also levels up and changes the XP needed to level up.

As the title already points it out, i'm trying to make a scrip for the FORGE system.

#
"XPAmount|0|Insert XP Amount|TEXT|WIDTH=6")]
[h:abort(status)]

[h:Experience = Experience + XPAmount]
[r:token.name] obtains [r:XPAmount] XP.<br>

[if:(Level < 7) || (Level > 8), CODE:
{
    [h:NextLevel = NextLevel * 2]
};
{
    [h:NextLevel = 125000]
}]```
tidal lotus
#

change this [if:(Level < 7) || (Level > 8), CODE:
to this: [if(Level < 7 || Level > 8), CODE:

meager surge
#

As you can see here, after level 7 the XP required changes and then it multiplies by 2 again

#

so i'm trying to look for a way to set it to THAT number

tidal lotus
#

I would do it this way then

    [h:NextLevel = 125000]
};{
    [h:NextLevel = NextLevel * 2]
}]```
meager surge
#

OH

#

that's more practical, thanks!

#

also i forgot to add [h: Level = Level + 1]

#

Here's the final result

tidal lotus
#

I think I need more information.

Do you want an input that takes that numeric value, compares that to your level / xp grid, and then if you cross a value in the grid, to level up?

Right now, I'm not seeing any check against the grid so when your posted code is run, so long as the input is 1 xp, they'll level up.

meager surge
#

This is how level up works in FORGE

#

however i'm just automatizing the level up

#

i'm not doing anything at Melek's level

tidal lotus
#

Ok, but to do what you're wanting, you need to compare values and conditionally increase them.
Also, at no point does level 8 mean 125000 exp. I'd understand your rule to mean, the moment I reach or breach 125,000, I hit level 8. If I go from 124,999 to 130,000, level 9 is not 250000 exp away

#

Meaning you'll need to have some more logic checks, and need to compare to the grid, check the input value against current exp, add them, if a level exp value is breached, then you level up.

meager surge
#

I just realized level 7 requires 64k XP

meager surge
tidal lotus
#

64 is still 2x32 (level 6), It looks like the only odd jump is level 8.

No, you can do what you want to do but it's more than what you shared ๐Ÿ™‚

#

You need to store level up information in a JSON, string, list, table.
Read those values against the calculated XP (current XP plus input).
Take that total and check the json,string,list,table values and if you breach one, then level up ๐Ÿ™‚

meager surge
#

Uh

#

i have no idea what you said

#

the last part i mean

#

I'm just getting to the point where i just make a script to manually input the amount and call it a day, it's been painful

tidal lotus
#

You're already doing the easy part, you could even do a bunch of if statements
eg. [h, if(Experience > 2000): Level = 2]
[h, if(Experiernce > 4000): Level = 3]
etc

meager surge
#

i tried to do a bunch of statements

#

it prints the code for some reason

#

Too bad i don't have the code

tidal lotus
#

use [h, if and you'll be good ๐Ÿ™‚

meager surge
#

ah

#

well okay, thank you

tidal lotus
#
[h, if(Experience>=2000): Level = 2]
[h, if(Experience>=4000): Level = 3]
[h, if(Experience>=8000): Level = 4]
[h, if(Experience>=16000): Level = 5]
[h, if(Experience>=32000): Level = 6]
[h, if(Experience>=64000): Level = 7]
[h, if(Experience>=125000): Level = 8]
[h, if(Experience>=250000): Level = 9]
[h, if(Experience>=500000): Level = 10]```
meager surge
#

oh, yeah, i was doing exactly that, but got hungry, and now i see this, thanks a lot man

tidal lotus
#
[h:abort(status)]

[h:Experience = Experience + XPAmount]
[r:token.name] obtains [r:XPAmount] XP.<br>
[h: currentLevel = Level]
[h, if(Experience<2000): Level = 1]
[h, if(Experience>=2000): Level = 2]
[h, if(Experience>=4000): Level = 3]
[h, if(Experience>=8000): Level = 4]
[h, if(Experience>=16000): Level = 5]
[h, if(Experience>=32000): Level = 6]
[h, if(Experience>=64000): Level = 7]
[h, if(Experience>=125000): Level = 8]
[h, if(Experience>=250000): Level = 9]
[h, if(Experience>=500000): Level = 10]
[r, if(currentLevel != Level): token.name has Leveled UP !!```
That should be *good*
meager surge
#

Again, thank you so much for helping me ๐Ÿ™

#

there's also a doubt i have, but i better make another post about it

prisma vessel
solar bloom
# prisma vessel Or even `[h:NextLevel=if(Level==8, 125000, NextLevel*2)]`

I've noticed looking at code for random drop-ins (and even some pages on the wiki) that there are different formats used for the conditionals.

I'm wondering if maybe one resembles standard java code more, or what else might lead to a preference of one format vs. the other:

[h, if(Level==8): NextLevel = 125000; NextLevel = NextLevel * 2]

vs.

[h:NextLevel=if(Level==8, 125000, NextLevel*2)]

Although I'm not nearly as familiar with the format, I -do- like how the second version avoids an additional use of the variable name. Not sure if this would result in an (ultra tiny?) processing speed boost versus the other format.

prisma vessel
#

Yeah I like it b/c it's a bit more terse but not in a way that makes it less clear. Also the second version is slightly older in Maptool, the first version is a roll option that was added later (although both a very long time ago now)

#

The nice thing about the second one is that you can embed it inside conditional branches and it doesn't violate the rules on nested if statements

meager surge
#

Again, i don't have much experience in macro writting or coding

#

so i don't exactly know what to do

tidal lotus
#

You can use either one, both load an execute the same in the source code. As Ao mentioned, there are good reason to use one over the other but you'd never be able to settle only using one ๐Ÿ™‚

meager surge
tidal lotus