Browse Source

patch legacy elk, add generatemod.py

master
poikilos 6 years ago
committed by Jacob Gustafson
parent
commit
5091f3b29d
  1. 20
      patches/example_license.txt
  2. 198
      patches/generatemod.py
  3. 20
      patches/mods-stopgap/elk_legacy/LICENSE.txt
  4. 1
      patches/mods-stopgap/elk_legacy/depends.txt
  5. 2
      patches/mods-stopgap/elk_legacy/description.txt
  6. 5
      patches/mods-stopgap/elk_legacy/init.lua
  7. 1
      patches/mods-stopgap/elk_legacy/mod.conf
  8. 6
      patches/mods-stopgap/elk_legacy/readme.md
  9. 31
      webapp/views/pages/modding.ejs

20
patches/example_license.txt

@ -0,0 +1,20 @@
Copyright <year> <copyright holder>
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

198
patches/generatemod.py

@ -0,0 +1,198 @@
#!/usr/bin/env python
import sys
import os
import shutil
# sys.argv[0] is name of script
myPath = os.path.realpath(__file__)
myDir = os.path.dirname(myPath)
def customDie(msg, code=1):
print("")
print("ERROR:")
print(msg)
print("")
print("")
exit(code)
def usage():
print("Usage:")
print(sys.argv[0] + " mod [options]")
print("")
print("Options:")
print(
'''
--fill adds only missing files to an existing mod (instead of
failing when directory exists).
[alias to] (do not actually use brackets) If you specify any two
options without --, the first will be an alias and the
second will be convert_to. The alias options are only for
mods that are aliases, as a shortcut to creating a mostly
complete mod (other than copyright information and
description) with only this script.
'''
)
print("")
print("Examples:")
print(sys.argv[0] + " mod_name")
print(sys.argv[0] + " mod_name --fill")
print(sys.argv[0] + " mod_name modname:item_name other_modname:convert_to")
print(sys.argv[0] + " mod_name mobsmod:mob_name other_mobsmod:convert_to")
print("")
print("")
licSrc = "example_license.txt"
licDestName = "LICENSE.txt"
licDesc = "MIT License"
if not os.path.isfile(licSrc):
tryLicSrc = os.path.join(myDir, licSrc)
if not os.path.isfile(tryLicSrc):
print("ERROR: missing " + licSrc)
exit(1)
else:
licSrc = tryLicSrc
toMod = None
fromName = None
toName = None
extraArgCount = 0
enableFill = False
options = []
for i in range(1, len(sys.argv)):
if sys.argv[i] == "--fill":
extraArgCount += 1
enableFill = True
else:
if (len(sys.argv[i]) >= 2) and (sys.argv[i][:2] == "--"):
usage()
customDie("Invalid option: " + sys.argv[i])
options.append(sys.argv[i])
if (len(options) != 1) and (len(options) != 3):
usage()
exit(1)
thisName = options[0]
if os.path.isdir(thisName):
if not enableFill:
print("")
print("ERROR: A mod named " + thisName + " cannot be ")
print("generated when the directory already exists.")
print("")
exit(1)
else:
os.mkdir(thisName)
if (len(options) == 3):
fromName = options[1]
toName = options[2]
delimI = toName.rfind(":")
if delimI > -1:
toMod = toName[:delimI]
if toMod.find(":") > -1:
usage()
customDie("Your modname contains too many colons.")
exit(1)
else:
toMod = "default"
mobAPI = None
if toMod is not None:
if not os.path.isfile(os.path.join(thisName, "depends.txt")):
dependsOut = open(os.path.join(thisName, "depends.txt"), 'w')
dependsOut.write(toMod+"\n")
dependsOut.close()
if toMod.find("mob") > -1:
mobAPI = toMod
if not os.path.isfile(os.path.join(thisName, "description.txt")):
descOut = open(os.path.join(thisName, "description.txt"), 'w')
descOut.write("\n")
descOut.close()
if not os.path.isfile(os.path.join(thisName, "mod.conf")):
confOut = open(os.path.join(thisName, "mod.conf"), 'w')
confOut.write("name = "+thisName+"\n")
confOut.close()
if not os.path.isfile(os.path.join(thisName, "readme.md")):
readmeOut = open(os.path.join(thisName, "readme.md"), 'w')
readmeLine1 = thisName + " Minetest Mod"
readmeOut.write(readmeLine1+"\n")
readmeOut.write("="*len(readmeLine1)+"\n")
readmeOut.write("See description.txt\n")
readmeOut.write("\n")
readmeOut.write("## License\n")
readmeOut.write("See " + licDestName + "\n")
readmeOut.close()
licDest = os.path.join(thisName, licDestName)
if not os.path.isfile(licDest):
shutil.copyfile(licSrc, licDest)
luaOut = None
if not os.path.isfile(os.path.join(thisName, "init.lua")):
luaOut = open(os.path.join(thisName, "init.lua"), 'w')
# luaOut.write("#!/usr/bin/env lua\n")
luaOut.write("-- " + sys.argv[0] + " (EnlivenMinetest) generated\n")
luaOut.write("-- the original version of this file.\n")
fromMod = None # not required
step0 = ""
if (len(options) == 3):
delimI = fromName.find(":")
if delimI > -1:
fromMod = fromName[:delimI]
else:
fromMod = ""
apiLinePrefix = ""
mobLinePrefix = ""
if luaOut is not None:
if mobAPI is not None:
apiLinePrefix = "-- "
else:
mobLinePrefix = "-- "
luaOut.write("-- If your mobs API doesn't contain the\n")
luaOut.write("-- word 'mobs', your alias method is not\n")
luaOut.write("-- known. In that case, you may have to\n")
luaOut.write("-- change minetest.register_alias to your\n")
luaOut.write("-- mob API's (if your alias is for a mob).\n")
luaOut.write(mobLinePrefix + mobAPI + ':alias_mob("'
+ fromName + '", "' + toName + '")' + "\n")
luaOut.write(apiLinePrefix + 'minetest.register_alias("'
+ fromName + '", "' + toName + '")' + "\n")
else:
step0 = "Add your code init.lua."
if luaOut is not None:
luaOut.write("\n")
luaOut.close()
print("")
print("")
print(step0)
print("The new mod is the " + thisName + " folder. Remember to:")
ender = "."
if (toMod is not None) and (len(toMod) > 0):
ender = ""
print("1. Edit depends.txt if your mod requires some mod" + ender)
if (toMod is not None) and (len(toMod) > 0):
print(" other than '" + toMod + "'.")
print("")
print("2. Edit description.txt to contain a brief description of")
print(" your mod (less than 100 characters).")
print("")
print("3. Edit LICENSE.txt and add the year and the name of all ")
print(" authors, and change the license if desired (The included")
print(" " + licSrc)
print(" should be the " + licDesc + ".")
print(
''' The MIT License is good for Minetest mods so they can be used
most widely such as on app stores where replacing the program as per
the GPL v3 is not compliant with mobile OS security--the license of
most Minetest releases is the MIT License). Some joke licenses exist
but DO NOT protect your work in cases where they explicitly allow
others to copy your work and claim it as their own especially if they
modify it in any way. They would just be doing what you said they
could do!
'''
)
print("")
print("")

20
patches/mods-stopgap/elk_legacy/LICENSE.txt

@ -0,0 +1,20 @@
Copyright 2019 Poikilos (Jake Gustafson)
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

1
patches/mods-stopgap/elk_legacy/depends.txt

@ -0,0 +1 @@
codermobs

2
patches/mods-stopgap/elk_legacy/description.txt

@ -0,0 +1,2 @@
This mod transitions the elk that is from old versions of ENLIVEN or
Bucket_Game.

5
patches/mods-stopgap/elk_legacy/init.lua

@ -0,0 +1,5 @@
-- ../generatemod.py (EnlivenMinetest) generated
-- the original version of this file.
codermobs:alias_mob("codermobs:elk_male", "codermobs:elk")
-- minetest.register_alias("codermobs:elk_male", "codermobs:elk")

1
patches/mods-stopgap/elk_legacy/mod.conf

@ -0,0 +1 @@
name = elk_legacy

6
patches/mods-stopgap/elk_legacy/readme.md

@ -0,0 +1,6 @@
elk_legacy Minetest Mod
=======================
See description.txt
## License
See LICENSE.txt

31
webapp/views/pages/modding.ejs

@ -59,7 +59,11 @@ Minetest's core functionality is written in Lua.
Lua, every mod is open source. Almost every one is released under Lua, every mod is open source. Almost every one is released under
some sort of public license as well, which usually allows you to modify, some sort of public license as well, which usually allows you to modify,
reuse, and redistribute the code (usually under the condition that you reuse, and redistribute the code (usually under the condition that you
credit the original author). The license file sometimes has no file credit the original author). <i>Some joke licenses exist but DO NOT
protect your work in cases where they explicitly allow others to copy
your work and claim it as their own especially if modified it in any
way--they would just be doing what you said they could do.</i></p>
<p>The license file sometimes has no file
extension, so you may have to pick a program to open it in Windows. extension, so you may have to pick a program to open it in Windows.
You can open it (or any other text file) in Notepad. However, Geany You can open it (or any other text file) in Notepad. However, Geany
is recommended since there is more than one undo step. For Lua is recommended since there is more than one undo step. For Lua
@ -232,6 +236,31 @@ cannot be smelted nor drop a mineral--they still use the
minetest.register_ore function).</p> minetest.register_ore function).</p>
<h2>Appendices</h2> <h2>Appendices</h2>
<h3>Common Errors</h3>
<p class="lead"><samp color="darkred">ERROR[Server]: LuaEntity name
"creatures:chicken" not defined</samp></p>
<p>If you have the error above, you have removed a mod or customized a
creature so it has a different name.</p>
<p>To convert the mob to some other mob, try something like:</p>
<code>mobs:alias_mob("creatures:chicken", "codermobs:chicken")</code>
<p>If you have an unknown node (you see blocks in the game that say
"unknown node" on them), you may need an additional mod to support
your world. If you removed a mod on purpose or a node was renamed in a
later version (see nftools example below), you can use Minetest's
builtin alias function to make a mod to convert the nodes:
<code>minetest.register_alias("name", "convert_to")</code>
Example content for init.lua:
<code>minetest.register_alias("nftools:aquamarine_ore", "nftools:stone_with_turquoise")</code>
In that case, your depends.txt must contain one line:
<code>nftools</code>
</p>
<p>The alias function may be confusing: You are registering the alias
parameter 1 for parameter 2, which means that you are defining parameter
1 as an alias--not a real item--but another name for convert_to. When
the world is saved, only convert_to will be saved. If you are sure that
all of the world was loaded that contained the problematic nodes
(players visited all of those areas) then you can remove your
transitional mod.</p>
<h3>Common Items for Moderators to Spawn</h3> <h3>Common Items for Moderators to Spawn</h3>
(list of item names for /giveme itemname) (list of item names for /giveme itemname)
<pre> <pre>

Loading…
Cancel
Save