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

Teleport to safe spot, but as a library #311

Open
altrisi opened this issue Apr 22, 2022 · 2 comments
Open

Teleport to safe spot, but as a library #311

altrisi opened this issue Apr 22, 2022 · 2 comments
Labels
enhancement New feature or request

Comments

@altrisi
Copy link
Collaborator

altrisi commented Apr 22, 2022

world_map has a function to teleport to a safe spot:

// verifies player has proper place to land on a terrain and if its not generated moves player to a safe position.
__check_safe_landing(player, pos, dim, immediate) ->
(
in_dimension(dim,
add_chunk_ticket(pos, 'portal', global_map_view_distance+length(global_chunk_statuses));
pos = [floor(pos:0), global_config:dim:'map_center':1, floor(pos:2)];
world_chunk = __to_chunk_coords(pos, dim);
status = _get_chunk_status(world_chunk, true);
if(immediate && status < 0,
if (!solid(pos), set(pos, 'black_concrete'));
set(pos+[0,1,0], 'air');
set(pos+[0,2,0], 'air');
set(pos+[0,3,0], 'air');
modify(player, 'pos', pos+[0.5,2.2,0.5]);
);
status
)
);

cam has something for that too:

for( yposes,
scan(x, _, z, 32, 0, 32,
if( air(_) && air(pos_offset(_, 'up')) && suffocates(pos_offset(_, 'down')),
modify(player, 'pos', pos(_)+l(0.5,0.2,0.5));
return(true);
)
)
);

And the thing is, it's likely other apps would like to use similar functionality, such as waystones in #305.

Proposal for extracting it to a library. Maybe not making cam use the library as cam is used a lot and adding a dependency could be an issue, but I don't see why world_map can't, same for other apps.

@altrisi altrisi added the enhancement New feature or request label Apr 22, 2022
@Ghoulboy78
Copy link
Collaborator

Well, then would this entail potentially creating a block in midair tho? cos thats what world_map does, but not everyone want to do that. Unless we do it so that it returns null if there is no safe space in the area they query.

@altrisi
Copy link
Collaborator Author

altrisi commented May 10, 2022

Well if you opt-in to the library, it will do it, but the lib would tell you what it does. Could always have a param or something to decide whether it should create a platform if needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants