Skip to content

Instantly share code, notes, and snippets.

View me2beats's full-sized avatar

Albert me2beats

  • Russia, Yekaterinburg
View GitHub Profile
@me2beats
me2beats / button.gd
Created March 1, 2022 11:00
knopka zazhata 2 sec
extends Button
onready var timer = $Timer
func _on_Button_button_down():
timer.start()
func _on_Button_button_up():
timer.stop()
@me2beats
me2beats / plugin.gd
Last active November 22, 2021 02:19
auto_pos_3d
tool
extends EditorPlugin
var ray_length = 1000
var position3d_node_name = "Pos3D"
func handles(object):
@me2beats
me2beats / freelook.gd
Last active October 9, 2021 18:02
freelook camera test
# original: https://godotengine.org/asset-library/asset/701
extends Camera
export(float, 0.0, 1.0) var sensitivity = 0.25
# Mouse state
var _mouse_position = Vector2(0.0, 0.0)
var _total_pitch = 0.0
@me2beats
me2beats / file_utils.gd
Created September 4, 2021 21:15
file utils
static func get_files_by_ext(dir:String, extension:String, recursive=false)->Array:
var files = get_files(dir, recursive)
var res = []
for i in files:
if i.get_extension() == extension:
res.push_back(i)
return res
@me2beats
me2beats / script.gd
Created August 28, 2021 15:05
experimental
static func set_bit_vals(dict:Dictionary):
var i = 1
for key in dict:
dict[key] = i
i += i
@me2beats
me2beats / plugin.gd
Created July 5, 2021 18:33
Toggle expand bottom panel from plugin (hacky)
tool
extends EditorPlugin
func _enter_tree():
var base = get_editor_interface().get_base_control()
var expand_button:ToolButton = get_expand_bottom_panel_button(base)
expand_button.pressed = not expand_button.pressed
@me2beats
me2beats / signal_last_in_frame.gd
Created June 29, 2021 03:05
get signal last in frame emitting
# not reusable/ abstraction needed
tabcont.connect("tab_changed", self, 'on_signal_tab_changed')
connect("tab_changed__last_in_frame", self, "on_tab_changed__last_in_frame")
signal tab_changed__last_in_frame
var started: = false
var result:int
func on_signal_tab_changed(tab:int):
@me2beats
me2beats / code_utils.gd
Created June 24, 2021 17:07
code utils
# not tested!!
extends Object
class_name CodeUtils
static func code_line_split(s:String)->PoolStringArray:
var res: PoolStringArray
@me2beats
me2beats / grid.gd
Created June 11, 2021 10:51
simple grid for 3d (ImmediateGeometry)
extends ImmediateGeometry
export var offset = 0.01
export var grid_step = 1
export var grid_size = 10
func _ready():
begin(Mesh.PRIMITIVE_LINES)
var half_grid_size = grid_size/2.0
for i in range(-half_grid_size, half_grid_size+1):
@me2beats
me2beats / main.gd
Created June 8, 2021 07:21
godot building
func _ready():
pass