You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-22 15:06:45 +00:00
Merge pull request #52100 from vnen/gdscript-access-outer-constants
GDScript: Allow access to outer constant and enum values
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
extends Node
|
||||
|
||||
const NO_TYPE_CONST = 0
|
||||
const TYPE_CONST: int = 1
|
||||
const GUESS_TYPE_CONST := 2
|
||||
|
||||
class Test:
|
||||
var a = NO_TYPE_CONST
|
||||
var b = TYPE_CONST
|
||||
var c = GUESS_TYPE_CONST
|
||||
|
||||
func test():
|
||||
var test_instance = Test.new()
|
||||
prints("a", test_instance.a, test_instance.a == NO_TYPE_CONST)
|
||||
prints("b", test_instance.b, test_instance.b == TYPE_CONST)
|
||||
prints("c", test_instance.c, test_instance.c == GUESS_TYPE_CONST)
|
||||
@@ -0,0 +1,4 @@
|
||||
GDTEST_OK
|
||||
a 0 True
|
||||
b 1 True
|
||||
c 2 True
|
||||
@@ -0,0 +1,14 @@
|
||||
extends Node
|
||||
|
||||
enum Named { VALUE_A, VALUE_B, VALUE_C = 42 }
|
||||
|
||||
class Test:
|
||||
var a = Named.VALUE_A
|
||||
var b = Named.VALUE_B
|
||||
var c = Named.VALUE_C
|
||||
|
||||
func test():
|
||||
var test_instance = Test.new()
|
||||
prints("a", test_instance.a, test_instance.a == Named.VALUE_A)
|
||||
prints("b", test_instance.b, test_instance.b == Named.VALUE_B)
|
||||
prints("c", test_instance.c, test_instance.c == Named.VALUE_C)
|
||||
@@ -0,0 +1,4 @@
|
||||
GDTEST_OK
|
||||
a 0 True
|
||||
b 1 True
|
||||
c 42 True
|
||||
@@ -0,0 +1,14 @@
|
||||
extends Node
|
||||
|
||||
enum { VALUE_A, VALUE_B, VALUE_C = 42 }
|
||||
|
||||
class Test:
|
||||
var a = VALUE_A
|
||||
var b = VALUE_B
|
||||
var c = VALUE_C
|
||||
|
||||
func test():
|
||||
var test_instance = Test.new()
|
||||
prints("a", test_instance.a, test_instance.a == VALUE_A)
|
||||
prints("b", test_instance.b, test_instance.b == VALUE_B)
|
||||
prints("c", test_instance.c, test_instance.c == VALUE_C)
|
||||
@@ -0,0 +1,4 @@
|
||||
GDTEST_OK
|
||||
a 0 True
|
||||
b 1 True
|
||||
c 42 True
|
||||
Reference in New Issue
Block a user