Author Topic: Problems creating a dynamic variable  (Read 2398 times)

0 Members and 1 Guest are viewing this topic.

Offline slyoneTopic starter

  • Full Member
  • ***
  • Posts: 135
  • Activity:
    0%
  • Reputation Power: 2
  • slyone has no influence.
  • Gender: Male
  • Respect: +40
  • Referrals: 1
    • View Profile
Problems creating a dynamic variable
« on: February 18, 2012, 06:41:27 AM »
0
I'm trying to create a variable name dynamically.  The test code I am using is below:

Code: [Select]
set %var1 10
set %var2 string

set % , %var1 , %var2 XXXXX

display % , %var1 , %var2
halt

I want the variable to be "%10string" and to have a value of XXXXX.  But when I use the display command it shows the string %10string rather than the value XXXXX. 

Can anyone help?
Started playing back at the Second Age

Offline TrailMyx

  • Officially retired from UO
  • Administrator
  • *
  • *
  • Posts: 13302
  • Activity:
    0.2%
  • Reputation Power: 154
  • TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!
  • Gender: Male
  • Viper!
  • Respect: +1349
  • Referrals: 33
    • View Profile
    • ScriptUO
Re: Problems creating a dynamic variable
« Reply #1 on: February 18, 2012, 09:27:34 AM »
0
You have to use a combination of the dot operator and the concatenation operator.

Code: [Select]
set %var1 10
set %var2 string

set % . %var1 , %var2 Worked

display %10string
halt
Please read the ScriptUO site RULES
Come play RIFT with me!

Offline manwinc

  • Elite
  • *
  • *
  • Posts: 2556
  • Activity:
    0%
  • Reputation Power: 32
  • manwinc is a rising star!manwinc is a rising star!manwinc is a rising star!manwinc is a rising star!manwinc is a rising star!manwinc is a rising star!
  • Gender: Male
  • "The Devs Hard at Work"
  • Respect: +123
  • Referrals: 1
    • View Profile
Re: Problems creating a dynamic variable
« Reply #2 on: February 18, 2012, 09:41:26 AM »
0
For what you are doing, you would need to use an intermediate step in order to Extract the Data from your Dynamic Variable.

Code: [Select]
set %Var1 10
set %Var2 String
set %Temp %Var1 , %Var2
set % , %Temp Worked
display % . %Temp
Halt

The Easiest way to get around this is just to Bypass the Var2.

Code: [Select]
set %Var1 10
set %String , %Var1 Worked
Display %String . %Var1
halt

Once you get the Hang of it, its not Tooo Bad.

Monkeys and Typewriters!

" Oh I know, We'll make a Boss Encounter that requires 3 keys per player to enter, Then we'll make it not a closed instance so you never know if you are going to pop into a fresh room or a boss that has 1% Health left with 20 dudes smashing its face in, wasting your time and effort"

Offline slyoneTopic starter

  • Full Member
  • ***
  • Posts: 135
  • Activity:
    0%
  • Reputation Power: 2
  • slyone has no influence.
  • Gender: Male
  • Respect: +40
  • Referrals: 1
    • View Profile
Re: Problems creating a dynamic variable
« Reply #3 on: February 18, 2012, 10:42:04 AM »
0
You have to use a combination of the dot operator and the concatenation operator.

Code: [Select]
set %var1 10
set %var2 string

set % . %var1 , %var2 Worked

display %10string
halt

For what you are doing, you would need to use an intermediate step in order to Extract the Data from your Dynamic Variable.

Code: [Select]
set %Var1 10
set %Var2 String
set %Temp %Var1 , %Var2
set % , %Temp Worked
display % . %Temp
Halt

The Easiest way to get around this is just to Bypass the Var2.

Code: [Select]
set %Var1 10
set %String , %Var1 Worked
Display %String . %Var1
halt

Once you get the Hang of it, its not Tooo Bad.



Thank you!!
Started playing back at the Second Age

Tags: concatenation