Charpurrr / SuperMarioSolarEngine

An open source fanmade 2D Mario engine that implements elements from all the mainline 3D titles
https://docs.google.com/document/d/1hzFKpgm-1IukFWBig9A5ZsCQQEqVqJFVrNOAVmHSHJI/edit
MIT License
14 stars 7 forks source link

added enhancement feature for swappable items in editor hotbar. #17

Closed Unequipped closed 5 months ago

Unequipped commented 5 months ago

Added #16 Edited hotbar.gd and hotbar_item.gd so that an item is swapped with another item if it is moved on top of it.

https://github.com/Charpurrr/SuperMarioSolarEngine/assets/77971199/8e796332-8ea7-4c75-9c8b-954b0cba93af

Charpurrr commented 5 months ago

wow this is awesome thank you so much??? i'm like in awe because this is the first time something like this happens to one of my projects on github LOL

we don't know eachother do we ?

Unequipped commented 5 months ago

You're welcome! Glad I could help :) The changes can probably be optimised and cleaned up a bit more. E.g. line 117 in hotbar_item.gd if item_icon.texture != null and item_data != null: -> if item_icon.texture and item_data:

One issue I noticed was when you pin the terrain option it results in an error. I tested this with and without the changes I made and got the same results. It seems to be limited to the the terrain option, Goobas and Mario are fine.

To recreate: Run the editor and open the item selection menu. Either drag and drop or click the terrain option to place it in the hotbar. Click and hold in the hotbar slot with the terrain item until it is pinned. Releasing the click results in an error but moving the mouse out of the terrain hotbar slot and then releasing doesn't result in an error. You don't have to pin the terrain item for the error to show - tapping the terrain item in the hotbar with or without it being pinned also results in the same error.

The error: Cannot call method 'instantiate' on a null value

The code it points to: res://level_designer/items/preview_items/preview_display/complex_preview_display.gd

@tool
class_name ComplexPreviewDisplayData
extends PreviewDisplayData

@export var preview_scene: PackedScene

func create():
    return preview_scene.instantiate() # <-- HERE

Cause of error: Not too sure but something to do with the act of releasing mouse click while the cursor is within the hotbar slot holding the terrain.

I can submit an issue for this ^

Also I don't think we know each other?