From a7f4c343dec519688e7ce6bb41de2171bcec2500 Mon Sep 17 00:00:00 2001 From: Sage The DM Date: Thu, 17 Apr 2025 19:39:33 +0200 Subject: [PATCH] changed the word amount --- the-scavanger/.godot/editor/editor_layout.cfg | 4 +- .../.godot/editor/script_editor_cache.cfg | 6 +- the-scavanger/scripts/player.gd | 58 ++++++++----------- 3 files changed, 30 insertions(+), 38 deletions(-) diff --git a/the-scavanger/.godot/editor/editor_layout.cfg b/the-scavanger/.godot/editor/editor_layout.cfg index e1e3f15..b0f3030 100644 --- a/the-scavanger/.godot/editor/editor_layout.cfg +++ b/the-scavanger/.godot/editor/editor_layout.cfg @@ -38,8 +38,8 @@ selected_bottom_panel_item=0 [EditorWindow] screen=2 -mode="windowed" -position=Vector2i(1921, 31) +mode="maximized" +position=Vector2i(1920, 23) size=Vector2i(1416, 1000) [ScriptEditor] diff --git a/the-scavanger/.godot/editor/script_editor_cache.cfg b/the-scavanger/.godot/editor/script_editor_cache.cfg index f1ce6c1..a934e84 100644 --- a/the-scavanger/.godot/editor/script_editor_cache.cfg +++ b/the-scavanger/.godot/editor/script_editor_cache.cfg @@ -3,11 +3,11 @@ state={ "bookmarks": PackedInt32Array(), "breakpoints": PackedInt32Array(), -"column": 15, +"column": 0, "folded_lines": Array[int]([]), "h_scroll_position": 0, -"row": 13, -"scroll_position": 0.0, +"row": 72, +"scroll_position": 50.0, "selection": false, "syntax_highlighter": "GDScript" } diff --git a/the-scavanger/scripts/player.gd b/the-scavanger/scripts/player.gd index baa891d..000f430 100644 --- a/the-scavanger/scripts/player.gd +++ b/the-scavanger/scripts/player.gd @@ -23,62 +23,54 @@ var has_red_potion = false var has_green_potion = false var coin_count = 0 -var word_chunks = [] # Array to store the tokenized words -var current_chunk_index = 0 # Keeps track of the current chunk +var word_chunks = [] # Stores the words to show in chunks +var current_chunk_index = 0 # Tracks which chunk we're on -# Function to prepare and show text in 5-word chunks +# Call this to start displaying the text in chunks func show_text_in_chunks(full_text: String) -> void: - # Add mystical Latin phrase at the end for a wizard or knight - full_text += " Ave Domine Limosus, dominator omnium slime!" + # Add wizard/knight-style ending at the end + full_text += " Ave Domine Limosus, gloria regni slime aeterni!" - # Split the full text into words, keeping punctuation separate + # Tokenize the full text into words and punctuation word_chunks = tokenize_text(full_text) current_chunk_index = 0 $"TextEdit".visible = true - $"TextEdit".text = "" # Clear the text before starting + $"TextEdit".text = "" # Start clean - set_process(true) # Enable processing for the _process function + set_process(true) # Allow input checking in _process -# Function to tokenize the text into words and punctuation separately +# Tokenize text into words and punctuation marks separately func tokenize_text(text: String) -> Array: var regex = RegEx.new() - regex.compile(r"[\w']+|[.,!?;]") # Regular expression to split words and punctuation + regex.compile(r"[\w']+|[.,!?;]") # Match words and punctuation var matches = regex.search_all(text) var tokens = [] for match in matches: - tokens.append(match.strings[0]) # Append each matched token + tokens.append(match.strings[0]) return tokens -# Process function to handle input and display text chunks -func _process(delta): - # Check if there are more chunks to display and listen for input - if current_chunk_index * 5 < word_chunks.size(): - if Input.is_action_just_pressed("ui_accept"): # Trigger on just pressed input +# Called every frame, listens for just-pressed input to show next chunk +func _process(_delta): + if Input.is_action_just_pressed("ui_accept_text"): + if current_chunk_index * 7 < word_chunks.size(): _display_next_chunk() - # If all chunks are displayed, show an empty chunk and hide the TextEdit - elif current_chunk_index * 5 >= word_chunks.size() and $"TextEdit".visible: - _display_empty_chunk() + elif $"TextEdit".visible: + _display_empty_chunk() -# Function to display only the next chunk of 5 words +# Show the current chunk of exactly 7 words func _display_next_chunk() -> void: - # Clear the current text - $"TextEdit".text = "" - - # Show the next 5 words - var start = current_chunk_index * 5 - var end = min(start + 5, word_chunks.size()) # Ensure we don't go beyond the last word - var chunk_text = " ".join(word_chunks.slice(start, end)) # Join the next 5 words - $"TextEdit".text = chunk_text # Display only the current 5 words - - # Move to the next chunk + var start = current_chunk_index * 7 + var end = min(start + 7, word_chunks.size()) + var chunk_text = " ".join(word_chunks.slice(start, end)) + $"TextEdit".text = chunk_text current_chunk_index += 1 -# Function to display an empty chunk before closing the text +# Show empty chunk and hide the box func _display_empty_chunk() -> void: - # Display an empty chunk (effectively clearing the TextEdit) $"TextEdit".text = "" - # Hide the TextEdit after the empty chunk $"TextEdit".visible = false + set_process(false) + func resetGame():