RPTools.net

Discussion and Support

Skip to content

It is currently Sat Dec 16, 2017 9:31 pm 






Reply to topic  [ 6 posts ] 

Previous topic | Next topic 

  Print view

Author Message
User avatar  Offline
Dragon
 
Joined: Wed Aug 31, 2011 8:49 pm
Posts: 495
Location: Somewhere between Heaven and Hell
 Post subject: Adding attacks to a single property
PostPosted: Fri Sep 15, 2017 5:00 pm 
I'd like to create a single property on my monster tokens that will store attacks inside it. Because some monsters only have one or two attacks, and others can have several, I'm not sure how to approach this. In example, if the monster has Claw, Bite, and Tail as attacks, how would I go about making it so I could store them all in the property, and then recall them later?

When there is a specific variable name, I know how to store jsons within jsons, and how to recall them again, but my hangup is, I don't know how to recall the information when the variables are unknown. In example, if Monster A has two attacks, and Monster B has 4 attacks, how will the code know to extract 2 attacks from Monster A, and 4 attacks from Monster B?

A simple point in the right direction is fine, but any advice available is greatly appreciated as always.

_________________
"An arrogant person considers himself perfect. This is the chief harm of arrogance. It interferes with a person's main task in life - becoming a better person." - Leo Tolstoy

Image


Top
 Profile  
 
User avatar  Offline
Deity
 
Joined: Fri Mar 20, 2009 4:40 am
Posts: 9427
Location: Netherlands
 Post subject: Re: Adding attacks to a single property
PostPosted: Fri Sep 15, 2017 7:52 pm 
Wiki: json.fields() and then listcontains and if

edit: perhaps after the json.fields its better to use a combi of [foreach:] and [switch:]

so to be a bit less cryptic:

Code:
attacks getProperty("attacks""Ork")
attackList json.fields(attacks)

foreach(
attackattackList), CODE:{
<!-- 
i always forget the right syntax so this most likely wont workthat and i didnt add the [] so it wont work anyway -->
  switch(
attack), CODE:
    case 
"left hand": {bla};
    case 
"right hand":{different bla};
    case 
"bite": {yet more bla}
    
etc.
   default:{
bla unknown attack type bla}

_________________
GETTING STARTED WITH MAPTOOLS - TUTORIALS, DOCS, VIDEOS, TOOLS, ETC

My stuff
Excel Tools: Table and Light editors
MT Tools: Bag of Tricks: Tools for Maptool, Dungeon Builder I, Dungeon Builder II,onMouseOverEvent and
DPI.
Frameworks: Dark Heresy, Rogue Trader, Deathwatch, Black Crusade, Only War, SET Card Game, RoboRally
Wiki: Debugging Tutorial, Speed Up Your Macros, Working With Two CODE Levels, Shortcut Keys, Avoiding Stack Overflow, READ THIS


Top
 Profile  
 
User avatar  Offline
Dragon
 
Joined: Wed Aug 31, 2011 8:49 pm
Posts: 495
Location: Somewhere between Heaven and Hell
 Post subject: Re: Adding attacks to a single property
PostPosted: Sat Sep 16, 2017 10:22 am 
To clarify, json.fields() basically works like listCount()? That's what the wiki makes me think anyway.

I'll be sending this all to a form using the foreach method you showed me previously, wolph, so players can choose which weapon/attack they have that they wish to alter, and I can do the same thing for monster templates.

So with your example, count the number of objects/arrays in my attacks property using json.fields().
Foreach set of attacks in that property, extract attackName, accuracy, damage, etc and arrange it in a table.

Awesome, exactly what was I looking for - thanks again Wolph42 =)

_________________
"An arrogant person considers himself perfect. This is the chief harm of arrogance. It interferes with a person's main task in life - becoming a better person." - Leo Tolstoy

Image


Top
 Profile  
 
User avatar  Offline
Dragon
 
Joined: Wed Aug 31, 2011 8:49 pm
Posts: 495
Location: Somewhere between Heaven and Hell
 Post subject: Re: Adding attacks to a single property
PostPosted: Sat Sep 23, 2017 11:50 am 
What command do you use to add a new json object to the end of an existing json, since json.append only works for arrays? I'm trying to read over the json.set() wiki where it says something about set it to a specific index, but I'm not entirely understanding if that's the right way to go or not?

I was -guessing- I would need to use json.fields to find the number of objects already in the json, then use json.set(myJson,fieldsresult,newObject) or something like that. A bit clueless here.

_________________
"An arrogant person considers himself perfect. This is the chief harm of arrogance. It interferes with a person's main task in life - becoming a better person." - Leo Tolstoy

Image


Top
 Profile  
 
User avatar  Offline
Deity
 
Joined: Fri Mar 20, 2009 4:40 am
Posts: 9427
Location: Netherlands
 Post subject: Re: Adding attacks to a single property
PostPosted: Sat Sep 23, 2017 6:51 pm 
adding you do with json.set(object, key, value) object being the json variable, key the name of the value to add and value...the value ro add.

_________________
GETTING STARTED WITH MAPTOOLS - TUTORIALS, DOCS, VIDEOS, TOOLS, ETC

My stuff
Excel Tools: Table and Light editors
MT Tools: Bag of Tricks: Tools for Maptool, Dungeon Builder I, Dungeon Builder II,onMouseOverEvent and
DPI.
Frameworks: Dark Heresy, Rogue Trader, Deathwatch, Black Crusade, Only War, SET Card Game, RoboRally
Wiki: Debugging Tutorial, Speed Up Your Macros, Working With Two CODE Levels, Shortcut Keys, Avoiding Stack Overflow, READ THIS


Top
 Profile  
 
User avatar  Offline
Dragon
 
Joined: Wed Aug 31, 2011 8:49 pm
Posts: 495
Location: Somewhere between Heaven and Hell
 Post subject: Re: Adding attacks to a single property
PostPosted: Tue Sep 26, 2017 9:17 am 
Many apologies for the delayed 'Thank You', Wolph - been quite the busy weekend/beginning. So, Thank you =)

_________________
"An arrogant person considers himself perfect. This is the chief harm of arrogance. It interferes with a person's main task in life - becoming a better person." - Leo Tolstoy

Image


Top
 Profile  
 
Display posts from previous:  Sort by  
Reply to topic  [ 6 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 2 users online :: 0 registered, 0 hidden and 2 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 2 guests





cron

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

Style based on Andreas08 by Andreas Viklund

Style by Elizabeth Shulman