Editor Plugin: Is it allowed to remove certain blocks?

You can talk about ManiaScript for ManiaPlanet here

Moderator: English Moderator

tly
Posts: 8
Joined: 01 Oct 2011, 14:23

Editor Plugin: Is it allowed to remove certain blocks?

Post by tly »

hey guys :)

im trying to create an editor plugin to remove blockclips. (to make nice transitions :) )
the problem: either im doing something wrong or it isnt allowed to remove certain blocks.

using "RemoveBlock(someCoords);" only removes "normal" blocks.
using "Blocks.removekey(someKey);" throws an error, because Blocks is const.

is there any way to do this?

this is my code:

Code: Select all

#RequireContext CEditorPlugin
#Include "TextLib" as TextLib

main(){
	log("ClipRemover stars.");
	declare Integer i;
	foreach(index => block in Blocks){
		if(TextLib::SubString(block.BlockModel.Name,TextLib::Length(block.BlockModel.Name)-4,4)=="Clip"){
			i+=1;
			//what to do here? :D
			//RemoveBlock(block.Coord);
			//Blocks.removekey(index);
		}
	}
	log(i^" Clips should have been removed.");
	while(True){
		yield;
	}
}
greetings

tly
Last edited by tly on 20 Sep 2014, 17:22, edited 1 time in total.
jui
Posts: 171
Joined: 16 May 2013, 15:58

Re: Editor Plugin: Is it allowed to remove certain blocks?

Post by jui »

When i try your script the if condition is never true (i stays at 0). So the function RemoveBlock never gets called.
Maybe i have placed the wrong blocks. :D I tested the RemoveBlock function and it works for me with a block.Coord argument.
tly
Posts: 8
Joined: 01 Oct 2011, 14:23

Re: Editor Plugin: Is it allowed to remove certain blocks?

Post by tly »

jui wrote:When i try your script the if condition is never true (i stays at 0). So the function RemoveBlock never gets called.
Maybe i have placed the wrong blocks. :D I tested the RemoveBlock function and it works for me with a block.Coord argument.
thanks for your attempt :thumbsup: i just noticed, that RemoveBlock works for normal blocks ;)

The blockmodel which end with "Clip" are the connections between road parts :) i wanted to remove them because they can be annoying if you blockmix in the editor...
this egde for example:

Image
the clip is not removed, to ingame its like this:

Image

i noticed, that the RemoveBlock function returns 'True', if the block was removed. If you try to remove these clips, it always returns 'False' and doesnt remove the block....
Last edited by tly on 20 Sep 2014, 17:27, edited 1 time in total.
User avatar
TMarc
Posts: 15255
Joined: 05 Apr 2011, 19:10
Location: Europe
Contact:

Re: Editor Plugin: Is it allowed to remove certain blocks?

Post by TMarc »

Silly idea, but which block did you place first? The underground or the overground block?
Or does it not matter at all here?
tly
Posts: 8
Joined: 01 Oct 2011, 14:23

Re: Editor Plugin: Is it allowed to remove certain blocks?

Post by tly »

TMarc wrote:Silly idea, but which block did you place first? The underground or the overground block?
Or does it not matter at all here?
it tried both ways :D but good idea :thumbsup:

even it it had worked, it wouldnt have solved the general problem ;)

for example this transition worked in tmnf, because the unlimiter could remove clips:

Image
User avatar
TMarc
Posts: 15255
Joined: 05 Apr 2011, 19:10
Location: Europe
Contact:

Re: Editor Plugin: Is it allowed to remove certain blocks?

Post by TMarc »

Are you sure you tried everyhting? I'm not 8-)

What do you say?
Image


First I tried the usual trick to place a working combination of blocks in the air, switch to blockmix mode, copy the ramp block, and place it on the ground :arrow: fail, same small horizontal grid issue.

Then I thought: hey, it's blockmix, why should we not make the concret ramp continue straight into the ground, to force it have the right connections, and later add the underground dirt slope ramp additionally? e.g. using block 2-1-4?
And this did the trick...

Showcase in the air:
Image

and comparison without (background) and with additional ramp block (foreground):
Image

The only minor drawback here: there are small visual glitches at the border of both blocks, because at the upper part, the undeground block ramp has the same place as the straight ramp block. :oops:

But as workaround, good enough, huh!? ;)
tly
Posts: 8
Joined: 01 Oct 2011, 14:23

Re: Editor Plugin: Is it allowed to remove certain blocks?

Post by tly »

TMarc wrote:Are you sure you tried everyhting? I'm not 8-)

What do you say?
Image


First I tried the usual trick to place a working combination of blocks in the air, switch to blockmix mode, copy the ramp block, and place it on the ground :arrow: fail, same small horizontal grid issue.

Then I thought: hey, it's blockmix, why should we not make the concret ramp continue straight into the ground, to force it have the right connections, and later add the underground dirt slope ramp additionally? e.g. using block 2-1-4?
And this did the trick...

Showcase in the air:
Image

and comparison without (background) and with additional ramp block (foreground):
Image

The only minor drawback here: there are small visual glitches at the border of both blocks, because at the upper part, the undeground block ramp has the same place as the straight ramp block. :oops:

But as workaround, good enough, huh!? ;)
thanks :) this is quite nice :D
tly
Posts: 8
Joined: 01 Oct 2011, 14:23

Re: Editor Plugin: Is it allowed to remove certain blocks?

Post by tly »

update: the trick cant be used, because the editor does not save the blocks correctly :shock:
you can use it in the editor, validate and stuff but when you save the map the uphill part is removed...
User avatar
TMarc
Posts: 15255
Joined: 05 Apr 2011, 19:10
Location: Europe
Contact:

Re: Editor Plugin: Is it allowed to remove certain blocks?

Post by TMarc »

tly wrote:update: the trick cant be used, because the editor does not save the blocks correctly :shock:
you can use it in the editor, validate and stuff but when you save the map the uphill part is removed...
I don't know what you are doing, but it is still working for me, try the map here:
https://www.dropbox.com/s/tudaarfo7xdce ... p.Gbx?dl=0

are you sure you enabled the blockmixing mode, and pressed F2 a few times wo change the block icon to red color?
Attention, when you use CTRL+left click to select a block, it might reset the block placement mode!
tly
Posts: 8
Joined: 01 Oct 2011, 14:23

Re: Editor Plugin: Is it allowed to remove certain blocks?

Post by tly »

thanks, its working now :) the first time i saved the map the block was removed but the second time it stayed :D
Post Reply

Return to “ManiaScript”

Who is online

Users browsing this forum: No registered users and 1 guest