Page 2 of 2

Posted: 31 Dec 2017, 0:18
by SuperMarioLevels134
I've been trying to make an idle animation by having a npc that is taking place over the charecter, how would I do this?
Here's my level: ... SnHma?dl=0

What's the code to change transparency of an NPC?

Posted: 8 Jan 2018, 15:50
by Prado
How to change the transparency of an NPC with scripts?

Also, how to make NPC hurt only at certain transparency levels?

Edit: found it, nevermind.

How to fix this?

Posted: 18 Apr 2018, 22:46
by Spectra
How do i fix this error?

Code: Select all

call sysval "(sys "Disablejump")
call sysval "(sys "Disablespinjump")

edit: I did it with events

Holding ID?

Posted: 3 Jul 2018, 19:02
by 3color BombDX
Hello, I just want to know how can I identify using the tea-script what NPC ID is the player holding?

Layer Won't Spin

Posted: 31 Jul 2018, 8:35
by P-Switch
I'm Trying To Make A Ring Of Coins Spin Around A ? Block, Yet Using The LSpin Command On A Layer Called "Block 1" Does Nothing. Can Someone Help Me Here?
If You're Wondering, Here's The Command.
Call LSpin("Block 1", -199568+16, -200144+16, 0.02)

Posted: 31 Jul 2018, 9:24
by Lx Xzit
I don't see anything wrong with your code, are you sure it's triggered through events?

Posted: 31 Jul 2018, 21:42
by P-Switch
Lx Xzit wrote:I don't see anything wrong with your code, are you sure it's triggered through events?
Hmm, Well, Sorry For My Error, I'm Still New To Scripting, But I Thought The Scripts Triggered Automatically Unless Specified Not To.
(EDIT: I Figured Out Where In The Events Section Where To Trigger Events. Thanks For Telling Me That Events Triggered Them.)
Edit #2:
I Have Some New Problems, Specifically, 2. I'm Trying To Add To The Coin Counter, Since I'm Making 5, 10, 50, And 100 Coin NPC's. But The Script I'm Using Is Not Working.
Here's The Script (Remember, I'm Pretty New To Scripting, In Fact, The Level I'm Scripting Is My First Scripted Level, So If It's All Wrong, Sorry):
If Val(CoinCount)>Val(LocalCCount) Then
End If
If Val(LocalCCount)=Val(CoinCount) Then
Else Val(CoinCount)=Val(CoinCount)
End If
I Also Wrote A Second Script That Adds To The LocalCCount Variable:
Now, The Second Problem.
Since The 100-Coin Object Has To Be The 3-Up Moon, Because I Ran Out Of Other Coin Objects To Use, It Doesn't Make A Coin Sound When Collected, So I Tried Using The AudioSet Command To Play A Sound Effect. But It Brings Up A '12' Error, So It Does Nothing.
The Following Is The Script:
AudioSet(1, 14, 0, "coin.ogg")
AudioSet(2, 14, 0)
AudioSet(3, 14, 0)

Posted: 1 Aug 2018, 8:25
by Lx Xzit
No problem, I understand you may be new at teascript. Well, here's an error:

Code: Select all

If Val(CoinCount)>Val(LocalCCount) Then
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:

Code: Select all


It'll produce error. The right way to type it is:

Code: Select all

Val(LocalCCount) = Val(LocalCCount) + 1

Another 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) + 5

Click 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) + 10

Do 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).

Posted: 1 Aug 2018, 9:17
by P-Switch
(Lx Xzit, I Would've Quoted That Block Of Text Here, But It Was Too Big.)
Firstly, I Planned To Add The 5, 10, 50, And 100 Bonuses Separately After You Explained What Was Wrong With My Scripts, (Since If It Was Already Broken, I Didn't Really Need To Make More of The Useless Thing, Right?) Secondly, The 3-UP Bonus For The Moon Is Not Actually Hard-Coded, So Just Changing The "Score" Setting In A Custom .TXT NPC File Was All I Had To Do. I Think Though I Will Use The GFX Expansion Idea, But Since I Didn't Use It For The 100-Coin, You Can Probably See That I Don't Know How It Works (I Haven't Really Dipped Into All The Fancy Features Yet.) For The AudioSet Loading Option Though, The Scripting Help File Never Said Anything About It Only Loading Custom Files, So I Blame That Error On It. For All The Other Errors I Made, Those Were Mostly My Fault, I Kind of Rushed Making That First Script. I Was Really Impatient That It Would Work, So I Was Too Hasty. Lastly, Thanks For Helping Me With The Scripts! I'm Glad This Help Thread Exists.
(Knowing That I Can Directly Add To The CoinCount System Value, Kind Of Defeats The Purpose Of The LocalCCount Value, As I Thought The CoinCount Value Couldn't Be Directly Changed, Since The Scripting Help File Said System Values Couldn't Be Edited Directly. Someone Should Really Edit That Thing.)

EDIT: Something ELSE Has Gong Wrong With The Scripts, Sure, The 5, 10, 50, And 100 Coin NPC's Work Now, But, The Coin Counter Stops At 99 If I Collect Any Scripted Coins. Only Un-Scripted Coins Can Go Over 99 And Give The 1-UP. Which Means, The Scripted Coins Are Useless.

Coins Not Adding Up

Posted: 12 Aug 2018, 15:22
by P-Switch
Well, I May Be Thankful For That Coin Adding Script, It Does Not Seem To Work Like I Thought It Would. Mainly Because Once The Coin Count Reaches 99, Unless A Un-Scripted Coin Is Collected, The Scripted Coins WON'T Make The Coin Counter Go Over To 100, And Give The Player A 1UP, As Such, The Script Seems To Be Practically Useless Due To This Error.
(Lx Xzit, You Made That Error Since You Corrected The Script, So Technically, You Have To Fix It. Sorry, Its Classic "Your Fault" Rules.)

Teascripting Issues

Posted: 14 Apr 2019, 21:08
by Sam4354
I am new to Teascripting in SMBX 1.4.4 (38A), so I guess feel dumb for saying this, but, using this tool to script NPCs is a lot more complicated then I hoped for. I tried researching it up, and I got almost nothing. So I was wondering if anyone can give me a tutorial on how to script NPCs. If anyone is able to help, then I respect that.

Broken Variables

Posted: 26 May 2019, 2:26
by P-Switch
Hey, I've been on this topic before, clearly, but I have something else I need help with: Variables. I hadn't done anything with them until now, although the scripts I constructed aren't working. It's supposed to be 8 NPC's circling around a core. Each time a piece of the shield is destroyed, the circling NPC's move a little faster. Once all 8 Shield NPC's are destroyed, the core becomes vulnerable. Although, the scripts don't seem to work.
Here's the two scripts:
Script Name:ProtectShieldDamage

Code: Select all

if var(ShieldDamageActive) == 1
   var(ShieldSpeed) = var(ShieldSpeed) + 0.01
   var(ShieldDamageActive) = 0
end if
if var(ShieldSpeed) > 0.45
   var(ShieldSpeed) = 0.45
end if

Script Name:ProtectShieldSpin

Code: Select all

Call Var(ShieldSpeed)
Call LSpin("ProtectShield",-199632+16,-200272+16,ShieldSpeed)

The Variable "ShieldSpeed" Starts at 0.01, meanwhile "ShieldDamageActive" starts at 0 and turns to 1 once a shield part is destroyed. I plan to make a script to handle the incrementing of ShieldDamageActive once these scripts are fixed.

Posted: 26 May 2019, 5:39
by Lx Xzit
Remember that Tea-Script is not related to C nor JavaScript, it's a pseudo-language and the syntaxis is different.
When you use a variable, you must create it in the variables tab (which is found in "view" > "variables"). Once you do so the variable is already initialized and you can use them as you want. But when you use variables in scripts, they must be in parenthesis and accompanied by the keyword "var" or "v". So for example if you have a variable called "blocks":

Code: Select all


are both valid.

Aside from that, I noticed some syntaxis errors:

For the first script:
1-"if" statements should have an "end" at the end of the line. You also don't use double "=" to differentiate between assigning values and comparing them. So under any circumstance you should use two "=" together.
2-"tcreate" needs a "call"

For the second script:
1- You don't need to "call" a variable, this line is unnecessary.
2- In the last parameter of "LSpin", everytime you use a variable you should put it in parenthesis and use the keyword "var" or "v" (to be honest I never use "var").

Background Script throwing Errors

Posted: 10 Mar 2020, 11:48
by Dry Bones
I've been trying to split a BG into three sections that are moving at different Speeds using the following script:

Code: Select all

bgp(9).splitter=340 , 538
bgp(9).zsp=0.25 , 0

Problem is that everytime I want to split it into more than two sections, I get the following error "Expression can't be null".
Thing is, I used the exact same structure as in the Scripting Help Document (int / float numbers separated by commas).
(By the way, is there any way of using .splitcount and .splitter with Background 10?)

Posted: 30 Jun 2020, 0:11
by Toy Bonnie
Is there any way to know when a NPC entered a liquid? I'm trying to make a SMW Dolphin script.

Posted: 30 Jun 2020, 2:00
by Lx Xzit
Toy Bonnie wrote:Is there any way to know when a NPC entered a liquid? I'm trying to make a SMW Dolphin script.
Use "inwater" property, (like "if .inwater = 1 then") you can also detect liquids through iterators