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] Power Cards

December 24 (10 years ago)
Thanks for the replies guys.

Tags with the same name is *never ever* happening. It's a programming thing....
Yeah, I was almost certain as much. Thanks.

Hrm, I don't typically use apostrophes in character names, so this hasn't come up. I may be able to fix it, dunno. Does Roll20 do the space in front of alt characters normally or only through the API?
Only the API. I've used the name fine for months. It's no biggie, really, but it's a head's up.
December 26 (10 years ago)
PowerCards 2.0 is getting much closer to being done. Finally got multi-rolling done and it works regardless of the tag name now. "Same name" tags are in. A word of warning however... the deprecated tags listed above are being removed in PC2.0 and this will break macros based on the current version of the script in this thread. For example, --usage and --action are no longer being used. In their place, I'm going to create a way for the GM/DM to define sets of formatting and you'll be able to use --style|atwill or --style|encounter or whatever the GM creates. That's my next project now that multi-rolls are done.

December 26 (10 years ago)
vÍnce
Pro
Sheet Author
Right on Honey Badger. Can't wait to find every way possible to break your new version.
December 27 (10 years ago)
So... the --style tag... should the options be defined inside the script itself or make it part of a handout, so the GM can alter it on the fly without having to open the API and such?
December 27 (10 years ago)
Wes
Sheet Author
I would vote "Handout" it would be nice to set it up inside your campaign. On the flip side. Something that will probably only need to be set once isn't too bad to have to do from the api page.
December 27 (10 years ago)
Gen Kitty
Forum Champion
All the GM-settable options should be consistent. Gathering them together at the top of the script works for me, but at this point I'm also used to hunting through the script to find the places you didn't intend for GMs to tweak and changing styles to suit me :> (Mainly changing font-styles for stuff)
December 27 (10 years ago)
The Aaron
Pro
API Scripter
I'd put them in the state object, that's what it's there for. I know you've run into some issues with it in the past, but it's always been stable since I've started using it
December 27 (10 years ago)

The Aaron said:

I'd put them in the state object, that's what it's there for. I know you've run into some issues with it in the past, but it's always been stable since I've started using it

Uh... no, lol. The object of doing this is to make it easier for a GM to find/see/change options without having to hunt around in the script or whatnot. You can't even see the state object without writing a script to specifically look at it and spit out the contents. :P Will probably go with a handout.
December 27 (10 years ago)
The Aaron
Pro
API Scripter
Right. Using the state object implies providing commands to view & set the configuration.
December 30 (10 years ago)

Edited December 30 (10 years ago)
Ugh...

https://wiki.roll20.net/API:Objects#Using_the_Note...

This apparently has the same fucking problems with being asynchronous as sendChat does... >_< ... which means I can't use a handout to store PowerCard Format options. Feh.
December 30 (10 years ago)
The Aaron
Pro
API Scripter
Yeah, that's a change since: https://app.roll20.net/forum/post/1014870/#post-10...
December 30 (10 years ago)
Feh. I'm not writing to the notes field though. Just reading it. >_<
December 30 (10 years ago)
The Aaron
Pro
API Scripter
If this will help, here's a little script that handles all the async bits of creating (when it's missing or deleted) and reading (at start up and on change) a config from a handout:
var NotesTest = NotesTest || (function() {
	'use strict';

	var version = 0.1,
		noteConfigId,
		noteConfigName = 'NotesTest Config',
		config = {},

	fixedCreateObj = (function () {
		return function () {
			var obj = createObj.apply(this, arguments);
			if (obj && !obj.fbpath) {
				obj.fbpath = obj.changed._fbpath.replace(/([^\/]*\/){4}/, "/");
			}
			return obj;
		};
	}()),

	loadConfig = function (configText) {
		log ('loading config from: '+configText);
	},

	createConfig = function() {
		var configNote = fixedCreateObj('handout',{
			name: noteConfigName
		});
		configNote.set('notes','Add config here...');
		noteConfigId = configNote.id;
	},

	checkInstall = function(callback) {
		var configNote = filterObjs(function(o){
			return ( 'handout' === o.get('type') && noteConfigName === o.get('name') && false === o.get('archived'));
		})[0];
		if(configNote) {
			noteConfigId = configNote.id;
			configNote.get('notes',function(n) {
				loadConfig(n);
				callback();
			});
		} else {
			createConfig();
			callback();
		}
	},

	handleInput = function(msg) {
		var args;

		if (msg.type !== "api") {
			return;
		}

		args = msg.content.split(/\s+/);
		switch(args[0]) {
			case '!NotesTest':
				break;
		}
	},

	handleNoteChange = function(obj,prev) {
		if(obj.id === noteConfigId) {
			log('updating config from: '+ obj.get('name'));
			obj.get('notes',function(n) {
				loadConfig(n);
			});
		}
	},

	handleNoteDestroy = function(obj) {
		if(obj.id === noteConfigId) {
			log('creating new config.');
			createConfig();
		}
	},

	registerEventHandlers = function() {
		on('chat:message', handleInput);
		on('change:handout', handleNoteChange);
		on('destroy:handout', handleNoteDestroy);
	};

	return {
		CheckInstall: checkInstall,
		RegisterEventHandlers: registerEventHandlers
	};
}());

on('ready',function() {
	'use strict';

	NotesTest.CheckInstall(function(){
		NotesTest.RegisterEventHandlers();
	});
});
December 30 (10 years ago)

Edited December 30 (10 years ago)
Thanks for pointing me in the right direction Aaron. I didn't go with as complicated of a solution as you did. I just moved the code I had grabbing the information into a function and then call it on:ready and on:change:handout. It puts the data into a state object now, though I dislike that option, since other scripts could inadvertently alter it or delete it entirely.
December 30 (10 years ago)
Woot. GM defined powercard formats in handouts are working as intended... at least until I release PowerCard 2.0 and people get their hands on it. I also managed to figure out and solve a problem I didn't know I had until I added this feature. If the last --tag was one of the reserved/ignored tags... the bottom of the card would not be rounded.

Either later today or tomorrow... I will no longer be updating this thread and will create a new thread for the new version, since the two will be incompatible. I have one last update to put into this thread and that's a fix for the random colon appearing when using the custom emote option.
December 30 (10 years ago)

Updates

  • December 30th, 2014 ~ 7:00 am eastern:
    • Fixed the random colon appearing when using custom emotes.
    • Added a version check into the script for bug tracking. Simply type !power_version in chat and the script will whisper you which version of the script your GM is currently using.
This should be the last update/bugfix for the 1.0 version of the script. There are a number of changes in the 2.0 version that will make your macros look rather ugly and in some cases, non-functional.
December 30 (10 years ago)
A look back at what PowerCards started out as...



... and where they're at now.

December 30 (10 years ago)
The Aaron
Pro
API Scripter
Cool!
December 30 (10 years ago)
vÍnce
Pro
Sheet Author
I've seen so many screen shots of roll20 that include the powercards I've come to think of them as being part of roll20. Hard to imagine a roll20 game without them. Thanks HB
December 30 (10 years ago)

Vince said:

I've seen so many screen shots of roll20 that include the powercards I've come to think of them as being part of roll20. Hard to imagine a roll20 game without them. Thanks HB
That's kinda cool. :) Thanks!
December 30 (10 years ago)
Anyone else having problems with todays update? I've copied over twice now and it no longer works for me.
December 30 (10 years ago)

Edited December 30 (10 years ago)

Michael said:

Anyone else having problems with todays update? I've copied over twice now and it no longer works for me.

Yeah, it's not working for me either... and it was earlier. I think I found the problem... but my shower handle broke and I'm trying to figure out how to get it fixed. Will post an update later that fixes this problem.

Nevermind. It was easier than I thought. Updating main post now...
December 30 (10 years ago)

Updates

  • December 30th, 2014 ~ 1:40 pm eastern: Minor bugfix for sendChat issues and the random colon fix from earlier...
It should work now. Had two issues... command wasn't being turned into a string properly (my bad) and the if/else logic I changed to get rid of the random colon that appeared when using the custom emotes was slightly off. Should be good though.
December 30 (10 years ago)
Gen Kitty
Forum Champion
Thank you for all the hard work you've put into this. I look forward to seeing what lies ahead in 2.0.... hopefully it won't cause me to rewrite *all* my macros. ^_^
December 31 (10 years ago)

GenKitty said:

Thank you for all the hard work you've put into this. I look forward to seeing what lies ahead in 2.0.... hopefully it won't cause me to rewrite *all* my macros. ^_^
The biggest change is how multiple attacks are handled... instead of Attack3, you now need to use Attack#3. Any unreserved tag can be repeated though. Not just attack, damage, and multi (which doesn't exist anymore as a reserved tag). I have also completely removed usage/action and re-used the defunct format tag (since .style is already something in javascript and I can't use it). You'll be able to define --format options in a handout and change them without having to open the api, add them there, and save the script. I'm gonna work on writing up the initial post of the new thread and hopefully post the next version sometime tonight or tomorrow.
December 31 (10 years ago)
Gen Kitty
Forum Champion

HoneyBadger said:

GenKitty said:

Thank you for all the hard work you've put into this. I look forward to seeing what lies ahead in 2.0.... hopefully it won't cause me to rewrite *all* my macros. ^_^
The biggest change is how multiple attacks are handled...

Ahhh. I never used that approach because I like having target token names paired with each attack line. x.x
December 31 (10 years ago)
vÍnce
Pro
Sheet Author
You'll be able to define --format options in a handout and change them without having to open the api, add them there, and save the script
That's going to be nice.
December 31 (10 years ago)

Edited December 31 (10 years ago)
Gen Kitty
Forum Champion
You'll be able to define --format options in a handout and change them without having to open the api, add them there, and save the script


Question: Will that extend to fonts and other options currently settable in the script such as URL support?
December 31 (10 years ago)

GenKitty said:

Ahhh. I never used that approach because I like having target token names paired with each attack line. x.x

That's doable too. Just wish we had some kind of multi-targeting feature that didn't require clicking the same token over and over to fill up the list.

GenKitty said:
You'll be able to define --format options in a handout and change them without having to open the api, add them there, and save the script


Question: Will that extend to fonts and other options currently settable in the script such as URL support?

Not at this time. Just starting out with text and background colors for the title of the card and the even/odd rows.
December 31 (10 years ago)

GenKitty said:

Ahhh. I never used that approach because I like having target token names paired with each attack line. x.x
This is now part of ver 2.0 of PowerCards. :)

It was actually much simpler than I thought it would be, mostly due to the changes I've made to repeated tags. In the old version, it would have been a headache.
December 31 (10 years ago)
New thread/script is just about ready to post. I will no longer be updating this version of PowerCards unless there is a game breaking bug/change that prevents people from using it.

New Thread!

December 31 (10 years ago)
Gen Kitty
Forum Champion

HoneyBadger said:

GenKitty said:

Ahhh. I never used that approach because I like having target token names paired with each attack line. x.x
This is now part of ver 2.0 of PowerCards. :)

*squints* *heads off to new thread*