RPTools.net

Discussion and Support

Skip to content

It is currently Sat May 18, 2013 10:36 pm 






Reply to topic  [ 7 posts ] 

Previous topic | Next topic 

  Print view

Author Message
User avatar  Offline
Dragon
 
Joined: Sat Feb 13, 2010 2:35 am
Posts: 965
Location: California
 Post subject: Trying to understand why a token property is changing.
PostPosted: Sun Apr 29, 2012 1:11 am 
I'm trying to create an input that will set a property on a token that has the languages known by the player.
So the input and subsequent if statements set the correct languages picked. But in order to get the current languages set then I need to use a getProperty statement but when I do it returns all of the languages separated by ##. I can't figure this. Any thoughts?

Here is the code

Code:
[h: fail = input(
      "Abyssal|0|Abyssal|CHECK",
      "Common|0|Common|CHECK",
      "DeepSpeech|0|Deep Speech|CHECK",
      "Draconic|0|Draconic|CHECK",
      "Dwarven|0|Dwarven|CHECK",
      "Elven|0|Elven|CHECK",
      "Giant|0|Giant|CHECK",
      "Goblin|0|Goblin|CHECK",
      "Primordial|0|Primordial|CHECK",
      "Supernal|0|Supernal|CHECK"
      )]
[h: abort(fail)]

[h: tlanguage = getProperty("Languages")]
    [h, if(Abyssal==1): tlanguage = listAppend(tlanguage, "Abyssal")]
   [h, if(Common==1): tlanguage = listAppend(tlanguage, "Common")]
   [h, if(DeepSpeech==1): tlanguage = listAppend(tlanguage, "DeepSpeech")]
   [h, if(Draconic==1): tlanguage = listAppend(tlanguage, "Draconic")]
   [h, if(Dwarven==1): tlanguage = listAppend(tlanguage, "Dwarven")]
   [h, if(Elven==1): tlanguage = listAppend(tlanguage, "Elven")]
   [h, if(Giant==1): tlanguage = listAppend(tlanguage, "Giant")]
   [h, if(Goblin==1): tlanguage = listAppend(tlanguage, "Goblin")]
   [h, if(Primordial==1): tlanguage = listAppend(tlanguage, "Primordial")]
   [h, if(Supernal==1): tlanguage = listAppend(tlanguage, "Supernal")]
[h: setProperty("Languages", tlanguage)]
[r: tlanguage]


If I select Abyssal and common then the token property ends up looking like this

Code:
Abyssal=1 ## Common=1 ## DeepSpeech=0 ## Draconic=0 ## Dwarven=0 ## Elven=0 ## Giant=0 ## Goblin=0 ## Primordial=0 ## Supernal=0 ##, Abyssal, Common

_________________
DCI/RPGA# 7208328396 Skype ID mfrizzell77
Characters:
Strabor - Dwarf Avenger 5th Level
Tikkanan - Human Warlock 2nd Level
----------------------------------------------------
"People are more violently opposed to fur than leather because it's safer to harass rich women than motorcycle gangs."


Top
 Profile  
 
User avatar  Offline
Deity
 
Joined: Tue Nov 10, 2009 6:11 pm
Posts: 5300
Location: Bay Area
 Post subject: Re: Trying to understand why a token property is changing.
PostPosted: Sun Apr 29, 2012 2:24 am 
The first part is what you have in your "Languages" property before you append to it. Unless you're going to pre-check already selected languages, then you don't need to get Languages. Also, using list append will create duplicates anyway. Just set tlanguage = "".

_________________
Downloads:


Top
 Profile  
 
User avatar  Offline
Deity
 
Joined: Fri Mar 20, 2009 4:40 am
Posts: 5488
Location: Netherlands
 Post subject: Re: Trying to understand why a token property is changing.
PostPosted: Sun Apr 29, 2012 5:57 am 
aliasmask wrote:
The first part is what you have in your "Languages" property before you append to it. Unless you're going to pre-check already selected languages, then you don't need to get Languages. Also, using list append will create duplicates anyway. Just set tlanguage = "".


yup, it looks like the tlanguage is not initialized in which case you either get an error or '[really weird stuff], added listitems'. In addition, your macro will fail on more accounts, for one, its impossible to 'unselect' a chosen language also if you have selected 3 languages before you need to check them again.
Its better to change this
Code:
 "Abyssal|0|Abyssal|CHECK",

into this
Code:
 "Abyssal|"+Abyssal+"|Abyssal|CHECK",

where 'Abyssal' is set to 0 or 1 before you run the input. This can be done with e.g.
Code:
[allLanguages = "Abyssal, Common, etc"]
[foreach(language, allLanguages):set(language, if(listContains(tlanguage , language),1,0))]
[tlanguage = ""]
input()... etc.
UNTESTED
Note that tLanguage needs to be properly set BEFORE you use this, so first check whether 'Languages' on the token contains correct values.

_________________
My stuff
Excel Tools: Table editor and Illumination Generator
MT Tools: Dungeon Builder Tool, Bag of Tricks: Teleport pads, Pits, Traps and Warded Areas and onMouseOverEvent
Framework: Dark Heresy, Rogue Trader, Deathwatch, Black Crusade and Only War
Wiki: Debugging Tutorial, Speed Up Your Macros, Working With Two CODE Levels, Shortcut Keys, Avoiding Stack Overflow

My dropbox referral. If you use this then both you and me get 500Mb extra space. 2.5Gb total.


Top
 Profile  
 
User avatar  Offline
Dragon
 
Joined: Sat Feb 13, 2010 2:35 am
Posts: 965
Location: California
 Post subject: Re: Trying to understand why a token property is changing.
PostPosted: Sun Apr 29, 2012 8:26 am 
OK changed my code to get rid of the getProperty and instead initialized the tlanguage to "". That got rid of the garbage. But setting the inputs "+value+" didn't do anything except prompt me for the value of each. I think because they aren't properties them selves but just a list in a property.
I think I need to use getProperty to get the current value of Languages then use the foreach loop to see if the list contains the language and is so set the check to 1 and if not 0.
Does that sound right?

OK changed my input to this

Code:
"Abyssal|"+Abyssal+"|Abyssal|CHECK",
      "Common|"+Common+"|Common|CHECK",
      "DeepSpeech|"+DeepSpeech+"|Deep Speech|CHECK",
      "Draconic|"+Draconic+"|Draconic|CHECK",
      "Dwarven|"+Dwarven+"|Dwarven|CHECK",
      "Elven|"+Elven+"|Elven|CHECK",
      "Giant|"+Giant+"|Giant|CHECK",
      "Goblin|"+Goblin+"|Goblin|CHECK",
      "Primordial|"+Primordial+"|Primordial|CHECK",
      "Supernal|"+Supernal+"|Supernal|CHECK",


And added this to the macro before the input is called.

Code:
[h: planguage = getProperty("Languages")]
[foreach(language, planguage):set(language, if(listContains(planguage , language),1,0))]


It is close to working there is no garbage anymore and the foreach loop properly identify's which languages already exist but it does not properly set the others because I still get a pop up asking the value for any language that was not in the list obtained from the Languages property.
Any thoughts?

_________________
DCI/RPGA# 7208328396 Skype ID mfrizzell77
Characters:
Strabor - Dwarf Avenger 5th Level
Tikkanan - Human Warlock 2nd Level
----------------------------------------------------
"People are more violently opposed to fur than leather because it's safer to harass rich women than motorcycle gangs."


Top
 Profile  
 
User avatar  Offline
Deity
 
Joined: Fri Mar 20, 2009 4:40 am
Posts: 5488
Location: Netherlands
 Post subject: Re: Trying to understand why a token property is changing.
PostPosted: Sun Apr 29, 2012 9:59 am 
Yes, you're looping through planguage you need to loop through ALL languages, so create a list for those and loop through those.

_________________
My stuff
Excel Tools: Table editor and Illumination Generator
MT Tools: Dungeon Builder Tool, Bag of Tricks: Teleport pads, Pits, Traps and Warded Areas and onMouseOverEvent
Framework: Dark Heresy, Rogue Trader, Deathwatch, Black Crusade and Only War
Wiki: Debugging Tutorial, Speed Up Your Macros, Working With Two CODE Levels, Shortcut Keys, Avoiding Stack Overflow

My dropbox referral. If you use this then both you and me get 500Mb extra space. 2.5Gb total.


Top
 Profile  
 
User avatar  Offline
Dragon
 
Joined: Sat Feb 13, 2010 2:35 am
Posts: 965
Location: California
 Post subject: Re: Trying to understand why a token property is changing.
PostPosted: Sun Apr 29, 2012 1:18 pm 
Ah, I see the Languages property is just the ones already selected not the entire list.

_________________
DCI/RPGA# 7208328396 Skype ID mfrizzell77
Characters:
Strabor - Dwarf Avenger 5th Level
Tikkanan - Human Warlock 2nd Level
----------------------------------------------------
"People are more violently opposed to fur than leather because it's safer to harass rich women than motorcycle gangs."


Top
 Profile  
 
User avatar  Offline
Deity
 
Joined: Fri Mar 20, 2009 4:40 am
Posts: 5488
Location: Netherlands
 Post subject: Re: Trying to understand why a token property is changing.
PostPosted: Sun Apr 29, 2012 5:02 pm 
mfrizzell wrote:
Ah, I see the Languages property is just the ones already selected not the entire list.

Yup!
Of course if you create that list anyway, you could also build the Wiki: input() Dynamically with a foreach loop. IRC theres an example in the wiki on how to do that. That way you could add languages just to the list and the rest of the code adapt with it. Or you could make several lists restricting choices to certain characters...

_________________
My stuff
Excel Tools: Table editor and Illumination Generator
MT Tools: Dungeon Builder Tool, Bag of Tricks: Teleport pads, Pits, Traps and Warded Areas and onMouseOverEvent
Framework: Dark Heresy, Rogue Trader, Deathwatch, Black Crusade and Only War
Wiki: Debugging Tutorial, Speed Up Your Macros, Working With Two CODE Levels, Shortcut Keys, Avoiding Stack Overflow

My dropbox referral. If you use this then both you and me get 500Mb extra space. 2.5Gb total.


Top
 Profile  
 
Display posts from previous:  Sort by  
Reply to topic  [ 7 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 is 1 user online :: 0 registered, 0 hidden and 1 guest (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 1 guest





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

Style based on Andreas08 by Andreas Viklund

Style by Elizabeth Shulman