my script it throwing out of range errors

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

Shadowblitz16
Topic author, Close friend
Close friend
Shadowblitz16
Topic author, Close friend
Close friend
Reputation: 11
Posts: 93
Joined: 15 Aug 2016

Post #1by Shadowblitz16 » 5 Mar 2017, 6:48

can someone tell my why my script is crashing smbx and throwing out of range errors?

Code: Select all

'Script No.1 Name:New Script
//Check if the variable SineTimer is less or equal to zero
if (val(SineTimer) <= 0)
{
   //Resets SineShift and SineTimer
   val(SineShift) = -val(SineShift);
   val(SineTimer) = 10;
}   

//Moves the layer in a sine wave   
call LMove(Floats, .x, .y += val(SineShift);, 1);

Shadowblitz16
Topic author, Close friend
Close friend
Shadowblitz16
Topic author, Close friend
Close friend
Reputation: 11
Posts: 93
Joined: 15 Aug 2016

Post #2by Shadowblitz16 » 7 Mar 2017, 8:38

ok so here's a better script but it seems that it doesn't work
can someone tell me why?

Code: Select all

with Block(132)
   .y = val(Y) + val(Amp)*sin(.y/val(Freq))
End With


I have variables called Y, Amp, and Freq in my variables editor.
Y is set to 16
Amp is set to 100
Freq is set to 32

Lx Xzit M
Moderator
Moderator
Avatar
Lx Xzit M
Moderator
Moderator
Reputation: 213
Posts: 491
Joined: 9 Nov 2015
Website

Post #3by Lx Xzit » 12 Mar 2017, 6:17

What are you trying to do exactly? Your script is not working because you're telling to the game that work with the block 132 (not its ID, I mean, the block number 132 that you placed in the level) do this. Better use the script on this way:

Code: Select all

with block(getIDbyname("MyBlock"))
   *code*
end with


Note that "MyBlock" is the name of the block you want to do this script.

Pick up the block (or the blocks) you want do the script and name it as you want (in this case, "MyBlock", the name should always be the same as the script of course), like this:
Spoiler
Image
[size=100][b]VISIT MY YOUTUBE CHANNEL![/b] [url=https://www.youtube.com/channel/UC_AcXEExdYtaydxcCVPSGoQ]LX XZIT[/url][/size]
[size=100]Join our 38A Discord server! [url= https://discord.gg/7hCmNBE]CLICK HERE[/url][/size]

Shadowblitz16
Topic author, Close friend
Close friend
Shadowblitz16
Topic author, Close friend
Close friend
Reputation: 11
Posts: 93
Joined: 15 Aug 2016

Post #4by Shadowblitz16 » 19 Mar 2017, 3:59

first one still crashes with the same error.
and the second one doesn't do anything but shift the blocks to the right 1 by block

Ruther M
Citizen
Citizen
Avatar
Ruther M
Citizen
Citizen
Reputation: 0
Posts: 8
Joined: 23 Sep 2017
Website

Post #5by Ruther » 7 Oct 2017, 2:33

To first error is that you are writing with c ++ code and no Teascript

You wrote:
Spoiler
if (val (SineTimer) <= 0)
{
    // Resets SineShift and SineTimer
    val (SineShift) = -val (SineShift);
    val (SineTimer) = 10;
}
And it must have been:
Spoiler
if val (SineTimer) <= 0 then
    'Resets SineShift and SineTimer
    val (SineShift) = -val (SineShift);
    val (SineTimer) = 10;
end if

And the other error is inside the function Lmove when you putting an operation "+="

Try this script (to test)
Spoiler
val (coordinatey) =.y

do
with block (getIDbyname (Thenameofmylock))

.y = val (coordinatey) + val (Amp) * sin (val (a) * 0.017)
val (a) = val (a) +1
end with

call sleep (1)
loop


Return to “TeaScript”

Who is online (over the past 5 minutes)

Users browsing this forum: 1 guest