No problem, I understand you may be new at teascript. Well, here's an error:
Code: Select all
If Val(CoinCount)>Val(LocalCCount) Then
Val(LocalCCount)=Val(CoinCount)
Else
Val(LocalCCount)=Val(LocalCCount)
End If The code inside "else" block is redundant, saying X variable is equal to its value won't change anything, so with the first "if" block would've be enough, you don't need to cover actions that won't change anything.
This syntax is wrong:
It'll produce error. The right way to type it is:
Code: Select all
Val(LocalCCount) = Val(LocalCCount) + 1Another problem with the syntax is this:
Code: Select all
Else Val(CoinCount)=Val(CoinCount)When using "else" keyword there's no need to be condition in font of it, because else itself means "if any of the previous conditions were met". So unless you use a "elseif", don't put a condition in font of "else".
Also your code seems very confusing to me. A simpler way to do it is create 4 different scripts (one that adds 5, 10, 50 and 100)
1st script: name it "5 coins" and put this code in there:
Code: Select all
sysval(coincount) = sysval(coincount) + 5Click the 5-coin NPC in the NPC tab, go to Advanced > Events I > Death > 5 Coins [script]
2nd script: name it "10 coins" and put this code:
Code: Select all
sysval(coincount) = sysval(coincount) + 10Do the same you did with 5-coin NPC, but this time it triggers this script. Now do the same with the 50-coin and 100-coin, just remember to change the value in the code to the respective addition.
By this method all coins must trigger this script when collected ("dies"), if there's a coin that it's not configured like above it will work like an standard coin. There are other ways to do this, but I wanted to keep it simple. Since when a NPC dies the script stops executing inmediately, these kind of npcs needs to be treaty differently.
I Ran Out Of Other Coin Objects To Use
You can use GFX expansion feature, then you can have multiple coins in the same slot. Also I don't think is a good idea use the 3-up moon, it'll give you 4 lives when collected, you better use GFX expansion feature.
Regarding the sound effect:
AudioSet(1, 14, 0, "coin.ogg") This first line loads a
custom sound. This is not needed if you'll play a default sound.
AudioSet(2, 14, 0) This is the correct line since it'll play a default sound.
AudioSet(3, 14, 0) This line is unneeded. When a sound effect is called, it'll play at once and then stop (this unless you introduce special parameters).
Here you only need the second line so get rid of the first and third one. The reason why it drops error is because you missed the string at the second and third line (and first line string is wrong, it won't produce errors but if you're going to use custom sounds it wouldn't work, just to clarify).
So change the second line like this:
AudioSet(2, 14, 0, "")
The things between quotation marks is optional, it doesn't matter what you type here unless you're loading a sound effect, but you always need the quotations marks (remember; 1 for load sound effect, 2 for play and 3 to stop it).