This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func pick(in: Node3D) -> Array: | |
var camera = get_viewport().get_camera_3d() | |
var center_pos = get_viewport().size / 2.0 | |
var mouse_pos = get_viewport().get_mouse_position() | |
var from = camera.project_ray_origin(center_pos) | |
var to = from + camera.project_ray_normal(mouse_pos) * 50.0 | |
var pick_results: Array[MeshInstance3D] = [] | |
for m in in.get_children(): | |
m = m as MeshInstance3D |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class_name DateHelper | |
static func date_add_days(date: Dictionary, days_to_add: int = 1) -> Dictionary: | |
assert(date.has("month"), "the date Dictionary must have a month") | |
assert(date.has("day"), "the date Dictionary must have a month") | |
assert(date.has("year"), "the date Dictionary must have a year") | |
var to_unix = OS.get_unix_time_from_datetime(date) + (86400 * days_to_add) | |
return OS.get_datetime_from_unix_time(to_unix) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function string:split(delimiter, max_matches) | |
-- Split a string by delimiter. The resulting table will be of size #max_matches. | |
max_matches = max_matches or #self | |
assert(max_matches > 0, "max_matches must be more than 0!") | |
local result = {} | |
local pos = 0 | |
for vstart, vend in function() return string.find(self, delimiter, pos, true) end do | |
table.insert(result, string.sub(self, pos, vstart - 1)) | |
pos = vend + 1 | |
if #result >= max_matches - 1 then |