Skip to content

Commit 52336b3

Browse files
committed
Added enums
1 parent 6f2428a commit 52336b3

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

gdscript/enum.gd

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
extends SceneTree
2+
3+
enum {CLUB, DIAMOND, SPADE, HEART}
4+
enum Direction {NORTH, EAST, SOUTH, WEST}
5+
enum Text {BOLD, ITALICS, UNDERLINE=-2, STRIKETHROUGH, SUBSCRIPT, SUPERSCRIPT}
6+
7+
func _init():
8+
var card = DIAMOND
9+
match card:
10+
CLUB:
11+
print("You have a Club")
12+
DIAMOND:
13+
print("You have a Diamond")
14+
SPADE:
15+
print("You have a Spade")
16+
HEART:
17+
print("You have a Heart")
18+
19+
var direction = Direction.WEST
20+
match direction:
21+
Direction.NORTH:
22+
print("Heading North")
23+
Direction.SOUTH:
24+
print("Heading South")
25+
1:
26+
print("Heading 1")
27+
3:
28+
print("Heading 3")
29+
Direction.EAST:
30+
print("Heading East")
31+
Direction.WEST:
32+
print("Heading West")
33+
34+
assert(Text.BOLD == Text.SUBSCRIPT)
35+
assert(Text.ITALICS == Text.SUPERSCRIPT)
36+
assert(SPADE == Direction.SOUTH)
37+
quit()

gdscript/test.ps1

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ godot --display-driver headless --no-header -s "$PSScriptRoot\clockhands_time.gd
2121
Assert-MatchTests &&
2222
godot --display-driver headless --no-header -s "$PSScriptRoot\code_regions.gd" &&
2323
godot --display-driver headless --no-header -s "$PSScriptRoot\documentation_comment.gd" &&
24+
godot --display-driver headless --no-header -s "$PSScriptRoot\enum.gd" &&
2425
godot --display-driver headless --no-header -s "$PSScriptRoot\fibonacci.gd" &&
2526
godot --display-driver headless --no-header -s "$PSScriptRoot\file_reader.gd" "$PSScriptRoot\..\test\carrots_expected" |
2627
Compare-Object (Get-Content "$PSScriptRoot\..\test\carrots_expected") |

0 commit comments

Comments
 (0)