Initial commit

gh-pages
rubenwardy 2014-08-16 20:16:29 +01:00
commit 7a3cdbc5bd
6 changed files with 399 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
*~*

7
README.md Normal file
View File

@ -0,0 +1,7 @@
Simple Minetest Mod Maker
=========================
Create by rubenwardy
License: GPL 3.0 or later
Use at https://rubenwardy.github.io/minetest_mod_maker

248
assets/editor.js Normal file
View File

@ -0,0 +1,248 @@
var project = {name: "test", items: [{
name: "n1",
type: "node",
desc: "Node One",
digMode: "crumbly"
},{
name: "n2",
type: "node",
desc: "Node Two",
digMode: "crumbly"
}]};
function displayName(fromTitle)
{
var tmp = "<p>";
tmp += "Please enter a mod name. ";
tmp += "This will be the name of the folder that ";
tmp += "the mod will be placed in when installed.";
tmp += "</p><p>Make sure the mod name has not already been used. ";
tmp += "Look on the forums to check.<br />";
tmp += "<span id=\"allowed\">Only lower case letters, numbers and/or underscore characters may be used.</span></p>";
tmp += "<p>Name: <input id=\"name\" name=\"name\" value=\""+project.name+"\" /></p>";
tmp += "<p id=\"buttons\"><a id=\"btn_continue_1\" class=\"button long_button\">" + ((fromTitle)?"Next":"Change") + "</a></p>";
$("#page").html(tmp);
$("#btn_continue_1").click(function() {
var input = $("#name").val();
var reg = /^[a-z0-9_]+$/;
if (!reg.test(input)) {
$("#allowed").css("color", "red");
return;
}
project.name = input;
displayMain();
});
}
function displayMain()
{
var tmp = "<p>On this page you can create and delete nodes to be added to the mod. ";
tmp += "When you are done, click next. You can come back to this page after clicking next.</p>";
tmp += "<table id=\"item_list\"><tr><th style=\"width: 120px;\">Name</th><th style=\"width: 60px;\">Type</th><th>Description</th><th>Actions</th></tr>";
for (var i = 0; i < project.items.length; i++) {
var item = project.items[i];
tmp += "<tr><td>" + item.name + "</td><td>" + item.type + "</td><td>" + item.desc + "</td><td>";
tmp += "<a id=\""+i+"\" class=\"delete_btn button\">Delete</a></td></tr>";
}
tmp += "</table>";
tmp += "<p id=\"buttons\">";
tmp += "<a id=\"btn_create_node\" class=\"button\">Create Node</a>";
tmp += "<a id=\"btn_change_name\" class=\"button\">Change Mod Name</a>";
tmp += "<a id=\"btn_next\" class=\"button long_button\">Next</a>";
tmp += "</p>";
$("#page").html(tmp);
$("#btn_create_node").click(function() {
displayNode();
});
$("#btn_change_name").click(function() {
displayName(false);
});
$("#btn_next").click(function() {
displaySetup();
});
$(".delete_btn").click(function() {
project.items.splice($(this).attr('id'), 1);
displayMain();
});
}
function displayNode()
{
var tmp = "<p>Use this page to create a node. A node is what you may know as a block - ";
tmp += "A 1by1by1 metre block in the game.</p>";
tmp += "<table id=\"form_table\">";
function makeRow(name, label, value, note)
{
var res = "<tr><td>"+label+":</td><td>"+value+"</td>";
res += "<td id=\""+name+"_note\">" + note + "</td></tr>";
return res;
}
function makeRow_Text(name, label, note)
{
return makeRow(name, label, "<input type=\"text\" id=\""+name+"\" name=\""+name+"\" />", note);
}
tmp += makeRow_Text("name", "Name", "The name of the node in code. Must be unique. Only lower case letters, numbers and/or underscore characters may be used.");
tmp += makeRow_Text("desc", "Description", "Displayed in tooltips. Only letters, numbers and/or underscores characters may be used.");
var select = "<select name=\"slDM\" id=\"digMode\">";
function selectOP(name, desc, sel)
{
return "<option"+(sel?" selected":"") + " value=\""+name+"\">"+name+(desc!=""?(" - "+desc+"."):"")+"</option>";
}
select += selectOP("cracky", "Tough but crackable stuff like stone", true);
select += selectOP("crumbly", "Dirt, sand", false);
select += selectOP("snappy", "Cut using fine tools", false);
select += selectOP("choppy", "Cut using force (trees, wooden planks)", false);
select += selectOP("fleshy", "Living things like animals and the player", false);
select += selectOP("explody", "Especially prone to explosion", false);
select += selectOP("oddly_breakable_by_hand", "Breaks easily", false);
tmp += makeRow("dig", "Dig Mode", select, "The dig mode of a node determines which tools work best, and how quick it is to dig.");
/*var select = "<select name=\"slSD\" id=\"sound\">";
select += selectOP("none", "", true);
select += selectOP("custom", "use custom sounds", false);
select += selectOP("dirt", "use dirt sounds", false);
select += selectOP("glass", "use glass sounds", false);
tmp += makeRow("sound", "Sounds", select, "");*/
tmp += "</table>";
tmp += "<p id=\"buttons\"><a class=\"button\" id=\"btn_home\">Back</a> <a class=\"button\" id=\"btn_create\">Create</a></p>";
$("#page").html(tmp);
$("#btn_home").click(function() {
displayMain();
});
$("#btn_create").click(function() {
$("#name_note").css("color", "black");
$("#desc_note").css("color", "black");
var name = $("#name").val();
var reg1 = /^[a-z0-9_]+$/;
if (name=="" || !reg1.test(name)) {
$("#name_note").css("color", "red");
return;
}
var desc = $("#desc").val();
var reg2 = /^[\w ]+$/;
if (desc=="" || !reg2.test(desc)) {
$("#desc_note").css("color", "red");
return;
}
var digMode = $("#digMode").val();
project.items.push({
name: name,
type: "node",
desc: desc,
digMode: digMode
});
displayMain();
});
}
function generateCode()
{
var res = "-- Mod: " + project.name + "\n";
res += "-- Code generated by the Simple Minetest Mod Maker\n";
res += "-- ( https://rubenwardy.github.io/minetest_mod_maker )\n";
for (var i = 0; i < project.items.length; i++) {
var item = project.items[i];
res += "\nminetest.register_"+item.type+"(\""+project.name+":"+item.name+"\", {\n";
res += "\tdescription = \"" + item.desc + "\",\n";
if (item.type == "node") {
res += "\ttiles = {\n";
res += "\t\t\""+project.name+"_"+item.name+"_top.png\",\n";
res += "\t\t\""+project.name+"_"+item.name+"_bottom.png\",\n";
res += "\t\t\""+project.name+"_"+item.name+"_right.png\",\n";
res += "\t\t\""+project.name+"_"+item.name+"_left.png\",\n";
res += "\t\t\""+project.name+"_"+item.name+"_back.png\",\n";
res += "\t\t\""+project.name+"_"+item.name+"_front.png\"\n";
res += "\t},\n";
res += "\tgroups = {" + item.digMode + " = 2}\n";
}
res += "})\n";
}
return res;
}
function displaySetup()
{
var tmp = "<p style=\"margin:0;\">There are a few things you need to do before we can continue. You need ";
tmp += "to create the folder structure for a mod.</p>";
tmp += "<ul style=\"margin-left: 1.5em;\">";
tmp += "<li>Find the <a href=\"http://wiki.minetest.com/wiki/Installing_mods#Install\" target=\"blank\">location";
tmp += "where you install mods</a>.</li>";
tmp += "<li>Create a folder called '"+project.name+"'. This is your mod's folder.</li>";
tmp += "<li>In that folder, create a folder called 'textures'.</li>";
tmp += "<li>Open up a text editor. The text editor must be a plain text editor. ";
tmp += "If you are on Windows, we recommend that you download <a href=\"http://notepad-plus-plus.org/\"";
tmp += " target=\"blank\">Notepad++</a>. However, WordPad is sufficient. ";
tmp += "You <b>can not</b> use Microsoft Word or Open Office.</li>";
tmp += "<li>Copy and paste the code at the bottom of this page into the text editor, ";
tmp += "and save as 'init.lua' in the mod's folder.</li>";
tmp += "<li>When you are done, click next to read about adding textures to your nodes.</li>";
tmp += "</ul>";
tmp += "<p style=\"margin:0;\"><textarea id=\"code_output\">";
tmp += generateCode();
tmp += "</textarea></p>";
tmp += "<p id=\"buttons\" style=\"margin-top:0;\"><a class=\"button long_button\" id=\"btn_home\">Back</a> ";
tmp += "<a class=\"button long_button\" id=\"btn_next\">Next</a></p>";
$("#page").html(tmp);
$("#btn_home").click(function() {
displayMain();
});
$("#btn_next").click(function() {
displayTextures();
});
}
function displayTextures()
{
var tmp = "<p>You need to create the following textures. Save them in the mod's folder under the file names given.</p>";
tmp += "<table id=\"item_list\"><tr><th>Filename</th><th>Description</th></tr>";
for (var i = 0; i < project.items.length; i++) {
var item = project.items[i];
if (item.type == "node") {
tmp += "<tr><td>"+project.name+"_"+item.name+"_top.png</td><td>The top surface of "+item.desc+"</td></tr>";
tmp += "<tr><td>"+project.name+"_"+item.name+"_bottom.png</td><td>The bottom surface of "+item.desc+"</td></tr>";
tmp += "<tr><td>"+project.name+"_"+item.name+"_right.png</td><td>The right surface of "+item.desc+"</td></tr>";
tmp += "<tr><td>"+project.name+"_"+item.name+"_left.png</td><td>The left surface of "+item.desc+"</td></tr>";
tmp += "<tr><td>"+project.name+"_"+item.name+"_back.png</td><td>The back surface of "+item.desc+"</td></tr>";
tmp += "<tr><td>"+project.name+"_"+item.name+"_front.png</td><td>The front surface of "+item.desc+"</td></tr>";
}
}
tmp += "</table>";
tmp += "<p>You're done!</p>";
tmp += "<p id=\"buttons\"><a class=\"button long_button\" id=\"btn_back\">Back</a> ";
tmp += "<a class=\"button long_button\" id=\"btn_home\">Home</a></p>";
$("#page").html(tmp);
$("#btn_back").click(function() {
displaySetup();
});
$("#btn_home").click(function() {
displayMain();
});
}
$(function() {
$("#btn_start").click(function() {
displayName(true);
});
displayMain();
});

2
assets/jquery.min.js vendored Normal file

File diff suppressed because one or more lines are too long

103
assets/style.css Normal file
View File

@ -0,0 +1,103 @@
html, body {
padding: 0;
margin: 0;
background: #333;
font-family: "Arial", sans-serif;
}
#wrap {
width: 80%;
max-width: 800px;
margin: auto;
background: white;
border-radius: 0 0 5px 5px;
padding: 0 0 10px 0;
margin-bottom: 20px;
}
p {
margin: 0;
padding: 10px 2em 10px 2em;
}
#header {
margin: 0;
padding: 1em;
background: #336699;
}
#header h1 {
margin: 0;
padding: 0;
color: white;
}
#page {
padding: 0.5em;
}
.button {
text-decoration: none;
color: white;
background: #369;
padding: 5px 1em 5px 1em;
margin: 0.5em;
border-radius: 2px;
cursor: pointer;
}
.button:hover {
background: #036;
}
.long_button {
padding: 5px 40px 5px 40px;
}
#item_list {
padding: 0 3em 0 3em;
width: 100%;
border-collapse: collapse;
}
#item_list td, #item_list th {
font-size: 1em;
border: 1px solid #036;
}
#item_list td {
padding: 8px 7px 8px 7px;
}
#item_list th {
font-size: 1.1em;
text-align: left;
padding: 5px 7px 4px 7px;
background-color: #369;
color: #ffffff;
}
#item_list tr.alt td {
color: #000000;
background-color: #EAF2D3;
}
#form_table {
margin-left: 3em;
width: 90%;
}
#form_table tr td:nth-child(1) {
width: 15%;
}
#form_table tr td:nth-child(2) {
width: 35%;
}
#form_table tr td:nth-child(3) {
padding: 10px;
width: 50%;
}
#forn_table input {
width: 100%;
}
#code_output {
width: 100%;
min-height: 200px;
}
#buttons {
text-align: center;
margin-top: 20px;
}

38
index.html Normal file
View File

@ -0,0 +1,38 @@
<!DOCTYPE html>
<html>
<head>
<title>Simple Mod Maker</title>
<link rel="stylesheet" type="text/css" href="assets/style.css">
<script src="assets/jquery.min.js"></script>
<script src="assets/editor.js"></script>
</head>
<body>
<div id="wrap">
<div id="header">
<h1>Simple Minetest Mod Maker</h1>
</div>
<div id="page">
<p>
The tool will allow you to create simple decorative blocks, without any programming,
which you can then add to Minetest as a mod.
</p>
<p>
Modding in Minetest is easy. If you are going to create anything more complicated
than a static block, then you need to learn how to program in Lua.
Or get someone else to do.
But the former is recommended.
</p>
<p>
Your progress will not be saved if you exit this tool.
You can't save or open a project file using this tool,
only export the final mod at the end.
</p>
<p style="text-align: center;">
<a id="btn_start" class="button long_button">Start</a>
</p>
</div>
</div>
</body>
</html>