SHARE
TWEET

Untitled

henry9836 Jan 4th, 2019 84 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. '''
  2. Automatic Mod Builder For Minetest V1.0
  3.  
  4.  
  5. by Henry Oliver (github.com/henry9836)
  6. '''
  7.  
  8. import os
  9. import shutil
  10.  
  11. global modname
  12. global path
  13. global f
  14.  
  15. def initnewmod():
  16.     #FILTER
  17.     global modname
  18.     global path
  19.     global f
  20.     modname = modname.lower()
  21.     modname = modname.replace(' ', '')
  22.  
  23.     path = modname + "/init.lua"
  24.     try:
  25.         os.mkdir(modname)
  26.         f = open(path ,"w+")
  27.         f.write("-- Built Using the Automatic Mod Builder For Minetest by Henry Oliver (github.com/henry9836) \r\n")
  28.         f.close()
  29.     except:
  30.         try:
  31.             os.remove(path)
  32.             f = open(path ,"w+")
  33.             f.write("-- Built Using the Automatic Mod Builder For Minetest by Henry Oliver (github.com/henry9836) \r\n")
  34.             f.close()
  35.         except:
  36.             print("Access Denied to create files quitting...")
  37.             quit()
  38.     mainmenu()
  39.  
  40. def clear():
  41.     if os.name == 'nt':
  42.         os.system('cls')
  43.     elif os.name == 'posix':
  44.         os.system('clear')
  45.     else:
  46.         print("clearing...")
  47.         for x in range(100):
  48.             print("")
  49.  
  50. def addblock():
  51.     global modname
  52.     newblockid = ""
  53.     extra = ""
  54.     extramod = ""
  55.     clear()
  56.     print("-= Block Factory =-")
  57.     newblockid = input("Block/Node Name: ")
  58.     newblockid = newblockid.replace(' ', '')
  59.     newblockid = (modname + ":" + newblockid)
  60.     desc = input("Description: ")
  61.     inp = input("Single Texture or Multiple Textures [S/m]: ")
  62.     if (inp == "m"):
  63.         print("not in yet :P")
  64.     else:
  65.         try:
  66.             os.mkdir(os.getcwd()+"/"+modname+"/media")
  67.         except:
  68.             print()
  69.         pic_location = input("Drag a texture in (must be: 16x16, 32x32, 64x64, 128x128, etc ONLY): ")
  70.         tmppath = os.getcwd()+"/"+modname+"/media"
  71.         shutil.copy(pic_location, tmppath)
  72.         texturename = input("Name of texture (with extension [e.g picture.png]): ")
  73.         tiles = 'tiles = {"'+ texturename +'"}'
  74.  
  75.         # Extras
  76.         inp = input("Transparent? [N/y]")
  77.         if (inp == "y"):
  78.             inp = input("[G]lass Like or [L]eaf Like? [G/l]")
  79.             if (inp == "l"):
  80.                 extra = extra + ', drawtype = "allfaces"'
  81.             else:
  82.                 inp = input("Connect Glasslike? [Y/n]")
  83.                 if (inp == "n"):
  84.                     extra = extra + ', drawtype = "glasslike"'
  85.                 else:
  86.                     extra = extra + ', drawtype = "glasslike_framed"'
  87.         inp = input("Should it come up in the creative menu? [Y/n]")
  88.         if (inp != "n"):
  89.             block_n = input("Name of new block: ")
  90.             extra = extra + ', minetest.register_alias("' + block_n + '", "'+newblockid+'"), itemname = minetest.registered_aliases[itemname] or itemname'
  91.         inp = input("Is this an ore? [N/y]")
  92.         if (inp == "y"):
  93.             extra = extra + ', is_ground_content = true, groups = {cracky=3, stone=1}'
  94.             inp = input("Does it drop any items when destroyed? [Y/n]")
  95.             if (inp != "n"):
  96.                 inp = input("Name of item dropped: ")
  97.                 inp2 = input("is it from [Y]our mod, [D]eafault or [O]ther mod? [Y/d/o]")
  98.                 if (inp2 == "d"):
  99.                     extra = extra + ', drop = "default:'+ inp +'"'
  100.                 elif (inp2 == "o"):
  101.                     inp3 = input("name of other mod: ")
  102.                     extra = extra + ', drop = "' + inp3 + ':' + inp +'"'
  103.                 else:
  104.                     extra = extra + ', drop = "' + modname + ':' + inp +'"'
  105.             extramod = '\r\n ' + 'minetest.register_ore({ ore_type = "scatter", ore = "'+ newblockid + '", wherein = "default:stone", clust_scarcity = 8*8*8, clust_num_ores = 8, clust_size     = 3, height_min     = -31000, height_max     = 64,})'
  106.  
  107.  
  108.  
  109.     #BUILD Time
  110.  
  111.     chunk = 'minetest.register_node("'+newblockid+'", { description = "' + desc + '", ' + tiles + extra + '}) \r\n' + extramod + '\r\n'
  112.     f = open(path ,"a+")
  113.     f.write(chunk)
  114.     f.close()
  115.  
  116. def additem():
  117.     global modname
  118.     newitemid = ""
  119.     extra = ""
  120.     extramod = ""
  121.     clear()
  122.     print("-= Item Forger =-")
  123.     newitemid = input("Item Name: ")
  124.     newitemid = newitemid.replace(' ', '')
  125.     newitemid = (modname + ":" + newitemid)
  126.     desc = input("Description: ")
  127.     try:
  128.         os.mkdir(os.getcwd()+"/"+modname+"/textures")
  129.     except:
  130.         print()
  131.     pic_location = input("Drag a texture in (must be: 16x16, 32x32, 64x64, 128x128, etc ONLY): ")
  132.     tmppath = os.getcwd()+"/"+modname+"/textures"
  133.     shutil.copy(pic_location, tmppath)
  134.     texturename = input("Name of texture (with extension [e.g picture.png]): ")
  135.     inventory_image = 'inventory_image = "'+ texturename +'"'
  136.  
  137.     #EXTRAS
  138.  
  139.     inp = input("Should it come up in the creative menu? [Y/n]")
  140.     if (inp != "n"):
  141.         item_n = input("Name of item: ")
  142.         extra = extra + ', minetest.register_alias("' + item_n + '", "'+newitemid+'"), itemname = minetest.registered_aliases[itemname] or itemname'
  143.     inp = input("Do you want the item to print to chat when left clicked? [N/y]")
  144.     if (inp == "y"):
  145.         msg = input("Message: ")
  146.         extra = extra + ', on_use = function(itemstack, placer, pointed_thing) minetest.chat_send_player(placer:get_player_name(), "' + msg + '") return itemstack end'
  147.  
  148.     #Crafting
  149.     inp = input("Do you want the item to be craftable? [Y/n]")
  150.  
  151.     if (inp != "n"):
  152.         inp10 = input("Amount Outputted: ")
  153.         inp1 = input("Top-Left Slot format(modname:item): ")
  154.         inp2 = input("Top-Mid Slot format(modname:item): ")
  155.         inp3 = input("Top-Right Slot format(modname:item): ")
  156.         inp4 = input("Mid-Left Slot format(modname:item): ")
  157.         inp5 = input("Mid-Mid Slot format(modname:item): ")
  158.         inp6 = input("Mid-Right Slot format(modname:item): ")
  159.         inp7 = input("Bottom-Left Slot format(modname:item): ")
  160.         inp8 = input("Bottom-Mid Slot format(modname:item): ")
  161.         inp9 = input("Bottom-Right Slot format(modname:item): ")
  162.         extramod = '\r\n ' + 'minetest.register_craft({ type = "shaped", output = "'+ newitemid + " " + inp10 + '", recipe = {{"'+ inp1 +'", "'+ inp2 +'", "'+ inp3 +'"},{"'+ inp4 +'", "'+ inp5 +'", "'+ inp6 +'"},{"'+ inp7 +'", "'+ inp8 +'", "'+ inp9 +'"}}})'
  163.  
  164.  
  165.  
  166.     #BUILD TIME
  167.  
  168.     chunk = 'minetest.register_craftitem("'+newitemid+'", { description = "' + desc + '", inventory_image = "' + texturename + '" ' + extra + '}) \r\n' + extramod + '\r\n'
  169.     f = open(path ,"a+")
  170.     f.write(chunk)
  171.     f.close()
  172.  
  173. def mainmenu():
  174.     global modname
  175.     global path
  176.     clear()
  177.     print("-= Main Menu =-")
  178.     print("Currently Working on: " + modname + ", located at: "+ os.getcwd() + "/" + path)
  179.     print("Options")
  180.     print("1. Add a block/node")
  181.     print("2. Add an item")
  182.     print("99. Exit")
  183.     inp = input("Select An Option: ")
  184.     if (inp == "1"):
  185.         addblock()
  186.     elif (inp == "2"):
  187.         additem()
  188.     elif (inp == "99"):
  189.         quit()
  190.     mainmenu()
  191.  
  192. #START
  193.  
  194. print("Welcome to the Automatic Mod Builder For Minetest")
  195. print("Verison: V1.0")
  196. print("~Built by Henry Oliver")
  197. print("")
  198. inp = input("Make a New Mod [Y/n]: ")
  199. if (inp == "n"):
  200.     modname = input("Mod Name: ")
  201.     path = modname + "/init.lua"
  202.     try:
  203.         f = open(path ,"a+")
  204.         f.write("-- Built Using the Automatic Mod Builder For Minetest by Henry Oliver (github.com/henry9836) \r\n")
  205.         f.close()
  206.     except:
  207.         print("Access Denied to edit files quitting...")
  208.         quit()
  209.     mainmenu()
  210. else:
  211.     modname = input("Mod Name: ")
  212.     initnewmod()
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top