Script with mapeditor

Hello.

I understand mapeditor is not made to handle script language but if you put a objet that have to execute a script (in the real game).
What is the best solution you founded to add a script to an object ?

A nice solution could be to be able to add a longtext (textarea) as custom properties !
Of course if you can set a type of language to have a syntax coloration, it would be wonderfull !

I’m using Lua for scripting dialogue and cutscenes in my game.

Originally I was using a custom property that had a string in it for the script. Obviously, writing scripts in this way isn’t a great experience, so what I ended up doing was simply using a file custom property and then the game engine loads up that file and executes it.

I don’t think it would work too well as a built-in feature since everyone’s use case for Tiled is different.

Yeap.
So you add a property called function (for example)
and you have a file with all the functions of a level !
That’s the solution I’m using but, there is at least 2 problems:

  • you have 2 files for one level
  • and this is less easy to let another person to make a level !

But, I’ll continue like this !

You’re usine Solar2D ou Love2D or something like this ?

I’m using a custom engine that I created that has Lua embedded.

Personally, I don’t think having the scripts being separate files is too big of a problem, especially if the game engine you use packs all the resources anyway.

This is already supported. If you click the “…” edit button on a custom string property, it’ll open a multi-line text editor.

2 Likes

Ah yes :+1:

I haven’t seen the “…”

I begin to really like mapeditor !
It is very usefull and simple !

I started to put my script in the editor :slightly_smiling_face:

Is it possible to set the tab size ?
Is it possible to change the text size (it’s quite small on my screen)
In a futur update a little bigger edit zone could be nice !

Thank’s
Etienne

Is it possible to set the tab size ?

Not currently.

Is it possible to change the text size (it’s quite small on my screen)

It’s the same size as all the other text in Tiled. If you increase text magnification in your OS, all text in Tiled will be larger, including presumably text in the string editor.

In a futur update a little bigger edit zone could be nice !

You can resize the editing window by dragging its bottom right corner.