test-client-godot/assets/Scripts/Tools/hexa.gd
2020-01-24 19:56:51 +01:00

62 lines
1.2 KiB
GDScript3

extends Node
# Declare member variables here. Examples:
# var a = 2
# var b = "text"
# Called when the node enters the scene tree for the first time.
func _ready():
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
#func _process(delta):
# pass
func HexaArray(value):
match value:
0:
return "0"
1:
return "1"
2:
return "2"
3:
return "3"
4:
return "4"
5:
return "5"
6:
return "6"
7:
return "7"
8:
return "8"
9:
return "9"
10:
return "a"
11:
return "b"
12:
return "c"
13:
return "d"
14:
return "e"
15:
return "f"
_:
return "?"
func IntToStringHexa(value):
var ret = ""
ret += HexaArray(value >> 4)
ret += HexaArray(value & 15)
return ret
func ArrayIntToStringHexa(array_int):
var ret = ""
for data in array_int:
ret += IntToStringHexa(data)
return ret