TeaScript Help Thread

Description: Internal scripting system of SMBX-38A Engine based on the simple VB-like language
Moderators: Yoshi021, Lx Xzit, 5438A38A, Semi-moderatos, Moderators

SuperMarioLevels134
Nice citizen
Nice citizen
Avatar
SuperMarioLevels134
Nice citizen
Nice citizen
Reputation: 0
Posts: 12
Joined: 25 May 2016

Post #21by SuperMarioLevels134 » 31 Dec 2017, 0:18

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: https://www.dropbox.com/sh/0614muxfus4a ... SnHma?dl=0

Prado M
Honourable citizen
Honourable citizen
Avatar
Prado M
Honourable citizen
Honourable citizen
Age: 19
Reputation: 2
Posts: 49
Joined: 14 Sep 2015
Location: Brazil

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

Post #22by Prado » 8 Jan 2018, 15:50

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.
Discord server to play SMBX online via Parsec!

https://discord.gg/FftYYMv

Spectra
Duke
Duke
Avatar
Spectra
Duke
Duke
Age: 19
Reputation: 6
Posts: 125
Joined: 30 Jan 2018
Location: The dream star
YouTube

How to fix this?

Post #23by Spectra » 18 Apr 2018, 22:46

How do i fix this error?

Code: Select all

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



edit: I did it with events
-No interesting comments here-

Tricolor BombDX
Our friend
Our friend
Avatar
Tricolor BombDX
Our friend
Our friend
Age: 15
Reputation: 8
Posts: 59
Joined: 8 May 2018
Location: Brazil

Holding ID?

Post #24by Tricolor BombDX » 3 Jul 2018, 19:02

Hello, I just want to know how can I identify using the tea-script what NPC ID is the player holding?
I support these projects:
[list]MARIO & LUIGI - The Great Quest
Super Mario - Rainbow Road
Super Mario Bros.: The Great Adventure
Adventures in 2DU
[/list]

P-Switch
Nice citizen
Nice citizen
Avatar
P-Switch
Nice citizen
Nice citizen
Reputation: -6
Posts: 15
Joined: 25 Jul 2018
Location: Super Mario World

Layer Won't Spin

Post #25by P-Switch » 31 Jul 2018, 8:35

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)
Why are you looking at my signature, anyway? There's nothing of importance here.

Lx Xzit M
Moderator
Moderator
Avatar
Lx Xzit M
Moderator
Moderator
Reputation: 265
Posts: 601
Joined: 9 Nov 2015
Website

Post #26by Lx Xzit » 31 Jul 2018, 9:24

I don't see anything wrong with your code, are you sure it's triggered through events?
VISIT MY YOUTUBE CHANNEL! LX XZIT
Join our 38A Discord server!

Image

P-Switch
Nice citizen
Nice citizen
Avatar
P-Switch
Nice citizen
Nice citizen
Reputation: -6
Posts: 15
Joined: 25 Jul 2018
Location: Super Mario World

Post #27by P-Switch » 31 Jul 2018, 21:42

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):
(BEGIN SCRIPT)
If Val(CoinCount)>Val(LocalCCount) Then
Val(LocalCCount)=Val(CoinCount)
Else
Val(LocalCCount)=Val(LocalCCount)
End If
If Val(LocalCCount)=Val(CoinCount) Then
Val(CoinCount)=Val(LocalCCount)
Else Val(CoinCount)=Val(CoinCount)
End If
(END SCRIPT)
I Also Wrote A Second Script That Adds To The LocalCCount Variable:
(BEGIN SCRIPT)
Val(LocalCCount)+1
(END SCRIPT)
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:
(BEGIN SCRIPT)
AudioSet(1, 14, 0, "coin.ogg")
AudioSet(2, 14, 0)
AudioSet(3, 14, 0)
(END SCRIPT)
Why are you looking at my signature, anyway? There's nothing of importance here.

Lx Xzit M
Moderator
Moderator
Avatar
Lx Xzit M
Moderator
Moderator
Reputation: 265
Posts: 601
Joined: 9 Nov 2015
Website

Post #28by Lx Xzit » 1 Aug 2018, 8:25

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:

Code: Select all

Val(LocalCCount)+1

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).
VISIT MY YOUTUBE CHANNEL! LX XZIT
Join our 38A Discord server!

Image

P-Switch
Nice citizen
Nice citizen
Avatar
P-Switch
Nice citizen
Nice citizen
Reputation: -6
Posts: 15
Joined: 25 Jul 2018
Location: Super Mario World

Post #29by P-Switch » 1 Aug 2018, 9:17

(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.
Why are you looking at my signature, anyway? There's nothing of importance here.

P-Switch
Nice citizen
Nice citizen
Avatar
P-Switch
Nice citizen
Nice citizen
Reputation: -6
Posts: 15
Joined: 25 Jul 2018
Location: Super Mario World

Coins Not Adding Up

Post #30by P-Switch » 12 Aug 2018, 15:22

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.)
Why are you looking at my signature, anyway? There's nothing of importance here.

Sam4354
Passerby
Passerby
Sam4354
Passerby
Passerby
Reputation: 0
Posts: 1
Joined: 14 Apr 2019

Teascripting Issues

Post #31by Sam4354 » 14 Apr 2019, 21:08

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.

P-Switch
Nice citizen
Nice citizen
Avatar
P-Switch
Nice citizen
Nice citizen
Reputation: -6
Posts: 15
Joined: 25 Jul 2018
Location: Super Mario World

Broken Variables

Post #32by P-Switch » 26 May 2019, 2:26

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
   TCreate(ShieldDestroyed,1)
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.
Why are you looking at my signature, anyway? There's nothing of importance here.

Lx Xzit M
Moderator
Moderator
Avatar
Lx Xzit M
Moderator
Moderator
Reputation: 265
Posts: 601
Joined: 9 Nov 2015
Website

Post #33by Lx Xzit » 26 May 2019, 5:39

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

var(blocks)
v(blocks)

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").
VISIT MY YOUTUBE CHANNEL! LX XZIT
Join our 38A Discord server!

Image


Return to “TeaScript”

Who is online (over the past 5 minutes)

Users browsing this forum: 6 guests