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

Add destroy_grid_entity function #341

Merged
merged 4 commits into from
Oct 11, 2023

Conversation

estebanfer
Copy link
Contributor

Adds the destroy_grid_entity function to be able to remove a grid entity from the grid at the same time it gets destroyed, so the neighbor entities can be fixed right after destroying it, and a way to correctly destroy grid entities before the game has created their decorations, to have the correct decorations
I was thinking I could add some optional parameter to disable destroying the items of the grid entity, so if the user wants to do something different with the items, it could be done by the user itself (?)

@Dregu
Copy link
Collaborator

Dregu commented Oct 7, 2023

I'd also suggest a destroy_grid(x, y, l) so you don't have to figure out what's there when playing with coordinates.

src/game_api/script/lua_vm.cpp Outdated Show resolved Hide resolved
src/game_api/layer.cpp Outdated Show resolved Hide resolved
@estebanfer
Copy link
Contributor Author

I'd also suggest a destroy_grid(x, y, l) so you don't have to figure out what's there when playing with coordinates.

So, a different function with that name right? Or an overload?

@Dregu
Copy link
Collaborator

Dregu commented Oct 7, 2023

I'd also suggest a destroy_grid(x, y, l) so you don't have to figure out what's there when playing with coordinates.

So, a different function with that name right? Or an overload?

Well the one you already made clearly expects an entity(uid), but I wouldn't mind if this new function has an overload that treats a single argument as uid and 3 as coordinates...

@estebanfer
Copy link
Contributor Author

It feels a bit weird for me since most overloads have almost the same kind of parameters or just extra ones, though create_illumination already does take either coordinates or uid.
What do you think would be better?

@Dregu
Copy link
Collaborator

Dregu commented Oct 7, 2023

What do you think would be better?

Well I think of it this way: What is the harm if we add the overload? Will someone accidentally forget the rest of the arguments and something terrible happens when the uid was supposed to be an x-coordinate, or is it just a convenient shorthand with no risk of confusing anyone...

@estebanfer
Copy link
Contributor Author

well, doesn't make sense passing uid, y position and layer, or passing just x position, hopefully people won't be that dumb 🐈

@estebanfer
Copy link
Contributor Author

oh and this reminds me that overloads generated in spel2.lua are kinda broken... I'll have to fix that

@Dregu
Copy link
Collaborator

Dregu commented Oct 8, 2023

oh and this reminds me that overloads generated in spel2.lua are kinda broken... I'll have to fix that

Ah yes the new safe io and os stuff is also missing, I was supposed to make something for it, but it's probably easiest to just manually add io.open_data = io.open or something.

@Dregu
Copy link
Collaborator

Dregu commented Oct 8, 2023

Still suggesting the overloaded function to be called destroy_grid, as destroy_grid_entity clearly expects an entity...

@estebanfer
Copy link
Contributor Author

ohh... true

@Dregu Dregu merged commit 9395c85 into spelunky-fyi:main Oct 11, 2023
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants