This site is currently in read-only mode during migration to a new platform.
You cannot post questions, answers or comments, as they would be lost during the migration otherwise.
+4 votes


I need to make a tool script that detects if a TileMap cell was changed by the user in the editor (not in the game). This would allow for features like autotiling.

Unfortunately when I tried subclassing TileMap and overriding the set_cell method to emit a signal, neither the signal nor the print-statement is called:

extends TileMap

signal cell_changed(tilemap, x, y, value)

func set_cell(x, y, value, flip_x = false, flip_y = false, transpose = false):
    print("cell changed")
    .set_cell(x, y, value, flip_x, flip_y, transpose)
    emit_signal("cell_changed", x, y, value, flip_x, flip_y, transpose)

Does anyone know how to realize it without going down c++ road? If not how can adjust tile_map.cpp to add a signal on edit?

I tried to put

 emit_signal("cell_changed", p_x, p_y, p_tile, p_flip_x, p_flip_y, p_transpose);

into the set_cell method and

ADD_SIGNAL(MethodInfo("cell_changed", PropertyInfo(Variant::INT, "x:Int"),  PropertyInfo(Variant::INT, "y:Int"),  PropertyInfo(Variant::INT, "value:Int"),  PropertyInfo(Variant::BOOL, "flip_x:Bool"),  PropertyInfo(Variant::BOOL, "flip_y:Bool"),  PropertyInfo(Variant::BOOL, "transpose:Bool")));

at the bottom of the .cpp file where the other signal is. But compiler says:

scene\2d\tile_map.cpp(706): error C2661: 'Object::emit_signal': no overloaded function takes 7 arguments
scene\2d\tile_map.cpp(1315): error C2440: '<function-style-cast>': cannot convert from 'initializer list' to 'MethodInfo'
scene\2d\tile_map.cpp(1315): note: No constructor could take the source type, or constructor overload resolution was ambiguous
scene\2d\tile_map.cpp(1315): error C2660: 'ClassDB::add_signal': function does not take 1 arguments
scons: *** [scene\2d\] Error 2
scons: building terminated because of errors.

How could I adjust the above to make it work. Sorry I am very new to the .cpp side of Godot and cannot yet grasp all the property and variants stuff.

Thank you for your time!

in Engine by (24 points)

Did you ever figure this out? Trying to make a similar tool. Thanks!

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.