Coding problems with custom cards.
by mtgrares
Moderators: timmermac, Blacksmith, KrazyTheFox, Agetian, friarsol, CCGHQ Admins
13 posts
• Page 1 of 1
Coding problems with custom cards.
by bte11ati » 31 Jan 2016, 23:35
I'm having some constant problem while coding my own cards for a small set to experiment with (I like programming).
First of all, more than rarely I get the error "...getAbility -- no Cost in [cardname]", prompting the game to crash. Why is this showing up? I ALWAYS have the cost where it should be. If I rewrite the entire line of code, the error disappears, even though the text is IDENTICAL.
Also, take this example. I copy the code from an existing card into my new one. It works perfectly. Then, if I would write the exact same thing into my new card instead, it doesn't work, or e.g the SubAbility doesn't trigger. I'm a pretty descent programmer so I just want to know if this is due to problem with the Forge-application itself and not me.
I'm also having some problem generally with the SubAbility not triggering. What might the causes for that be? (I'm on a Mac).
Thanks for reading and please respond if you've got any input at all!
First of all, more than rarely I get the error "...getAbility -- no Cost in [cardname]", prompting the game to crash. Why is this showing up? I ALWAYS have the cost where it should be. If I rewrite the entire line of code, the error disappears, even though the text is IDENTICAL.
Also, take this example. I copy the code from an existing card into my new one. It works perfectly. Then, if I would write the exact same thing into my new card instead, it doesn't work, or e.g the SubAbility doesn't trigger. I'm a pretty descent programmer so I just want to know if this is due to problem with the Forge-application itself and not me.
I'm also having some problem generally with the SubAbility not triggering. What might the causes for that be? (I'm on a Mac).
Thanks for reading and please respond if you've got any input at all!
Last edited by bte11ati on 01 Feb 2016, 14:04, edited 1 time in total.
Re: Coding problems with custom cards.
by friarsol » 01 Feb 2016, 00:24
Without seeing specific scripts, it's hard to conjecture. But I'm guessing if you are typing it out and it's not working, you probably have a small typo. All of the different parameters are case sensitive. I have written (literally) thousands of scripts and it's easy to get something slightly wrong during the scripting, names just slightly different or missing some necessary parsing characters.
Your OS shouldn't matter. If your SubAbilities aren't resolving, it's because they aren't being chained correctly. But as I mention, it's all conjecture without seeing the scripts.
Your OS shouldn't matter. If your SubAbilities aren't resolving, it's because they aren't being chained correctly. But as I mention, it's all conjecture without seeing the scripts.
- friarsol
- Global Moderator
- Posts: 7593
- Joined: 15 May 2010, 04:20
- Has thanked: 243 times
- Been thanked: 965 times
Re: Coding problems with custom cards.
by bte11ati » 01 Feb 2016, 14:03
Thanks for your response! I will try as I go along to find an example from the code. I can understand that I may chain the SubAbilities in the wrong manner (if you know any good thread or tutorial of this, it would be awesome if you showed me!). However, the Cost-error is seemingly random. It can be as simple as a A:AB$-AF without any SubAbilities. The code before and after are all correct, still I sometimes get the error. Is this completely unheard of?friarsol wrote:Without seeing specific scripts, it's hard to conjecture. But I'm guessing if you are typing it out and it's not working, you probably have a small typo.
Re: Coding problems with custom cards.
by bte11ati » 01 Feb 2016, 16:10
Here is an example of a problem with resolving triggers when I'm coding from scratch. The second trigger (from Battlefield to Graveyard) wont trigger at all. I have tried every possible combination of ValidCard$, ValidTgts$, Defined$ or ChangeType$, like Card.Self, Self etc, really everything and nothing works. Can you say what's wrong with this:friarsol wrote:But as I mention, it's all conjecture without seeing the scripts.
- Code: Select all
Name:Test Card
ManaCost:1 W
Types:Artifact Creature Soldier
PT:1/1
T:Mode$ ChangesZone | Origin$ Any | Destination$ Battlefield | ValidCard$ Card.Self | Execute$ TrigToken | TriggerDescription$ When CARDNAME enters the battlefield, put a 1/1 white Soldier token onto the battlefield.
T:Mode$ ChangesZone | Origin$ Battlefield | Destination$ Graveyard | ValidCard$ Card.Self | Execute$ TrigChangeZone | TriggerDescription$ Testtesttest.
SVar:TrigToken:AB$ Token | Cost$ 0 | TokenAmount$ 1 | TokenName$ Soldier | TokenTypes$ Creature,Soldier | TokenOwner$ You | TokenColors$ White | TokenPower$ 1 | TokenToughness$ 1 | TokenImage$ w 1 1 soldier M13
SVar:TrigChangeZone:AB$ChangeZone | Cost$ 0 | ValidCard$ Card.Self | Origin$ Graveyard | Destination$ Hand
Oracle$Blablabla.
Re: Coding problems with custom cards.
by bte11ati » 01 Feb 2016, 16:27
Ok, this is really frustrating. I wrote my own code (not copy paste), using Endless Cockroaches (with the same triggered ability) as a template. I matched it letter by letter by putting each line over one-another. This is my current code, STILL, the second trigger wont resolve. What am I missing here?
- Code: Select all
Name:Test Card
ManaCost:1 W
Types:Artifact Creature Soldier
PT:1/1
T:Mode$ ChangesZone | Origin$ Any | Destination$ Battlefield | ValidCard$ Card.Self | Execute$ TrigToken | TriggerDescription$ When CARDNAME enters the battlefield, put a 1/1 white Soldier token onto the battlefield.
T:Mode$ ChangesZone | Origin$ Battlefield | Destination$ Graveyard | ValidCard$ Card.Self | Execute$ TrigChangeZone | TriggerController$ TriggeredCardController | TriggerDescription$ Testtesttest CARDNAME.
SVar:TrigToken:AB$ Token | Cost$ 0 | TokenAmount$ 1 | TokenName$ Soldier | TokenTypes$ Creature,Soldier | TokenOwner$ You | TokenColors$ White | TokenPower$ 1 | TokenToughness$ 1 | TokenImage$ w 1 1 soldier M13
SVar:TrigChangeZone:AB$ChangeZone | Cost$ 0 | Origin$ Graveyard | Destination$ Hand | Defined$ TriggeredCard
Oracle$Blablabla.
Re: Coding problems with custom cards.
by friarsol » 01 Feb 2016, 17:05
Do you have multiple cards all named "Test Card"? Not the file name, but the name as defined inside the file. Names are unique in the Forge engine, so if you have a bunch of scripts all with the same name, they conflict with each other, causing only one of them to be available.
"Oracle$Blablabla." is definitely wrong. The first parse of each line is based on a colon. Not saying that's the cause of your problem but it would be "Oracle:Blahblah"
Are you restarting Forge after changing the cards? The scripts are only loaded during startup, so if you edit it and just try again, it's not going to change anything.
I took your script, fixed the Oracle issue, and tried it and both triggers work fine. So its probably one of those two things mentioned above
"Oracle$Blablabla." is definitely wrong. The first parse of each line is based on a colon. Not saying that's the cause of your problem but it would be "Oracle:Blahblah"
Are you restarting Forge after changing the cards? The scripts are only loaded during startup, so if you edit it and just try again, it's not going to change anything.
I took your script, fixed the Oracle issue, and tried it and both triggers work fine. So its probably one of those two things mentioned above
- friarsol
- Global Moderator
- Posts: 7593
- Joined: 15 May 2010, 04:20
- Has thanked: 243 times
- Been thanked: 965 times
Re: Coding problems with custom cards.
by bte11ati » 01 Feb 2016, 17:50
Both the filename and the given name are the same and unique and following the standard of naming (it also exists in my own set in the edition-folder).friarsol wrote:Do you have multiple cards all named "Test Card"? Not the file name, but the name as defined inside the file.
Oh yes, that's my fault, not very important though!friarsol wrote:"Oracle$Blablabla." is definitely wrong.
If you get it working as I wrote it (with the "oracle:" corrected) I can only conclude then that there's something wrong with how the program operates on my system (which I suspected with these many random errors) or the text-editor I'm using (Sublime Text 2). As a final example considering this card, now, the text when I trigger the tokens to produce in the stack isn't showing and the information (to the right in the default-match view) is missing for the first trigger. The tokens are there, but the trigger-information in the stack is blank. When I wrote this entry, the stack for the first trigger worked. Even though I haven't touched this code, this happens. I know it sounds like coding-error, but I can guarantee it isn't!
If you want, you can try it. This is for the file named test_soldier.txt, with the TriggerDescription missing...
- Code: Select all
Name:Test Soldier
ManaCost:1 W
Types:Artifact Creature Soldier
PT:1/1
T:Mode$ ChangesZone | Origin$ Any | Destination$ Battlefield | ValidCard$ Card.Self | Execute$ TrigToken | TriggerDescription$ When CARDNAME enters the battlefield, put a 1/1 white Soldier token onto the battlefield.
SVar:TrigToken:AB$ Token | Cost$ 0 | TokenAmount$ 1 | TokenName$ Soldier | TokenTypes$ Creature,Soldier | TokenOwner$ You | TokenColors$ White | TokenPower$ 1 | TokenToughness$ 1 | TokenImage$ w 1 1 soldier M13
Oracle:When CARDNAME enters the battlefield, put a 1/1 white soldier token onto the battlefield.
EDIT: Yes, I restart every time (maybe 3,249,012 times restarted in total now I guess...).
Last edited by bte11ati on 01 Feb 2016, 18:02, edited 1 time in total.
Re: Coding problems with custom cards.
by bte11ati » 01 Feb 2016, 17:54
And also, thanks for the all your inputs friarsol!
Re: Coding problems with custom cards.
by friarsol » 01 Feb 2016, 18:18
Try attaching one of your files instead of copying the contents? I use sublime text 2 as well, but your script looks the same as Attended Knight (aside from some number tweaks). I don't see why that should matter, since I know we've had mac users script cards before, and obviously "normal" cards work on your system. The only difference is how the file is being created/saved on your system, which still doesn't make sense.
- friarsol
- Global Moderator
- Posts: 7593
- Joined: 15 May 2010, 04:20
- Has thanked: 243 times
- Been thanked: 965 times
Re: Coding problems with custom cards.
by bte11ati » 01 Feb 2016, 18:57
So this is my process (for this example the card's name will be "Test Card" and the set "Test Set").friarsol wrote:Try attaching one of your files instead of copying the contents? I use sublime text 2 as well, but your script looks the same as Attended Knight (aside from some number tweaks). I don't see why that should matter, since I know we've had mac users script cards before, and obviously "normal" cards work on your system. The only difference is how the file is being created/saved on your system, which still doesn't make sense.
(0. Forge is not opened)
1. Create a picture and save it as "Test Card.full.jpg" in the pics\cards folder.
2. Create a .txt-file in res\cardsfolder\cardsfolder (unzipped folder) called "test_card.txt". Save it and keep Sublime Text 2 open.
3. Write the code as posted here (which works for you, but not for me).
4. Include the card to my Test Set.txt in res\editions as "C Test Card" (common rarity) below the other miscellaneous information under the right category [cards].
5. Starts forge and include my card to a test-deck.
6. ??????
7. Problems that shouldn't happen, happen. (in this example, the TriggerDescription$ fails to show for some reason).
Maybe there is something in my process that causes my problem? I attach the file that does what it should, but is glitchy regarding the stack-message. Thanks for your help!

- Attachments
-
test_card.txt
- (592 Bytes) Downloaded 203 times
Re: Coding problems with custom cards.
by friarsol » 01 Feb 2016, 21:58
So right before TriggerDescription you have a character that looks like a space , but isn't actually an ascii space? (according to my google search it's a non-breaking space) When I select your text the dot that represents a typical space doesn't show up there, so when we split on the '|' and then trim the front and end of that string, that non-breaking space isn't getting trimmed and you are left with the parameter:
"\xc2\xa0TriggerDescription" (At least that's what Python tells me this character is). Any idea how you are typing that?
I bet the same thing is happening when you are getting the Cost error.
Edit: Java's .trim() and how it interacts with non-breaking spaces: http://stackoverflow.com/questions/1060 ... er-in-java
"\xc2\xa0TriggerDescription" (At least that's what Python tells me this character is). Any idea how you are typing that?
I bet the same thing is happening when you are getting the Cost error.
Edit: Java's .trim() and how it interacts with non-breaking spaces: http://stackoverflow.com/questions/1060 ... er-in-java
- friarsol
- Global Moderator
- Posts: 7593
- Joined: 15 May 2010, 04:20
- Has thanked: 243 times
- Been thanked: 965 times
Re: Coding problems with custom cards.
by bte11ati » 01 Feb 2016, 23:19
Yes!! This has to be it! I will upload an image showing this in Sublime Text 2. If you mark everything, a dot is visible if it is a "true" space, and not if it isn't (See image). I will upload it for future reference if someone else have the same problem.friarsol wrote:So right before TriggerDescription you have a character that looks like a space , but isn't actually an ascii space? (according to my google search it's a non-breaking space)
Definitely!friarsol wrote:I bet the same thing is happening when you are getting the Cost error.
I will be more cautious while typing, but in all sincereness I don't know where the characters come from (any suggestions?). Maybe I will have to use MS Word with hidden characters on, because it seems weird to have to mark the text every time I make a space. Probably not gonna happen hehe. Anyhow, problem kind of solved! Thank you so much for your patience and help. Have a good one!

EDIT: Option+Space is the cause... I sometimes maybe press space before I let go of the Options-button
Re: Coding problems with custom cards.
by friarsol » 01 Feb 2016, 23:29
Not sure. I'm allergic to Macs, and I'm guessing it has to do with the OS spitting it out based on your a key combination. My best guess is that you are pressing Shift to get the pipe character '|' and not letting it go by the time you press Space, which gives you an nbsp? Honestly, what I'd do is just do a replace all right before you save of nbsp->sp.bte11ati wrote:I will be more cautious while typing, but in all sincereness I don't know where the characters come from (any suggestions?). Maybe I will have to use MS Word with hidden characters on, because it seems weird to have to mark the text every time a make a space. Probably not gonna happen hehe. Anyhow, problem kind of solved! Thank you so much for your patience and help. Have a good one!
Ah, a quick google search makes it sound like Option+Space gives you an nbsp: http://hints.macworld.com/article.php?s ... 1611584277
- friarsol
- Global Moderator
- Posts: 7593
- Joined: 15 May 2010, 04:20
- Has thanked: 243 times
- Been thanked: 965 times
13 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 8 guests