[Mod] Text / Code Editor [0.1][editor]

Post Reply
User avatar
rubenwardy
Moderator
Posts: 6381
Joined: Tue Jun 12, 2012 18:11
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy
Location: United Kingdom
Contact:

[Mod] Text / Code Editor [0.1][editor]

by rubenwardy » Post

Image

Flexible formspec based text editor for Minetest (with an API)

Version: 0.1
License: MIT
Dependencies: none
Download: https://github.com/rubenwardy/editor/archive/master.zip
Github: https://github.com/rubenwardy/editor

Report bugs or request help on the forum topic.

Secure virtual filesystem. The filesystem seen in the editor is not a real filesystem, but a simulated lua one.
Sample editor with persistence. Basic functionality such as a file list to open files,
tabs to switch between open files, close to close open files, and new to create new files.

This mod won't do anything by itself! You need to install a mod such as Insecure Lua Editor to actually use this mod's API

Installation

Unzip the archive, rename the folder to editor and
place it in minetest/mods/

( GNU/Linux: If you use a system-wide installation place
it in ~/.minetest/mods/. )

( If you only want this to be used in a single world, place
the folder in worldmods/ in your worlddirectory. )

For further information or help see:
http://wiki.minetest.com/wiki/Installing_Mods
Last edited by rubenwardy on Sun Dec 04, 2016 18:17, edited 2 times in total.

User avatar
TheReaperKing
Member
Posts: 531
Joined: Sun Nov 22, 2015 21:36
Contact:

Re: [Mod] Text / Code Editor [0.1][editor]

by TheReaperKing » Post

This is really neat! Do you have any recommendations of simple code my students and I could write in here so they could easily see the results of their work? I think print is great. Also I see you said the filesystem is virtual, is it possible to save it to a file? I suppose we could always copy and paste. Thanks so much for making this!
Become A Real Life Superhero - http://SuperheroHill.com
Project Lead of the Doom 3 Mod Last Man Standing - http://Doom3Coop.com
Project Lead of Platinum Arts Sandbox Free 3D Game Maker - http://SandboxGameMaker.com
Youtube Channel - https://www.youtube.com/user/PlatinumArtsKids

User avatar
rubenwardy
Moderator
Posts: 6381
Joined: Tue Jun 12, 2012 18:11
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy
Location: United Kingdom
Contact:

Re: [Mod] Text / Code Editor [0.1][editor]

by rubenwardy » Post

A player's filesystem is automatically saved to worlds/world/editor_files/playername.lua when they log out, or the server shuts down. It's in a lua table serialised format, like so:

Code: Select all

return {
    version = 1,
    files = {
          ["path/to/file1.txt"] = "file1 content",
          ["path/to/file2.txt"] = "file2 content"
    }
}
This mod is good for a singleplayer world where they can try out interactive things. For example:

Code: Select all

local player = minetest.get_player_by_name("singleplayer")
local pos = vector.round(player:getpos())

minetest.set_node(pos, { name = "nyancat:nyancat" })
will place nyancat nodes at the player's feet when ran

User avatar
Hybrid Dog
Member
Posts: 2775
Joined: Thu Nov 01, 2012 12:46
GitHub: HybridDog

by Hybrid Dog » Post

Unfortunately the current multiline formspec text field is extremely inconvenient and it does not likely change (https://github.com/minetest/minetest/pull/3474), so your efforts are for the cat.

‮‪‮
‮‪‮
‮‪‮
‮‪‮
‮‪‮
‮‪‮
‮‪‮
‮‪‮
‮‪

User avatar
rubenwardy
Moderator
Posts: 6381
Joined: Tue Jun 12, 2012 18:11
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy
Location: United Kingdom
Contact:

Re: [Mod] Text / Code Editor [0.1][editor]

by rubenwardy » Post

Nope, you can just fix that in the engine. And if we add a syntax text box we can do that. This is better than no editor.

User avatar
Hybrid Dog
Member
Posts: 2775
Joined: Thu Nov 01, 2012 12:46
GitHub: HybridDog

by Hybrid Dog » Post

rubenwardy wrote:This is better than no editor.
You're right.
Anyway, l need a file browser mod.

‮‪‮
‮‪‮
‮‪‮
‮‪‮
‮‪‮
‮‪‮
‮‪‮
‮‪‮
‮‪

User avatar
twoelk
Member
Posts: 1411
Joined: Fri Apr 19, 2013 16:19
GitHub: twoelk
IRC: twoelk
In-game: twoelk
Location: northern Germany

Re: [Mod] Text / Code Editor [0.1][editor]

by twoelk » Post

Indeed a nice file browser to explore some folder structures might be very useful. It could be used as plugin or api for such mods as WE or any other mod that needs to load and save content to a folder structure. It would be cool if for example I could organize my schematics in several folders or even some central common folder at minetest root outside of the world folder. This way I could easily share files between worlds without having to copy them around.

Could this be used to access real unsimulated other text files of other mods such as those used by the wiki mod, the gutenberg mod or some server guide mods from within the game?

User avatar
rubenwardy
Moderator
Posts: 6381
Joined: Tue Jun 12, 2012 18:11
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy
Location: United Kingdom
Contact:

Re: [Mod] Text / Code Editor [0.1][editor]

by rubenwardy » Post

It could, if you change filesystem.lua to use real file system functions

TG-MyinaWD
Member
Posts: 356
Joined: Thu May 08, 2014 21:22
GitHub: Maddie-Myina
IRC: Maddie-Myina
In-game: .
Location: Far Eden

Re: [Mod] Text / Code Editor [0.1][editor]

by TG-MyinaWD » Post

If I'm looking at this right.. You can create a mod ingame?
I'm a Transgender no shame about it.
I prefer to be considered as a "Girl/Lady/Miss/Madam/Female" for now on.

User avatar
rubenwardy
Moderator
Posts: 6381
Joined: Tue Jun 12, 2012 18:11
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy
Location: United Kingdom
Contact:

Re: [Mod] Text / Code Editor [0.1][editor]

by rubenwardy » Post

No, it's an editor that can execute lua code

User avatar
sorcerykid
Member
Posts: 1505
Joined: Fri Aug 26, 2016 15:36
GitHub: sorcerykid
In-game: Nemo
Location: Illinois, USA

Re: [Mod] Text / Code Editor [0.1][editor]

by sorcerykid » Post

I think there should a lot more emphasis in the description about the vulnerabilities of executing untrusted Lua code (i.e. tainted code). The loadstring( ) function is inherently insecure, and allows would-be attackers to inject arbitrary and dangerous code at runtime, which could seriously compromise the Minetest server (and potentially even the operating system itself), including changing passwords, deleting files, hanging the process, invoking shell commands, etc.

User avatar
rubenwardy
Moderator
Posts: 6381
Joined: Tue Jun 12, 2012 18:11
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy
Location: United Kingdom
Contact:

Re: [Mod] Text / Code Editor [0.1][editor]

by rubenwardy » Post

Wrong topic - the mod you're talking about is insecure lua editor (the clue is in the name). Both mods are a work in progress, the aim it to make it an editor eventually to be used to run sandboxed Lua code on the server to control turtle bots

hajo
Member
Posts: 606
Joined: Thu Oct 13, 2016 10:45
Location: DE
Contact:

Re: [Mod] Text / Code Editor [0.1][editor]

by hajo » Post

rubenwardy wrote:Image
Flexible formspec based text editor for Minetest (with an API)
..
Secure virtual filesystem. .. not a real filesystem, but a simulated lua one.
Sample editor with persistence.
Could this be used to edit books ?

As in, filename==>book-title, text==>book-contents,
where each file resides in one of the player's books.
Maybe with bookshelves as directories.

Also, a monospaced font and scrollbars would be nice,
as well as a counter telling the current line
(e.g. for finding the source of "error in line 27").
Or a button that prepends each line of text with a linenumber
(but editor and language-processor need to agree on how to count lines).

BTW, why have that line of filename-tabs at the top,
as well as that column at the left ?
A statusline for the current file, and the buttons for new/save/run etc.
would use the space better.

Post Reply

Who is online

Users browsing this forum: cHyper and 7 guests