Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
Chubzdoomer

Variables question

Recommended Posts

Is it not possible to perform calculations and store the results in a variable? I can't for the life of me figure out how to do it.

For example, let's say I have two variables: Experience, and Level 2 Experience (the experience required to reach level 2).

What if I wanted to create a third variable, Experience Remaining, and set it to the result of "Level 2 Experience - Experience"? That would be really useful since I could then display Experience Remaining on the HUD to show players exactly how much experience they needed to reach level 2.

Something like this is trivial in ACS or any scripting/programming language for that matter, but SnapMap either makes it stupidly complicated to set up or doesn't allow for it at all. I'm hoping it isn't the latter, but given the program's other ridiculous limitations it sure wouldn't surprise me.

Share this post


Link to post

I'd be surprised if you can efficiently program regular expressions with snapmap. I'd suggest instead that you have one variable ("experience") which you increment by a "hard-coded" amount on every monster kill (or whatever), and after you increment, you also check if the value of "experience" exceeds another "hard-coded" amount before you then proceed to do a "level up" action.

If you want an "experience remaining" counter, just decrement it by the same amount that you increment the "experience" counter.

But you know, you're always free to experiment and find a better solution. I've been surprised by a few things people have managed to do with snapmap.

Share this post


Link to post
sheridan said:

I'd be surprised if you can efficiently program regular expressions with snapmap. I'd suggest instead that you have one variable ("experience") which you increment by a "hard-coded" amount on every monster kill (or whatever), and after you increment, you also check if the value of "experience" exceeds another "hard-coded" amount before you then proceed to do a "level up" action.


Yeah, that's the method I'm using right now and it works fine. It just sucks that you can't set variables to the result of calculations performed on other variables. I think I'm just trying to push SnapMap a bit too far. It clearly isn't meant to reach that level of complexity (in regards to variable operations) which is a bit of a bummer but, again, not entirely shocking given its many other limitations.

Share this post


Link to post
chubz said:

What if I wanted to create a third variable, Experience Remaining, and set it to the result of "Level 2 Experience - Experience"?


You can, just take whatever activator you need (like for example "on resource spent", "on variable changed" and that kind of stuff) and make 2 connections to the "Experience Remaining" variable, one being "set" using "Level 2 Experience" as value (press ctrl+x when hovering on that property) and the other being "minus" using "Experience" (and you may even want to set a 0.1s delay on it).

Share this post


Link to post
ArchCrusader said:

You can, just take whatever activator you need (like for example "on resource spent", "on variable changed" and that kind of stuff) and make 2 connections to the "Experience Remaining" variable, one being "set" using "Level 2 Experience" as value (press ctrl+x when hovering on that property) and the other being "minus" using "Experience" (and you may even want to set a 0.1s delay on it).


Despite being a bit of a sloppy workaround, that does work--to a point. The issue is that since the variable is being set, THEN subtracted, if you display it on the HUD at all times (like I'm wanting to do), it constantly flickers between the value it's initially set to and the amount it becomes once it's subtracted.

Ultimately, I'm afraid there just isn't any kind of a viable, elegant solution to this simple problem. I do appreciate your help, though.

EDIT: Just for the hell of it I removed the 0.1-second input delay from "subtract" and that seems to have fixed everything! I figured not having the delay would screw things up, but the correct value is being shown and there's no flickering what-so-ever. Hooray!

Share this post


Link to post

That's actually pretty neat, I figured the 0.1s delay would have prevented some screwups but I didn't take in account the fact that when I used it the variable had a lower limit (as in it could not go lower than 0).
Glad to have been of help!

Share this post


Link to post

Variables can be calculated and assigned on the fly. The devil is in the detail. Create a branch from the node you want the calculation to fire from, point it to your variable, choose the type of calculation (addition, subtraction, multiplication etc) and you're set. No need to "Set" values. The output of the calculation will change the value of the variable it's linked to automatically.

You can even change to value in the calculation node to a variable, which paves the way for things like a scaling experience points systems, or scaling demon difficulty. I've used this method extensively for exactly this purpose in the map I'm creating.

Hope that makes sense. I'm not in front of my computer atm but can provide an example later if required.

Also worth mentioning that the order in which you connect events to a node determines when they get executed. For example, say you had a Module->On Entered node with 2 branches hanging off it: one branch adds 1000xp to an xp variable and the other branch gives the xp to the player proxy. If you connected the "give xp to player" to the On Entered node first, then connected the "increase xp value" second, it would give the player xp then increase the xp value. If your XP value starts off at zero, you'd give the player zero xp.

All you'd need to do to fix that is delete the line connections to the On Entered node, then connect the "increase xp" branch first, then connect the "give player xp" branch second. You can have a whole bunch of stuff fire in sequential order without needing to perform nasty logic checks or time delays just by connecting them in the order you want them to process.

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×