From 9d21b47e2833a693352c8832575bf483d5bc4699 Mon Sep 17 00:00:00 2001 From: Torsten Date: Sun, 14 Apr 2024 19:01:00 +0200 Subject: [PATCH] Started working on Hetzner API --- .../AWA/01a_Hetzner/ssh login and setup.md | 19 ++++++++++++ .../Snippets/Load and instantiate scene.md | 6 ++++ .../Picking a random item from an array.md | 3 ++ .../Randomly spawn objects on the screen.md | 29 +++++++++++++++++++ MyObsidianVault/AWA/Godot/Snippets/Timers.md | 5 ++++ 5 files changed, 62 insertions(+) create mode 100644 MyObsidianVault/AWA/01a_Hetzner/ssh login and setup.md create mode 100644 MyObsidianVault/AWA/Godot/Snippets/Load and instantiate scene.md create mode 100644 MyObsidianVault/AWA/Godot/Snippets/Picking a random item from an array.md create mode 100644 MyObsidianVault/AWA/Godot/Snippets/Randomly spawn objects on the screen.md create mode 100644 MyObsidianVault/AWA/Godot/Snippets/Timers.md diff --git a/MyObsidianVault/AWA/01a_Hetzner/ssh login and setup.md b/MyObsidianVault/AWA/01a_Hetzner/ssh login and setup.md new file mode 100644 index 0000000..1f74eab --- /dev/null +++ b/MyObsidianVault/AWA/01a_Hetzner/ssh login and setup.md @@ -0,0 +1,19 @@ +ssh -i /home/tschneider/.ssh/hetzner_id_rsa root@167.235.131.137 + + +```bash +wget https://www.zauberturm.de/awa/downloads/master_server.x86_64 +wget https://www.zauberturm.de/awa/downloads/scene_server.x86_64 +chmod +x master_server.x86_64 scene_server.x86_64 + +./master_server.x86_64 --headless > master_log.txt & +./scene_server.x86_64 --headless > scene_log.txt & # TODO: Set unique log name +``` + + + +VServer self-discover IPV4 address: +```bash +root@ubuntu-2gb-nbg1-1:~# curl -s http://169.254.169.254/hetzner/v1/metadata|grep public-ipv4|awk -F ': ' '{print $2}' +167.235.131.137 +``` \ No newline at end of file diff --git a/MyObsidianVault/AWA/Godot/Snippets/Load and instantiate scene.md b/MyObsidianVault/AWA/Godot/Snippets/Load and instantiate scene.md new file mode 100644 index 0000000..16e3099 --- /dev/null +++ b/MyObsidianVault/AWA/Godot/Snippets/Load and instantiate scene.md @@ -0,0 +1,6 @@ +```python +func _ready() -> void: + var gem_scene := preload("gem.tscn") + var gem_instance := gem_scene.instantiate() + add_child(gem_instance) +``` diff --git a/MyObsidianVault/AWA/Godot/Snippets/Picking a random item from an array.md b/MyObsidianVault/AWA/Godot/Snippets/Picking a random item from an array.md new file mode 100644 index 0000000..bb4c426 --- /dev/null +++ b/MyObsidianVault/AWA/Godot/Snippets/Picking a random item from an array.md @@ -0,0 +1,3 @@ +```python +random_item_scene: PackedScene = item_scenes.pick_random() +``` \ No newline at end of file diff --git a/MyObsidianVault/AWA/Godot/Snippets/Randomly spawn objects on the screen.md b/MyObsidianVault/AWA/Godot/Snippets/Randomly spawn objects on the screen.md new file mode 100644 index 0000000..df3091d --- /dev/null +++ b/MyObsidianVault/AWA/Godot/Snippets/Randomly spawn objects on the screen.md @@ -0,0 +1,29 @@ +```python +extends Node2D + +var item_scenes := [ + preload("gem.tscn"), + preload("health_pack.tscn") +] + +func _ready(): + get_node("Timer").timeout.connect(_on_timer_timeout) + + + +func _process(delta): + pass + + +func _on_timer_timeout() -> void: + + var random_item_scene: PackedScene = item_scenes.pick_random() + var item_instance = random_item_scene.instantiate() + add_child(item_instance) + + var viewport_size = get_viewport_rect().size + var random_position := Vector2(0,0) + random_position.x = randf_range(0, viewport_size.x) + random_position.y = randf_range(0, viewport_size.y) + item_instance.position = random_position +``` \ No newline at end of file diff --git a/MyObsidianVault/AWA/Godot/Snippets/Timers.md b/MyObsidianVault/AWA/Godot/Snippets/Timers.md new file mode 100644 index 0000000..5c439eb --- /dev/null +++ b/MyObsidianVault/AWA/Godot/Snippets/Timers.md @@ -0,0 +1,5 @@ + +Connecting the timeout signal of timer to a local function +```python +get_node("Timer").timeout.connect(_on_timer_timeout) +``` \ No newline at end of file