Skip to content
This repository was archived by the owner on Aug 16, 2024. It is now read-only.

If Statements

JXSnack edited this page Apr 2, 2023 · 2 revisions

Creating an if statement

Creating if statements is really easy. Everything that is after an if statement will be part of that if statement.
If statements can only be executed in a function or check. Not in variables! If you want to use variables in if statements or checks, put a v: infront of the variable!

Example

"functions": {
	"foo_check": {
		"args": {},
		"execute": [
			["if", "v:foo", "is", 5],
			["log", "Wow! Foo is really cool right now"],
			["end"]
		]
	}
},

Expanding an if statement with else or elif

You can also expand the if statement by using the else or elif command.

Elif example

"functions": {
	"foo_check": {
		"args": {},
		"execute": [		
			["if", "v:foo", "is", 5],
			["log", "Wow! Foo is really cool right now"],
			["elif", "v:foo", "is", 10],
			["log", "Whoa, that's a really large foo!"],
			["end"]
		]
	}
},

Elif needs argument like if

Else example

"functions": {
	"foo_check": {
		"args": {},
		"execute": [		
			["if", "v:foo", "is", 5],
			["log", "Wow! Foo is really cool right now"],
			["else"],
			["log", "Foo is not 5 right now!"],
			["end"]
		]
	}
},

Else doesn't have any arguments, but also needs to be in an if or elif.

Full example

"functions": {
	"foo_check": {
		"args": {},
		"execute": [
			["if", "v:foo", "is", 5],
			["log", "Wow! Foo is really cool right now"],
			["elif", "v:foo", "is", 10],
			["log", "Whoa, that's a really large foo!"],
			["elif", "v:foo", "is", 8],
			["log", "Medium sized foo"],
			["elif", "v:foo", "is", 3],
			["log", "Small sized foo"],
			["else"],
			["log", "Foo isn't 10, 8, 5 or 3"],
			["end"]
		]
	}
},

CrystalStudio

  • Settings
    • Custom theme (coming soon)
  • Project
    • Creating project (coming soon)
    • Open project (coming soon)
    • Bookmark project (coming soon)
  • Editor
    • Buttons (coming soon)
    • Scenes (coming soon)
    • Texts (coming soon)
    • Build/play Game (coming soon)

CrystalScript

Clone this wiki locally