RPTools.net

Discussion and Support

Skip to content

It is currently Mon Nov 20, 2017 11:35 pm 






Reply to topic  [ 12 posts ] 

Previous topic | Next topic 

  Print view

Author Message
 Offline
Giant
 
Joined: Mon Aug 01, 2011 5:43 am
Posts: 124
Location: Crete,Greece
 Post subject: Get 8 different results (1-8) mixed
PostPosted: Sun Sep 10, 2017 4:05 pm 
Hello,
I need to make a makro that will give 8 results from 1-8 mixed and add them to the assigned token properties.
Can anyone help?

_________________
High Templar of Ur


Last edited by oblisgr on Sun Sep 10, 2017 4:15 pm, edited 1 time in total.

Top
 Profile  
 
User avatar  Offline
Deity
 
Joined: Fri Mar 20, 2009 4:40 am
Posts: 9419
Location: Netherlands
 Post subject: Re: Get 8 different results (1-8) scrumbled
PostPosted: Sun Sep 10, 2017 4:10 pm 
wtf is a 'scrumbled'?

_________________
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  
 
 Offline
Giant
 
Joined: Mon Aug 01, 2011 5:43 am
Posts: 124
Location: Crete,Greece
 Post subject: Re: Get 8 different results (1-8) scrumbled
PostPosted: Sun Sep 10, 2017 4:15 pm 
mixed i meant. :lol:

_________________
High Templar of Ur


Top
 Profile  
 
User avatar  Online
Deity
 
Joined: Tue Nov 10, 2009 6:11 pm
Posts: 7948
Location: Bay Area
 Post subject: Re: Get 8 different results (1-8) mixed
PostPosted: Sun Sep 10, 2017 8:57 pm 
It's kind of vague, but here's one way.

Code:
<!-- have a list with numbers in it -->
[
HmyList "1,2,4,8,12,16,20,24"]

<!-- 
pick a random number from list -->
[
Hpick listGet(myList,1d8-1)]

<!-- 
get existing value on token -->
[
HtokenProp getProperty("myProp")]

<!-- if 
its empty, set to 0 -->
[
H, if(json.isEmpty(tokenProp)): tokenProp 0]

<!-- 
add the values together -->
[
HtokenProp tokenProp pick]

<!-- 
save total on token -->
[
HsetProperty("myProp",tokenProp)] 

_________________
Downloads:


Top
 Profile  
 
 Offline
Giant
 
Joined: Mon Aug 01, 2011 5:43 am
Posts: 124
Location: Crete,Greece
 Post subject: Re: Get 8 different results (1-8) mixed
PostPosted: Mon Sep 11, 2017 12:48 pm 
aliasmask wrote:
It's kind of vague, but here's one way.

Code:
<!-- have a list with numbers in it -->
[
H: myList = "1,2,4,8,12,16,20,24"]

<!--
 pick a random number from list -->
[
H: pick = listGet(myList,1d8-1)]

<!--
 get existing value on token -->
[
H: tokenProp = getProperty("myProp")]

<!--
 if its empty, set to 0 -->
[
H, if(json.isEmpty(tokenProp)): tokenProp = 0]

<!--
 add the values together -->
[
H: tokenProp = tokenProp + pick]

<!--
 save total on token -->
[
H: setProperty("myProp",tokenProp)] 


I dont understand how it gives 8 different results taken from the list.
If the list = 1,2,3,4,5,6,7,8 I want it to give 8 results from 1 to 8 non repeatable with random place.
Thats the thing

_________________
High Templar of Ur


Top
 Profile  
 
User avatar  Online
Deity
 
Joined: Tue Nov 10, 2009 6:11 pm
Posts: 7948
Location: Bay Area
 Post subject: Re: Get 8 different results (1-8) mixed
PostPosted: Mon Sep 11, 2017 12:59 pm 
I think you need to give a more detailed example then, because I'm not understanding what you're trying to accomplish.

_________________
Downloads:


Top
 Profile  
 
 Offline
Giant
 
Joined: Mon Aug 01, 2011 5:43 am
Posts: 124
Location: Crete,Greece
 Post subject: Re: Get 8 different results (1-8) mixed
PostPosted: Mon Sep 11, 2017 1:06 pm 
[H: myList = "1,2,3,4,5,6,7,8"]

[H: pick1 = listGet(myList,1d8-1)]
[H: pick2 = listGet(myList,1d8-1)]
[H: pick3 = listGet(myList,1d8-1)]
[H: pick4 = listGet(myList,1d8-1)]
[H: pick5 = listGet(myList,1d8-1)]
[H: pick6 = listGet(myList,1d8-1)]
[H: pick7 = listGet(myList,1d8-1)]
[H: pick8 = listGet(myList,1d8-1)]

[r:pick1][r:pick2][r:pick3][r:pick4][r:pick5][r:pick6][r:pick7][r:pick7][r:pick8]

Run this 3 times, gave me the following results:

611163777
436452441
461343777

The thing i dont want on these results are the repeatable results.
For example in first result i get 2x6,3x1,3x7 while i would like to get something like 13478265 (no number is repating)

_________________
High Templar of Ur


Top
 Profile  
 
 Offline
Kobold
 
Joined: Mon Apr 16, 2012 8:23 pm
Posts: 2
 Post subject: Re: Get 8 different results (1-8) mixed
PostPosted: Mon Sep 11, 2017 1:32 pm 
The OP is asking for it to distribute the numbers 1-8 once each into an output.
Examples: 12345678, 13827465, 81726354, ... and so on, so that each call gives a random ordered list of the numbers 1-8.

Code:
[h: myList = json.fromList("1,2,3,4,5,6,7,8")] <!-- list of 1 to 8 -->
[h: myVal = ""] <!-- Blank val to set -->

<!-- Repeat until no items left -->
[h, WHILE(json.length(myList) > 0), CODE:
{
[h: choose = d(1,json.length(myList))-1] <!-- Pick one-->
[h: myVal = myVal + string(json.get(myList, choose))] <!-- Add it to the value -->
[h: myList = json.remove(myList, choose)] <!-- Remove it from the list, prevents repeats -->
}]

<!-- save output on token -->
[H: setProperty("myProp", myVal)]


Top
 Profile  
 
User avatar  Online
Deity
 
Joined: Tue Nov 10, 2009 6:11 pm
Posts: 7948
Location: Bay Area
 Post subject: Re: Get 8 different results (1-8) mixed
PostPosted: Mon Sep 11, 2017 2:49 pm 
Ah, that's an easy one then.

Code:
[H: myList = json.append("",1,2,3,4,5,6,7,8)]
[H: newList = json.shuffle(myList)]
[R: json.toList(newList,"")]

_________________
Downloads:


Top
 Profile  
 
 Offline
Giant
 
Joined: Mon Aug 01, 2011 5:43 am
Posts: 124
Location: Crete,Greece
 Post subject: Re: Get 8 different results (1-8) mixed
PostPosted: Tue Sep 12, 2017 1:47 pm 
I made this code that gives me the result i need. The only problem is that the 1st and the 8th number appear with [ and ].
I dont know why.

[H: myList = json.append(1,2,3,4,5,6,7,8)]
[H: newList = json.shuffle(myList)]

[r: pick1 = listGet(newlist, 0)]
[r: pick2 = listGet(newlist, 1)]
[r: pick3 = listGet(newlist, 2)]
[r: pick4 = listGet(newlist, 3)]
[r: pick5 = listGet(newlist, 4)]
[r: pick6 = listGet(newlist, 5)]
[r: pick7 = listGet(newlist, 6)]
[r: pick8 = listGet(newlist, 7)]

[H: setProperty("Melee", pick1)]
[H: setProperty("Range", pick2)]
[H: setProperty("Fire", pick3)]
[H: setProperty("Frost", pick4)]
[H: setProperty("Nature", pick5)]
[H: setProperty("Arcane", pick6)]
[H: setProperty("Holy", pick7)]
[H: setProperty("Shadow", pick8)]

_________________
High Templar of Ur


Top
 Profile  
 
User avatar  Online
Deity
 
Joined: Tue Nov 10, 2009 6:11 pm
Posts: 7948
Location: Bay Area
 Post subject: Re: Get 8 different results (1-8) mixed
PostPosted: Tue Sep 12, 2017 3:36 pm 
Change listGet to json.get.

You can also do this:

Code:
[H: attackTypes = json.fromList("Melee,Range,Fire,Frost,Nature,Arcane,Holy,Shadow")]
[H: randId = json.append("",1,2,3,4,5,6,7,8)]
[H: randId = json.shuffle(randId)]
[H, foreach(attackProp,attackTypes): setProperty(attackProp,json.get(randId,roll.count))]

_________________
Downloads:


Top
 Profile  
 
 Offline
Giant
 
Joined: Mon Aug 01, 2011 5:43 am
Posts: 124
Location: Crete,Greece
 Post subject: Re: Get 8 different results (1-8) mixed
PostPosted: Wed Sep 13, 2017 3:09 pm 
aliasmask wrote:
Change listGet to json.get.

You can also do this:

Code:
[H: attackTypes = json.fromList("Melee,Range,Fire,Frost,Nature,Arcane,Holy,Shadow")]
[H: randId = json.append("",1,2,3,4,5,6,7,8)]
[H: randId = json.shuffle(randId)]
[H, foreach(attackProp,attackTypes): setProperty(attackProp,json.get(randId,roll.count))]


I used the json.get and worked.
Thanks for help

_________________
High Templar of Ur


Top
 Profile  
 
Display posts from previous:  Sort by  
Reply to topic  [ 12 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 :: 1 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: aliasmask and 2 guests





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

Style based on Andreas08 by Andreas Viklund

Style by Elizabeth Shulman