G’day g’day…

Today is a chill day, a friend is having some drama so he’s on his way over to visit me to escape it all. I had some steam buns for lunch, while I waited for them to steam I did my Japanese cards for the day. I had a smoothie for breakfast. Generally, it’s a chill day.

Work on Speedrounds

I just wanted to make a blog post to showcase this thing I’m making that I find really cool. I’m making a tool that automatically uploads my game to steam at the click of a button! I’ll paste the code here when I’m done, but I’m quite proud of how it’s going so far.

@tool
extends Node


@export_tool_button("Upload to Steam") var upload = upload_to_steam

@export_group("Login")
@export var username: String
@export var password: String

@export_group("Set files")
@export_file var steam_cmd_executable: String
@export_dir var export_directories: Array[String]
@export_global_dir var steam_sdk_content_directories: Array[String]


func upload_to_steam() -> void:
	if export_directories.size() != steam_sdk_content_directories.size():
		printerr("Export directories does not match steam sdk content directories")
		return
	
	var output: Array[String] = []
	
	for i: int in range(export_directories.size()):
		var globalized_export_directory: String = ProjectSettings.globalize_path(export_directories[i])
		OS.execute("ls", [globalized_export_directory], output)
		print("ls output of %d directory: %s" % [i, str(output)])
		
		var files_to_move = output[0].split("\n")
		
		output = []
		for file_to_move in files_to_move:
			if not file_to_move.is_empty():
				print("Moving file %s" % [globalized_export_directory + file_to_move])
				if OS.execute("mv", [globalized_export_directory + file_to_move, steam_sdk_content_directories[i]], output):
					printerr("Failed to move file: %s" % str(output))
					return
	
	output = []
	OS.execute(steam_cmd_executable, ["+login", username, password, "+run_app_build", "../scripts/app_build_540120.vdf",  "+quit"], output, true, true)
	print("Uploaded to steam:\n %s" % str(output))

I didn’t comment it because it’s perfectly readable on its own :3 (I hope).

Screw it making a desktop pet

I’m adding onto that list of things I’m doing with making a desktop pet, I got fed-up with making Speedrounds since something wouldn’t work and I felt pressured to get something done with my friend being there (which is a good thing, kinda).

I got a basic desktop pet going, and I’m quite proud of the code once again, so here it is:

extends Node2D


const SPEED = 400

@onready var icon: Sprite2D = $Icon


func _ready() -> void:
	get_window().size = icon.texture.get_size()


func _physics_process(delta: float) -> void:
	var window = get_window()
	var moving_in_rect: Rect2 = Rect2(window.position.x, window.position.y, window.size.x, window.size.y) # The rect of where the pet is moving to
	
	# Get the moving direction according to input
	var direction: Vector2 = Input.get_vector("left", "right", "up", "down").normalized()
	moving_in_rect.position += direction * SPEED * delta
	
	# Get the middle of where is trying to be moved
	var moving_to_position: Vector2 = moving_in_rect.position + moving_in_rect.size / 2 
	
	# Make sure the window is inside the usable rect of the screen
	var outside_of_all_areas: bool = true
	for i in range(DisplayServer.get_screen_count()):
		var screen_usable_rect = DisplayServer.screen_get_usable_rect(i)
		if (
				moving_to_position.x < screen_usable_rect.end.x 
				and moving_to_position.x > screen_usable_rect.position.x 
				and moving_to_position.y < screen_usable_rect.end.y 
				and moving_to_position.y > screen_usable_rect.position.y
		):
			outside_of_all_areas = false
	
	# Move the pet if it's not moving outside of the screen
	if not outside_of_all_areas:
		window.position += Vector2i(direction * SPEED * delta)

This time it is commented, but pretty loosely, it’s fairly simple.