Spherical forums

Sphere Development => Sphere Support => Topic started by: Eggbertx on March 28, 2016, 06:27:54 pm

Title: Resizing a map via scripting?
Post by: Eggbertx on March 28, 2016, 06:27:54 pm
Would it be possible to resize the width/height current map in-game, short of manually modifying the file and reloading?
I have an idea for a game that requires the map to be able to grow, and it wouldn't work (as well) if I just went with a very large map instead.
Title: Re: Resizing a map via scripting?
Post by: DaVince on March 28, 2016, 06:42:11 pm
It's not really the map itself that has sizes, but the individual layers. You can use SetLayerWidth(layer_num, width) and SetLayerHeight(layer_num, height) for that.
Title: Re: Resizing a map via scripting?
Post by: Radnen on March 28, 2016, 06:47:44 pm
You almost need your own solution. Unfortunately Sphere doesn't allow you to stitch maps together. It'd be a neat feature to see someday.

If you do use DaVinces advice, prepare to write game logic to set the tiles for the newly grown layers, because I'm pretty sure it'd just be filled with the tile at index 0. So you're almost the way there to creating tiles for a custom map engine, expect now you have the power of other features of sphere's map engine.
Title: Re: Resizing a map via scripting?
Post by: Fat Cerberus on March 28, 2016, 06:50:19 pm
Hm, it appears minisphere doesn't implement the resizing functions!  Were those Sphere 1.6?  I admit I didn't take a very close look at what was new in 1.6 during initial development.  Those would likely be pretty easy to add, it's surprising I never thought of it.
Title: Re: Resizing a map via scripting?
Post by: Radnen on March 28, 2016, 06:52:12 pm

Hm, it appears minisphere doesn't implement the resizing functions!  Were those Sphere 1.6?  I admit I didn't take a very close look at what was new in 1.6 during initial development.  Those would likely be pretty easy to add, it's surprising I never thought of it.


Memory tells me they were not known publicly. I think they might have been in the code base. Though, I'm not sure if the functions worked or if they had bugs and was the reason why nobody knew of them.
Title: Re: Resizing a map via scripting?
Post by: Eggbertx on March 28, 2016, 06:55:46 pm

If you do use DaVinces advice, prepare to write game logic to set the tiles for the newly grown layers, because I'm pretty sure it'd just be filled with the tile at index 0. So you're almost the way there to creating tiles for a custom map engine, expect now you have the power of other features of sphere's map engine.

With what I plan to do, that actually wouldn't be a problem, since it will be generating things via a template as it goes anyway.


And if it means using Sphere 1.5 until it's implemented in minisphere, I'll do that.
Title: Re: Resizing a map via scripting?
Post by: Fat Cerberus on March 29, 2016, 01:41:54 am
I just implemented the layer-resizing functions in minisphere:


It required more new code than I originally anticipated, because I had to add logic to keep zones and triggers in-bounds, recalculate the map size, etc.  Overall it was relatively painless though, just had to spend some time working out the glitches. :)  As a convenience, I also added SetLayerSize(), to set both dimensions at once.  The change will be in minisphere 3.0.1.

Figures this didn't come up before today, I could have snuck it into 3.0.0 at the last second. ;)
Title: Re: Resizing a map via scripting?
Post by: Eggbertx on March 29, 2016, 01:51:58 am
Well it's good to know that a game idea I came up with on a whim (sort of) got minisphere some new code.
Title: Re: Resizing a map via scripting?
Post by: Fat Cerberus on March 29, 2016, 08:58:50 am
Just doing my job.  :D
Title: Re: Resizing a map via scripting?
Post by: DaVince on March 29, 2016, 10:02:32 am
I also remember SetLayerSize() not being a thing, and was surprised to see it in the function list when I double checked. Guess it was a 1.6 thing. It really ought to exist, anyway, so it's good that it does. And now in minisphere too. :P
Title: Re: Resizing a map via scripting?
Post by: Fat Cerberus on March 29, 2016, 02:38:41 pm
Yep, it's in 3.0.1.

I'm actually planning on eventually making a new JS-based object-oriented map engine as part of miniRT, so I'll keep some of Radnen's ideas in mind re: map stitching and such.