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

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

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

by rubenwardy » Sun Aug 28, 2016 14:32

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: 529
Joined: Sun Nov 22, 2015 21:36

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

by TheReaperKing » Sun Aug 28, 2016 15:59

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!
Resources on happiness and life management - http://MikesHappyPlace.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: 5541
Joined: Tue Jun 12, 2012 18:11
Location: United Kingdom
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy

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

by rubenwardy » Sun Aug 28, 2016 16:06

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: 2681
Joined: Thu Nov 01, 2012 12:46

by Hybrid Dog » Sun Aug 28, 2016 17:43

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: 5541
Joined: Tue Jun 12, 2012 18:11
Location: United Kingdom
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy

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

by rubenwardy » Sun Aug 28, 2016 18:26

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: 2681
Joined: Thu Nov 01, 2012 12:46

by Hybrid Dog » Mon Aug 29, 2016 13:16

rubenwardy wrote:This is better than no editor.

You're right.
Anyway, l need a file browser mod.

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

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

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

by twoelk » Sat Oct 01, 2016 23:47

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: 5541
Joined: Tue Jun 12, 2012 18:11
Location: United Kingdom
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy

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

by rubenwardy » Sat Oct 01, 2016 23:49

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

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

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

by TG-MyinaWD » Tue Oct 04, 2016 04:16

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: 5541
Joined: Tue Jun 12, 2012 18:11
Location: United Kingdom
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy
 

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

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

by sorcerykid » Sun Dec 04, 2016 17:48

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: 5541
Joined: Tue Jun 12, 2012 18:11
Location: United Kingdom
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy

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

by rubenwardy » Sun Dec 04, 2016 18:16

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: 596
Joined: Thu Oct 13, 2016 10:45
Location: DE

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

by hajo » Sun Dec 04, 2016 19:27

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.
 


Return to Mod Releases



Who is online

Users browsing this forum: No registered users and 4 guests