#Move loot from a chest

1 messages · Page 1 of 1 (latest)

upper rapids
#

I am trying to move txt from one property on active token onto a selected token, but for some reason i dont get the names of the token
I have this code:
// is a comment, excluded in macro

h: cond = '{ "range": {"upto":1, "distancePerCell":0, "token":"' +getSelected()+ '"}, "pc":1 }']
[h: IDs = getTokenNames("json", cond)]
//All the actuel ID is show, now i need to transfer them to names to be shown in input box

[h: players=""]
[t,foreach(player,IDs), CODE : {
[h: json.append(players,player)]
}]
//returns nothing

[h: status = input(
"tempPlayer | " + players + " |Player|RADIO|ORIENT=V SELECT=0"
)]
[h:abort(status)]
//shows only a single 0, no ID and no names

[h: tempPlayer2 = listget(players,tempPlayer)]
// withdrawing the name from the list i need for the other part of the code

cinder chasm
#

Couple o'things
[h: **players=**json.append(players,player)]

getTokenNames already returns a string list you can just plug into into input() so that does is redundant anyway

You are then doing listGet on a json???

upper rapids
# cinder chasm Couple o'things [h: **players=**json.append(players,player)] getTokenNames alre...

I changed the first line to [h: players=json.append(players,player)] and the removed the line with Listget
Then i run it the input box comes up with two names (correct)
Names ["Marley" and "Alex"]

But i don't like the [" in the first name and "] in the second

the Listget line was to extract the name as input gives a number which i need to change to a name but without [" "

Even if i drop the foreach and use IDs i get the names with [" and the errors later

crisp yoke
#

try a players = json.toList(players)]
This will convert it back to a string.
or do this instead and don't json it.
players = listAppend(players,player)
point is you can't really mix / mingle string and json without an extra step.

#

@upper rapids is this what you want:

[h: players=getTokenNames(",", cond)]
[h: status = input("tempPlayer | " + players + "  |Player|RADIO|ORIENT=V SELECT=0")]
[h:abort(status)]
[h: chosenPlayer = listget(players,tempPlayer)]
[h: broadcast(chosenPlayer)]```