Get 8 different results (1-8) mixed
Moderators: dorpond, trevor, Azhrei, giliath, jay, Mr.Ice
Get 8 different results (1-8) mixed
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?
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?
Last edited by oblisgr on Sun Sep 10, 2017 5:15 pm, edited 1 time in total.
High Templar of Ur
Re: Get 8 different results (1-8) scrumbled
wtf is a 'scrumbled'?
GETTING STARTED WITH MAPTOOLS - TUTORIALS, DOCS, VIDEOS, TOOLS, ETC
DISCORD (the new MT forum!)
My stuff
Excel Tools: Table and Light editors
MT Tools: Bag of Tricks: Tools for Maptool, Dungeon Builder I, Dungeon Builder II,onMouseOverEvent.
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
DISCORD (the new MT forum!)
My stuff
Excel Tools: Table and Light editors
MT Tools: Bag of Tricks: Tools for Maptool, Dungeon Builder I, Dungeon Builder II,onMouseOverEvent.
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
Re: Get 8 different results (1-8) mixed
It's kind of vague, but here's one way.
Code: Select all
<!-- 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)]
Downloads:
- Notepad++ MapTool addon
- RPEdit details (v1.3)
- Coding Tips: Modularity and Design
- Videos: Macro Writing Tools
Re: Get 8 different results (1-8) mixed
I dont understand how it gives 8 different results taken from the list.aliasmask wrote:It's kind of vague, but here's one way.
Code: Select all
<!-- 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)]
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
Re: Get 8 different results (1-8) mixed
I think you need to give a more detailed example then, because I'm not understanding what you're trying to accomplish.
Downloads:
- Notepad++ MapTool addon
- RPEdit details (v1.3)
- Coding Tips: Modularity and Design
- Videos: Macro Writing Tools
Re: Get 8 different results (1-8) mixed
[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)
[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
Re: Get 8 different results (1-8) mixed
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.
Examples: 12345678, 13827465, 81726354, ... and so on, so that each call gives a random ordered list of the numbers 1-8.
Code: Select all
[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)]
Re: Get 8 different results (1-8) mixed
Ah, that's an easy one then.
Code: Select all
[H: myList = json.append("",1,2,3,4,5,6,7,8)]
[H: newList = json.shuffle(myList)]
[R: json.toList(newList,"")]
Downloads:
- Notepad++ MapTool addon
- RPEdit details (v1.3)
- Coding Tips: Modularity and Design
- Videos: Macro Writing Tools
Re: Get 8 different results (1-8) mixed
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)]
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
Re: Get 8 different results (1-8) mixed
Change listGet to json.get.
You can also do this:
You can also do this:
Code: Select all
[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:
- Notepad++ MapTool addon
- RPEdit details (v1.3)
- Coding Tips: Modularity and Design
- Videos: Macro Writing Tools
Re: Get 8 different results (1-8) mixed
I used the json.get and worked.aliasmask wrote:Change listGet to json.get.
You can also do this:
Code: Select all
[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))]
Thanks for help
High Templar of Ur