Guest User

Untitled

a guest
Jun 30th, 2020
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.59 KB | None | 0 0
  1. extends Node
  2.  
  3. const LOG_NONE = 0
  4. const LOG_LOW = -50
  5. const LOG_VERBOSE = -100
  6.  
  7. const UTIL_LOG_LEVEL = 0
  8.  
  9. # Declare member variables here. Examples:
  10. # var a = 2
  11. # var b = "text"
  12.  
  13. # Called when the node enters the scene tree for the first time.
  14. func _ready():
  15. pass # Replace with function body.
  16.  
  17. # Called every frame. 'delta' is the elapsed time since the previous frame.
  18. #func _process(delta):
  19. # pass
  20.  
  21. static func my_log(string_variable, variable= ""):
  22. var time = my_time()
  23. var format_string = "%s: %s" % [time, string_variable]
  24. print("%s: \n %s" % [format_string, variable])
  25.  
  26. static func my_time():
  27. var base_time = OS.get_time()
  28. return "%s:%s:%s" % [base_time["hour"], base_time["minute"], base_time["second"]]
  29.  
  30. static func loud_log(message, variable, log_level = UTIL_LOG_LEVEL): # For any case which should alert
  31. if log_level <= LOG_NONE:
  32. my_log("LOUD " + message, variable)
  33.  
  34. static func low_log(message, variable, log_level = UTIL_LOG_LEVEL): # For issues of import
  35. if log_level <= LOG_LOW:
  36. my_log("LOW " + message, variable)
  37.  
  38. static func verbose_log(message, variable, log_level = UTIL_LOG_LEVEL): # For intense debugging
  39. if log_level <= LOG_VERBOSE:
  40. my_log("VERBOSE " + message, variable)
  41.  
  42. static func sprite_at_pos(position: Vector2, parent: Node, rotation: float=0.0):
  43. var sprite = Sprite.new()
  44. sprite.position = position
  45. sprite.texture = load("res://icon.png")
  46. sprite.rotate(deg2rad(rotation))
  47. parent.add_child(sprite)
  48.  
  49. static func avg(elems) -> float:
  50. var sum: float = 0.0
  51. for item in elems:
  52. sum += item
  53. sum /= elems.size()
  54. return sum
Add Comment
Please, Sign In to add comment