New Scripting in the 8/17/13 (and later) Lackey

Started by Trevor, August 16, 2013, 02:39:47 PM

Previous topic - Next topic

Trevor

In the previous version of Lackey I started enabling scripting, as described at http://www.lackeyccg.com/forum/index.php?topic=1801.0 .
That method is now obsolete (though I am considering adding backward compatibility if people want it). The problem with that method was it only allowed modifications of the card the script was associated with and it only would run when the card was sent to the table, and only automatically.

The new system is much more versatile. It allows you to:
Have multiple scripts associated with each card.
Scripts can perform any log function (or multiple functions), such as /roll or /flip.
You can now label scrips to make them easier for people to understand.
You can define one of a card's scripts to be run automatically when the card is sent to the table.
Script's effects now appear in the log.
A card's scripts are accessible by right-clicking a card on the table.
Since card scripts use log function commands (http://lackeyccg.com/tutoriallogcommands.html), there are tons of things you can do with them, and as I add more log functions, those will be immediately available to card scripts.

To use the scripts, it's similar to the old method where you make a column in your card data file called "Script". For each card you want to have a script (or scripts) for, you enter in the script syntax into that column.

You can have any number of scripts in that cell. A script begins with <s> and ends with </s>. In between <s> and </s>, you can include:
An indicator if the function is automatically performed when the card is sent to the table. This begins with <a> and ends with </a> and inside you can put y for yes. So the automation syntax part would look like <a>y</a>. You can only have one automatically run script per card. Users can disable these from running in the Preferences/Miscellaneous section under "Enable scripts?".

The second component of the script syntax is a label for the script that appears in the right-click menu of a card on the table. This starts with <l> and ends with </l>. Note that that is the lower case letter L, for label.
The third and final component of the script syntax is the actual function(s) to be performed. This section starts with <f> and ends with </f>. In between, you put any log command, such as "/flip". If you have multiple commands for a single script, separate them with a semicolon.

As an option, you can use a simplified syntax when a card just uses an automatic script. This is good for a card that always is put onto the table with 3 red counters on it, for example. In that case, all you need is the log function, which would be /ccred=3 in that case. No need to use <s> or anything else in the full syntax for a simple script like this. When done like this, a script is given the name "Initialize" in the card's right-click menu on the table, and it is implicitly set to run automatically.

For example, in the script column of a card, you could write:
<s><a>y</a><l>Initialize</l><f>/ccred=3</f></s>
or just
/ccred=3
and they would do the same exact thing.

Note that all scripts are implicitly not automatically performed, unless they are input with the simplified method, in which case they are always implicitly automatically performed.

Suppose you have a card that has multiple abilities. You could give define it like this:
<s><a>y</a><l>Initialize counters</l><f>/ccgreen=3</f></s>
<s><l>+3, Spawn 2 sheep</l><f>/ccgreen+3;/spawnx2 Sheep Token</f></s>
<s><l>-2, Draw 2 cards</l><f>/ccgreen-2;/d2;/s eating sheep!</f></s>

When you drag this card to the table, it would set the green counters to 3.
You could right-click the card while it's on the table see 3 functions, "Initialize", "+3, Spawn 2 sheep", and "-2, Draw 2 cards". The first would reset the counters to 3, as you would do if you moved it off the table and then back. The second script would increase the number of green counters by 3 and then spawn 2 sheep tokens. The 3rd script would subtract 2 green counters and then draw you 2 cards.

Trevor

#1
These scripts are live in the 8/17/13 and above versions of lackey. Please report bugs/issues/requests/suggestions for improvements.

3XXXDDD

Did we lose the ability to script for automatic face-down cards?

Trevor

#3
Quote from: 3XXXDDD on August 18, 2013, 04:01:14 PM
Did we lose the ability to script for automatic face-down cards?
No. It should be /cflip, or /cf for short. The prefix /c means it is a function that operates on the selected card, as opposed to a general function, like /roll. /ccr=3 would be how to set the red counters to 3 for example, and /cr90 would set the card to rotated 90 degrees.

As I mentioned in the OP, the previous syntax is now obsolete. I could allow backwards compatibility, but I haven't. If you already altered your plugin's card data file, you could do something like a batch replace with the new syntax.


bakana

Is there any chance to be able to have a script autokick off when you draw the card or put the card back on top of the deck?

Trevor

Quote from: bakana on August 19, 2013, 07:57:44 PM
Is there any chance to be able to have a script autokick off when you draw the card or put the card back on top of the deck?
That seems like the sort of thing I don't think should be automated. Automation is great when it works, but at times it does something you don't want it to do, it's really annoying. I think the kind of script trigger you are talking about would be more trouble than its worth.

If you disagree, please let me know about a specific card and game where this sort of thing would be more useful than cumbersome.

If you want to know about a card that was just drawn, /lcd will announce the last card drawn to all players.

bakana

In XenoCard the cards in your deck are essentially your 'HP' stat.  Every time you draw a card your life should go down by one and if you put a card back on your deck your life can go up.  Was hoping clicking the draw button would allow for your life to be able to be affected as well.

Not a big deal if it isn't possible just wanted to see if it was possible. 

Trevor

Quote from: bakana on August 19, 2013, 11:13:39 PM
In XenoCard the cards in your deck are essentially your 'HP' stat.  Every time you draw a card your life should go down by one and if you put a card back on your deck your life can go up.  Was hoping clicking the draw button would allow for your life to be able to be affected as well.

Not a big deal if it isn't possible just wanted to see if it was possible.
The number of cards in your deck is a stat? So... why not just look at the number on the zone tab that displays that count? Assuming your player stat area isn't collapsed, it should be visible to all players at all times.

3XXXDDD



The earlier version of scripting didn't allow the name of the card to come up in the message area. Any way to change this? I've tested it both with just /cf as well as <s><a>y</a><l>Flip Card</l><f>/cf</f></s>.

Trevor

Quote from: 3XXXDDD on August 20, 2013, 12:01:24 PM


The earlier version of scripting didn't allow the name of the card to come up in the message area. Any way to change this? I've tested it both with just /cf as well as <s><a>y</a><l>Flip Card</l><f>/cf</f></s>.
The old method gave no log messages for anything, which was worse. The new method runs based on log commands, which is a lot more versatile, but I agree that it would be nice to have an option to do what you request. I'll think about how best to restore it.

comandercom

Is this updated in the plugin creation tutorial and if not where can I learn how to do this with my own plugin?

3XXXDDD

I'd suggest reading his post again. Everything is explained there.

Trevor


artrexdenthur

Quote from: Trevor on August 16, 2013, 02:39:47 PM
To use the scripts, it's similar to the old method where you make a column in your card data file called "Scripts".

Just in case anyone else has issues implementing this as I did, the correct column name is "Script" not "Scripts". Thank you for this, Trevor, this helps a lot with what I'm working on!