Roll20 uses cookies to improve your experience on our site. Cookies enable you to enjoy certain features, social sharing functionality, and tailor message and display ads to your interests on our site and others. They also help us understand how our site is being used. By continuing to use our site, you consent to our use of cookies. Update your cookie preferences .
×
Create a free account

[Script] !reveal command

May 01 (12 years ago)

This is a chat API command I made that finds objects by "class", then moves them to the objects layer:

https://gist.github.com/rlittlefield/5493842?1=5

Usage: !reveal foo bar

or: !alter foo bar > {rotation:24.1,aura1_radius:5, aura1_color:"#44FF00"}

Will find every object on the player page, and move it to the objects layer if the name of the object has a class in it. It would be super helpful if we could tag objects with some kind of metadata for the API (like class), which would make this sort of script even more trivial, and could make things much faster. Once the "state" object is persistent between sessions, it could also be used to track items. It would be nifty to make something like !addclass Name Class, which could then find the object id by name, then add it to a classes variable on the state object.


May 01 (12 years ago)

When you type !reveal foo does that show up on chat to players? These scripts are just gonna create a bunch of spam if we can't use hidden commands.

May 01 (12 years ago)

!commands (any command starting with !) will not output to the chat, unless you specifically tell the Javascript to have a chat output. So the answer is: not in this case, because he did not add chat output to the code.

May 01 (12 years ago)

Yes, it should currently hide the command. I've just updated it to have a handy function for getting items by class, added "conceal" and support for command aliases (hide, show). If I can figure out how to get the embedded gist to update, I'd show it.

Update: I tricked the embedded gist into updating. I think this new version should be somewhat more robust, and could be a fun starting point for building a few commands to operate on groups of graphics.

May 01 (12 years ago)
Riley D.
Roll20 Team

Cool! Yeah I'm not sure about adding something like a "class" to the token object. I'm still trying to determine how "separate" API-related data (like the state object) should be vs data that's shown in the in-game interface. One thing you could do is (assuming the token is linked to a Character) base it on the Character's tags once I've added support for those here shortly...

May 01 (12 years ago)
Riley D.
Roll20 Team

Oh, also, for the gist updating, in theory it should be pulling the latest version from Github on each page reload, was it not doing that?

May 01 (12 years ago)

Riley D. said:

Oh, also, for the gist updating, in theory it should be pulling the latest version from Github on each page reload, was it not doing that?

I don't think it is updating for me. Perhaps I used the incorrect link? I just added ?1=2 to the end to force a new page.

May 01 (12 years ago)

I just added a "!revealrandom", which picks a random graphic matching the class and that is currently on the gmlayer, and moves it to the objects layer. Maybe useful for when you can't decide which enemy attacks first?

May 01 (12 years ago)

Riley D. said:

Oh, also, for the gist updating, in theory it should be pulling the latest version from Github on each page reload, was it not doing that?

It seems to be caching the response from github. In fact, when I was working in the other thread, I was noticing that if I made changes, even across multiple replies it would not update from github.  

May 01 (12 years ago)
Riley D.
Roll20 Team

Interesting. Well we'll just have to add little strings onto the end, then, I guess.

May 02 (12 years ago)

I've added some additional functionality. You can now do a command like:

!alter foo bar > {rotation:24.1,aura1_radius:5, aura1_color:"#44FF00"}

Using this script you could write some macros to perform basic alterations to the tokens, so some automation stuff could be possible by anyone with access to the API and the skill to write a macro. Admittedly it would never be as automatic as an event handler in javascript, but if you wanted to script actions based on the press of a button, it could be nifty.The above example rotates everything with .foo or .bar in the name, and adds a green aura. The syntax is fairly specific (no fancy parsing), so even things like extra spaces would probably break it.

Update: I'm now using the frowned-upon "eval" function on everything to the right of the ">", so it should be more forgiving of the property syntax now.