RPTools.net

Discussion and Support

Skip to content

It is currently Fri Feb 23, 2018 1:43 pm 




Forum rules


PLEASE don't post images of your entire desktop, attach entire campaign files when only a single file is needed, or generally act in some other anti-social behavior. :)



Reply to topic  [ 3 posts ] 

Previous topic | Next topic 

  Print view

Author Message
User avatar  Offline
Giant
 
Joined: Mon Feb 16, 2009 7:12 pm
Posts: 243
 Post subject: Modifying a variable variable
PostPosted: Sat Jan 20, 2018 2:59 pm 
This seems like it should be simple, but I'll be darned if I can figure out how. I'm looking for a way to handle doing a variable assignment for a variable that is, itself, variable. Here's a quick and dirty example:

Code:
[h: Strength = 10]
[h: statName = "Strength"]

The goal is to set the Strength variable to 20 instead, but only by referring to the value stored on statName (so that, for example, one could swap in the name of a different variable as needed).

Obviously, doing [statName = 20] will just change the statName variable. [eval(statName) = 20] gets a little closer, as it actually returns the value of the variable named in statName, but it doesn't assign anything - it just returns 10, seemingly ignoring the equals sign and so forth. I feel like there's got to be a way to do this, and it's something simple enough. (I'm a little surprised that eval(statName) returns 10 and not "Strength".) Any thoughts on what I'm missing here, please?

_________________
I made a framework for Exalted 2.5E.


Top
 Profile  
 
User avatar  Offline
Deity
 
Joined: Tue Nov 10, 2009 6:11 pm
Posts: 8012
Location: Bay Area
 Post subject: Re: Modifying a variable variable
PostPosted: Sat Jan 20, 2018 3:13 pm 
You can use Wiki: set() or Wiki: setProperty().

_________________
Downloads:


Top
 Profile  
 
User avatar  Offline
Giant
 
Joined: Mon Feb 16, 2009 7:12 pm
Posts: 243
 Post subject: Re: Modifying a variable variable
PostPosted: Sat Jan 20, 2018 3:20 pm 
aliasmask wrote:

Well I'll be a monkey's uncle! I knew there had to be some kind of simple function for this. Added to the above example code, [set(statName, 20)] does indeed set the Strength variable to 20. I'm more than a bit surprised. I thought, without special modification, that something like that would have set 20 as the value of statName, rather than the value of the variable whose name it contains. But it works! Thank you!

_________________
I made a framework for Exalted 2.5E.


Top
 Profile  
 
Display posts from previous:  Sort by  
Reply to topic  [ 3 posts ] 

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:

Who is online

In total there are 3 users online :: 0 registered, 0 hidden and 3 guests (based on users active over the past 5 minutes)
Most users ever online was 243 on Sun Nov 04, 2012 6:14 am

Users browsing this forum: No registered users and 3 guests





Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group

Style based on Andreas08 by Andreas Viklund

Style by Elizabeth Shulman