Else if / 'If' statements, goto, LSet

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

ILikeWoods
Topic author, Duke
Duke
ILikeWoods
Topic author, Duke
Duke
Reputation: 3
Posts: 124
Joined: 24 Jan 2016

Post #1by ILikeWoods » 13 Feb 2016, 20:10

If lvltimer(count)< 380 Then
Call ShowMsg("You need")
Else
End If


Yes, timer is running (down from 400) and stuff like that. However the message won`t be shown. Elseif is supposed to be optional and a statement within Else isn`t a must either. What have I done wrong in this case?
The if else structure is within the same script as the information about the position of the level timer itself.

Code: Select all

If condition Then
[statement]
[Elseif condition-n Then]
[statement]
[Else]
[statement]
End If


Once I know what is wrong here, the if else statement is supposed to make a certain layer visible. I already know it is working with LSet (thanks goddess at least I have an idea how to use it this time thanks to Catskart, I should be able to handle this then)

updated thread title
Last edited by ILikeWoods on 14 Feb 2016, 13:09, edited 1 time in total.

Erwill M
Count
Count
Avatar
Erwill M
Count
Count
Age: 24
Reputation: 189
Posts: 295
Joined: 29 Nov 2015

Post #2by Erwill » 13 Feb 2016, 23:34

I don't see any problem with your script, you need to create one event who autostart when the game start, and it'll be trigger himself. This event will be used for your script. ("Script" -> your script)

ILikeWoods
Topic author, Duke
Duke
ILikeWoods
Topic author, Duke
Duke
Reputation: 3
Posts: 124
Joined: 24 Jan 2016

Post #3by ILikeWoods » 13 Feb 2016, 23:46

You don`t see anything wrong? This is bad^^

Maybe there is a bug with the level timer ... but why using this in a seperat script? Does not make much sense to me. I mean I also used the code snippets for the position of the level timer in the screenx script without issues.

Code: Select all

val(ScreenXStart) = sysval(Player1scrX)
val(ScreenYStart) = sysval(Player1scrY)
lvltimer(x) = 650
lvltimer(y) = 25


I just added the if statement below. And SceenX IS set to Autostart ... but I will try it with an other script instead hmm

Yave Yu M
Count
Count
Avatar
Yave Yu M
Count
Count
Age: 27
Reputation: 50
Posts: 242
Joined: 25 Jan 2016

Post #4by Yave Yu » 14 Feb 2016, 3:34

You may try use a loop to solve this problem.
For example:

Code: Select all

Sssss: 'Sign
If lvlTimer(Count)<380 Then
 Call ShowMsg("You need")
End If
Call Sleep(1)
Goto Sssss 'Go back to Sssss

KFCMARIO
Good citizen
Good citizen
Avatar
KFCMARIO
Good citizen
Good citizen
Reputation: 21
Posts: 33
Joined: 25 Jan 2016

Post #5by KFCMARIO » 14 Feb 2016, 9:57

Your script will just run once when triggered.You could use a goto statement to make a loop.
Spoiler
TmerCheck:
If lvltimer(count)< 380 Then
Call ShowMsg("You need")
End If
Call Sleep(1) ‘Actually timer interval value replacing '1' could be more effective,for example your timer interval is 30 so this line could be Call Sleep(30) or Call Sleep(lvlTimer(Intv))
goto TmerCheck

ILikeWoods
Topic author, Duke
Duke
ILikeWoods
Topic author, Duke
Duke
Reputation: 3
Posts: 124
Joined: 24 Jan 2016

Post #6by ILikeWoods » 14 Feb 2016, 11:27

Your script will just run once when triggered

I guess this makes sense then, once you know that ... while I am somehow familiar with goto (even through I have been told using them is a nasty way to do things) I could not guess its necessity. At the latest "Call Sleep" I couldn`t have "guessed".

Code: Select all

TimerCheck:
If lvltimer(count)<= 100 AND lvltimer(count)> 95 Then
Call LSet(LOWTIMEINFOL,1,1)
Elseif lvltimer(count)<= 95 Then
Call LSet(LOWTIMEINFOL,0,1)
Else
End If
Call Sleep(1)
goto TimerCheck



[LSet]
LSet(layername, type, nosmoke)
type(Double) Style,0 = Show,1 = Hide,2 = Toggle
LSet is somehow messed. 1 = SHOWS (which makes more sense to me), but 0 does not HIDE, I had to use 2 to HIDE (well yes toggle seems to work). This really just can not be right ... Level Start is set to hide the "LOWTIMEINFOL" layer ... right at the start.
It would work that way, but if I want to use faked "+ clock" items to add additional time, it could cause some problems.

Or has already been a newer version released in the meantime?

Is there a "Call Event" function to call an event from the Events list, I was looking and wasn`t really sure.

KFCMARIO
Good citizen
Good citizen
Avatar
KFCMARIO
Good citizen
Good citizen
Reputation: 21
Posts: 33
Joined: 25 Jan 2016

Post #7by KFCMARIO » 14 Feb 2016, 13:37

ILikeWoods wrote:[LSet]
LSet(layername, type, nosmoke)
type(Double) Style,0 = Show,1 = Hide,2 = Toggle
LSet is somehow messed. 1 = SHOWS (which makes more sense to me), but 0 does not HIDE, I had to use 2 to HIDE (well yes toggle seems to work). This really just can not be right ... Level Start is set to hide the "LOWTIMEINFOL" layer ... right at the start.
It would work that way, but if I want to use faked "+ clock" items to add additional time, it could cause some problems.

Or has already been a newer version released in the meantime?

Is there a "Call Event" function to call an event from the Events list, I was looking and wasn`t really sure.

[TCreate]
TCreate(eventname, delay)

This function could call an event after specific frames,Call TCreate(eventname,0) means call specific event instantly

ILikeWoods
Topic author, Duke
Duke
ILikeWoods
Topic author, Duke
Duke
Reputation: 3
Posts: 124
Joined: 24 Jan 2016

Post #8by ILikeWoods » 19 Feb 2016, 19:10

Do {Until} lvltimer(count)< 375 AND lvltimer(count)> 320
Call TCreate(LowTime1b,0)
Call TCreate(LowTime0b,1000)
Exit Do

--
Syntax Error ... in the first line, well looks like I don`t understand this generic example in the scripting manual. I can`t even test if the change of events with waiting time is working at all. Once again: There are no proper examples.

Edit: Please .. I really can not find the mistake ...

Do [{While|Until} condition]
[statement]
[Exit Do]
Loop [{While|Until} condition]

or are there any released scripting heavy maps already which I could check for learning? I suppose there aren`t any yet (I just checked the clock script testmap, there isn`t one).

I guess this is the very final script addition I need, also my final "post cheating" (I suppose it is a little bit nasty).
After that no more trying, since it is not my cup of tea.


Return to “TeaScript”

Who is online (over the past 5 minutes)

Users browsing this forum: 1 guest