Page 1 of 1
EditorInputIsDown_... does not work
Posted: 13 Dec 2016, 23:58
by BigBang1112
I'm struggling with this thing for a long time now, but still can't get it.
I want to do something when I delete a block. But EditorInputIsDown_CursorDelete doesn't seem to turn True anytime.
I tried setting EnableEditorInputsCustomProcessing to True, but that brokes the editor buttons and doesn't solve the problem either.
Tested also getting info from CEditorPluginEvent, which I knew it will return Unknown always, but I tried it just to say.
Help anyone? If you will help me, you'll save the plugin, that coming around the corner.

Thanks in advance.
Re: EditorInputIsDown_... does not work
Posted: 14 Dec 2016, 12:18
by zocka
I used this once:
Code: Select all
declare EraseDown = False;
declare IgnoreMapChange = False;
while (True) {
if (EditorInputIsDown_CursorDelete) {
EraseDown = True;
} else {
if (EraseDown) {
EraseDown = False;
IgnoreMapChange = False;
if (RemoveBlock(CursorCoord)) {
MyRemoveBlockFunction(CursorCoord);
}
}
}
foreach (Event in PendingEvents) {
if (Event.Type == CEditorPluginEvent::Type::MapModified) {
if (EditMode == CEditorPlugin::EditMode::Erase) {
MyRemoveBlockFunction(CursorCoord);
} else if (EditMode == CEditorPlugin::EditMode::Place) {
if (IgnoreMapChange) {
// ignore map change triggered by deleting a block
IgnoreMapChange = False;
}
}
}
}
yield;
}
Note that this will only accept single deletes (so not holding down the button and dragging around) as I wanted to allow only single block deletes (and placements with similiar code).
I have a commented-out "EnableEditorInputsCustomProcessing = True", so I guess I didn't need it for that, but I haven't touched that script in months.
Re: EditorInputIsDown_... does not work
Posted: 15 Dec 2016, 17:57
by BigBang1112
Thanks! The first part of the code didn't work, but the Event side did! Although it will trigger also when you Undo or do something in Erase mode.
So this can be the alternative way to fix. Ty again.

If you have any other ideas, let me know I will appreciate it.
Re: EditorInputIsDown_... does not work
Posted: 15 Dec 2016, 19:17
by zocka
I did a bit of testing now:
Code: Select all
#RequireContext CEditorPlugin
declare Integer CountBlocksDeleted;
declare Text DeletionLog;
Void MyRemoveBlockFunction(Int3 _CursorCoord) {
CountBlocksDeleted += 1;
DeletionLog = """deleted {{{CountBlocksDeleted}}} blocks, last at {{{_CursorCoord}}}""" ^ "\n" ^ DeletionLog;
ManialinkText = """<label text="{{{DeletionLog}}}"/>""";
}
main() {
while (True) {
// place a block in the bottom right of the map to enable this/delete the block to use the menu
EnableEditorInputsCustomProcessing = !GetBlock(<0, CollectionGroundY, 0>).BlockModel.IsTerrain;
if (EditorInputIsDown_CursorDelete) {
if (GetBlock(CursorCoord) != Null) {
if (!GetBlock(CursorCoord).BlockModel.IsTerrain) {
RemoveBlock(CursorCoord);
MyRemoveBlockFunction(CursorCoord);
}
}
}
foreach (Event in PendingEvents) {
if (Event.Type == CEditorPluginEvent::Type::MapModified) {
if (EditMode == CEditorPlugin::EditMode::Erase) {
MyRemoveBlockFunction(CursorCoord);
}
}
}
yield;
}
}
This
kind of works: to catch the EditorInputIsDown_... in PlaceMode, you have to EnableEditorInputsCustomProcessing. (Which totally makes sense.)
The script above seems to log whenever you delete a block (not beeing in PlaceMode or having a block placed at <0, ground, 0> otherwise (switch for custom editor input processing)).
I don't know what your plan was, but maybe you can build around that.
However I'm afraid you can't just get what block was changed from EraseMode or MapModified events. If I remember correctly, I tried that back then.
Re: EditorInputIsDown_... does not work
Posted: 15 Dec 2016, 20:37
by BigBang1112
I kinda did my way with Erase MapModified. Just tested it a hour ago and it works great.
It's not the best way, but it works good performance wise so I won't change it now.
I did it like this. Want to check if Finish block is deleted:
Code: Select all
if(RevMultiFin) { //RevMultiFin is a bool when if True it starts checking
if(GetBlock(CursorCoord).BlockModel.WaypointType == CBlockModel::EWayPointType::Finish) { //Important, so the StadiumGrass won't be tracked because that happens when you delete finish on ground.
blockCursorName = GetBlock(CursorCoord).BlockModel.Name;
blockCursorPos = GetBlock(CursorCoord).Coord;
blockCursorDir = GetBlock(CursorCoord).Direction;
} //Here I'm setting some variables to save the block data that I'm currently pointing on. Storing CBlock didn't work for me.
foreach (Event in PendingEvents) {
if (Event.Type == CEditorPluginEvent::Type::MapModified) {
if (EditMode == CEditorPlugin::EditMode::Erase) {
RevMultiFin = False; //However here I set RevMultiFin to False to stop the checking so the block data won't change. Also it removes crash while hitting Undo button after delete.
//Here u can do neat stuff with block you just deleted.
}
}
}
}
Thanks for other solution though, will use it later on if I'll need it.
