Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hooked scripts (mod-hooks.zip) are generated incorrectly in Godot 4.1 #455

Open
Alexejhero opened this issue Nov 19, 2024 · 0 comments
Open
Assignees
Labels
4.x 4.1 bug Something isn't working
Milestone

Comments

@Alexejhero
Copy link

Alexejhero commented Nov 19, 2024

Original file
extends Node

@export var speaker : AudioStreamPlayer2D
@export var cursor_point : CompressedTexture2D
@export var cursor_hover : CompressedTexture2D
@export var cursor_invalid : CompressedTexture2D
var cursor_visible = false
var controller_active = false

func _ready():
	SetCursor(false, false)

func SetCursor(isVisible : bool, playSound : bool):
	if (playSound): speaker.play()
	if (isVisible):
		if (!controller_active): Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
		else: Input.set_mouse_mode(Input.MOUSE_MODE_HIDDEN)
		cursor_visible = true
	if (!isVisible):
		Input.set_mouse_mode(Input.MOUSE_MODE_HIDDEN)
		cursor_visible = false

func SetCursorImage(alias : String):
	match(alias):
		"point": Input.set_custom_mouse_cursor(cursor_point, 0, Vector2(12, 0))
		"hover": Input.set_custom_mouse_cursor(cursor_hover, 0, Vector2(9, 0))
		"invalid": Input.set_custom_mouse_cursor(cursor_invalid, 0, Vector2(12, 0))
	pass
Diffed output (what is generated vs what it should have been)
  extends Node
  
  @export var speaker : AudioStreamPlayer2D
  @export var cursor_point : CompressedTexture2D
  @export var cursor_hover : CompressedTexture2D
  @export var cursor_invalid : CompressedTexture2D
  var cursor_visible = false
  var controller_active = false
  
  func vanilla_3757864496__ready():
      SetCursor(false, false)
+ 
+ func vanilla_3757864496_SetCursor(isVisible : bool, playSound : bool):
+     if (playSound):
+         speaker.play()
+     if (isVisible):
+         if (controller_active): Input.set_mouse_mode(Input.MOUSE_MODE_HIDDEN)
+         else: Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
+         cursor_visible = true
+     if (!isVisible):
+         Input.set_mouse_mode(Input.MOUSE_MODE_HIDDEN)
+         cursor_visible = false
+ 
+ func vanilla_3757864496_SetCursorImage(alias : String):
+      match(alias):
+         "point": Input.set_custom_mouse_cursor(cursor_point, 0, Vector2(12, 0))
+         "hover": Input.set_custom_mouse_cursor(cursor_hover, 0, Vector2(9, 0))
+         "invalid": Input.set_custom_mouse_cursor(cursor_invalid, 0, Vector2(12, 0))
+     pass
  
  # ModLoader Hooks - The following code has been automatically added by the Godot Mod Loader.
  
  
  func _ready():
      _ModLoaderHooks.call_hooks(vanilla_3757864496__ready, [], 2580177828)
      
  
- func SetCursor():
-     _ModLoaderHooks.call_hooks(vanilla_3757864496_SetCursor, [, ], 3168855034)
+ func SetCursor(isVisible : bool, playSound : bool):
+     _ModLoaderHooks.call_hooks(vanilla_3757864496_SetCursor, [isVisible, playSound], 3168855034)
      
  
- func SetCursorImage():
-     _ModLoaderHooks.call_hooks(vanilla_3757864496_SetCursorImage, [], 2557926557)
+ func SetCursorImage(alias: String):
+     _ModLoaderHooks.call_hooks(vanilla_3757864496_SetCursorImage, [alias], 2557926557)

This causes compiler errors because [, ] is invalid, which means the script cannot be loaded.

@KANAjetzt KANAjetzt added 4.x 4.1 bug Something isn't working labels Nov 19, 2024
@KANAjetzt KANAjetzt moved this to In progress in Mod Hooks Nov 29, 2024
@KANAjetzt KANAjetzt moved this from In progress to Backlog in Mod Hooks Nov 29, 2024
@KANAjetzt KANAjetzt added this to the 4.x - 7.0.0 milestone Nov 29, 2024
@KANAjetzt KANAjetzt self-assigned this Dec 29, 2024
@KANAjetzt KANAjetzt moved this from Backlog to In progress in Mod Hooks Dec 29, 2024
@KANAjetzt KANAjetzt moved this from In progress to In review in Mod Hooks Jan 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
4.x 4.1 bug Something isn't working
Projects
Status: In review
Development

No branches or pull requests

2 participants