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

User avatar
rubenwardy
Member
 
Posts: 4500
Joined: Tue Jun 12, 2012 18:11
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: 493
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!
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
Member
 
Posts: 4500
Joined: Tue Jun 12, 2012 18:11
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:

Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
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:

Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
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
 

Hybrid Dog
Member
 
Posts: 2460
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
Member
 
Posts: 4500
Joined: Tue Jun 12, 2012 18:11
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.
 

Hybrid Dog
Member
 
Posts: 2460
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: 1092
Joined: Fri Apr 19, 2013 16:19

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
Member
 
Posts: 4500
Joined: Tue Jun 12, 2012 18:11
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: 355
Joined: Thu May 08, 2014 21:22
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
Member
 
Posts: 4500
Joined: Tue Jun 12, 2012 18:11
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy

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

by rubenwardy » Tue Oct 04, 2016 08:55

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

User avatar
sorcerykid
Member
 
Posts: 219
Joined: Fri Aug 26, 2016 15:36
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
Member
 
Posts: 4500
Joined: Tue Jun 12, 2012 18:11
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: 262
Joined: Thu Oct 13, 2016 10:45

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.
Some of 'my' wiki-pages: Build-a-home - basic-robot - basic-machines - digtron
 


Return to WIP Mods

Who is online

Users browsing this forum: No registered users and 4 guests

cron