Advertisement
Guest User

Untitled

a guest
Jul 13th, 2012
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.71 KB | None | 0 0
  1. -- Generic colored-objects template by Vanessa Ezekowitz ~~ 2012-07-13
  2.  
  3. -- License: WTFPL
  4.  
  5. -- Before using this code, consult the README, particularly the "Semi-
  6. -- automatic generation of textures" section at the end, which descibes the
  7. -- use of the gentextures.sh BASH script included in this package. You"ll
  8. -- need to either follow those instructions or create your textures the usual,
  9. -- manual way. Without textures, this code won"t be very useful. :-)
  10.  
  11. -- When configured properly, this code creates node names that follow the
  12. -- naming convention established in Unified Dyes, such as "mymod:red" or
  13. -- "mymod:dark_yellow_s50".
  14.  
  15.  
  16. -- ===========================================================================
  17. -- Edit the next several variables to define what mod this template will
  18. -- generate and how it should behave in general.
  19. -- ===========================================================================
  20.  
  21. -- First, the standard machine-readable name of your mod
  22.  
  23. colored_block_modname = "template"
  24.  
  25. -- Human-readable description of the category of nodes you want to generate
  26.  
  27. colored_block_description = "My Colored Block"
  28.  
  29. -- The full node name of the neutral version of your main block as it
  30. -- exists right after crafting or mining it, before any dyes have been
  31. -- applied. Typically, this should refer to the white version of your
  32. -- mod's main block, but it can be anything as long as it makes sense.
  33.  
  34. neutral_block = colored_block_modname..":white"
  35.  
  36. -- This variable defines just how many of a given block a crafting operation
  37. -- should give. In most cases, the default (1) is correct.
  38.  
  39. colored_block_yield = "1"
  40.  
  41. -- If this object should let sunlight pass through it, set this to "true".
  42. -- Otherwise, set it to "false" (the default).
  43.  
  44. colored_block_sunlight = "false"
  45.  
  46. -- If the node should be something you can stand on, set this to "true"
  47. -- (the default). Otherwise, set it to false.
  48.  
  49. colored_block_walkable = "true"
  50.  
  51. -- What groups should the generated nodes belong to? Note that this must
  52. -- be in the form of a table as in the default.
  53.  
  54. colored_block_groups = { snappy=3, flammable=2 }
  55.  
  56. -- What sound should be played when the node is digged?
  57.  
  58. colored_block_sound = "default.node_sound_leaves_defaults()"
  59.  
  60.  
  61. -- ======================================================
  62. -- You shouldn"t need to edit anything below this point.
  63. -- ======================================================
  64.  
  65.  
  66. -- ------------------------------------------------------------------
  67. -- Generate all of the base color node definitions and all variations
  68. -- except for the greyscale stuff.
  69.  
  70. -- Hues are on a 30 degree spacing starting at red = 0 degrees.
  71. -- "s50" in a file/item name means "saturation: 50%".
  72. -- Texture brightness levels for the colors are 100%, 66% ("medium"),
  73. -- and 33% ("dark").
  74.  
  75. shades = {
  76. "dark_",
  77. "medium_",
  78. "" -- represents "no special shade name", e.g. bright.
  79. }
  80.  
  81. shades2 = {
  82. "Dark ",
  83. "Medium ",
  84. "" -- represents "no special shade name", e.g. bright.
  85. }
  86.  
  87. hues = {
  88. "red",
  89. "orange",
  90. "yellow",
  91. "lime",
  92. "green",
  93. "aqua",
  94. "cyan",
  95. "skyblue",
  96. "blue",
  97. "violet",
  98. "magenta",
  99. "redviolet"
  100. }
  101.  
  102. hues2 = {
  103. "Red ",
  104. "Orange ",
  105. "Yellow ",
  106. "Lime ",
  107. "Green ",
  108. "Aqua ",
  109. "Cyan ",
  110. "Sky Blue ",
  111. "Blue ",
  112. "Violet ",
  113. "Magenta ",
  114. "Red-violet "
  115. }
  116.  
  117. greys = {
  118. "black",
  119. "darkgrey",
  120. "mediumgrey",
  121. "lightgrey",
  122. "white"
  123. }
  124.  
  125. greys2 = {
  126. "Black ",
  127. "Dark Grey ",
  128. "Medium Grey ",
  129. "Light Grey ",
  130. "White "
  131. }
  132.  
  133. greys3 = {
  134. "black",
  135. "darkgrey_paint",
  136. "mediumgrey_paint",
  137. "lightgrey_paint",
  138. "white_paint"
  139. }
  140.  
  141. for shade = 1, 3 do
  142.  
  143. print ("shade loop start")
  144.  
  145. shadename = shades[shade]
  146. shadename2 = shades2[shade]
  147.  
  148. for hue = 1, 12 do
  149.  
  150. print ("hue loop start")
  151.  
  152. huename = hues[hue]
  153. huename2 = hues2[hue]
  154.  
  155. colorname = colored_block_modname..":"..shadename..huename
  156. pngname = colored_block_modname.."_"..shadename..huename..".png"
  157. nodedesc = shadename2..huename2..colored_block_description
  158. s50colorname = colored_block_modname..":"..shadename..huename.."_s50"
  159. s50pngname = colored_block_modname.."_"..shadename..huename.."_s50.png"
  160. s50nodedesc = shadename2..huename2..colored_block_description.." (50% Saturation)"
  161.  
  162. print ("register node "..colorname)
  163.  
  164. minetest.register_node(colorname, {
  165. description = nodedesc,
  166. tiles = { pngname },
  167. inventory_image = pngname,
  168. wield_image = pngname,
  169. sunlight_propagates = colored_block_sunlight,
  170. paramtype = "light",
  171. walkable = colored_block_walkable,
  172. groups = colored_block_groups,
  173. sounds = colored_block_sound
  174. })
  175.  
  176. print ("register node "..s50colorname)
  177.  
  178. minetest.register_node(s50colorname, {
  179. description = s50nodedesc,
  180. tiles = { s50pngname },
  181. inventory_image = s50pngname,
  182. wield_image = s50pngname,
  183. sunlight_propagates = colored_block_sunlight,
  184. paramtype = "light",
  185. walkable = colored_block_walkable,
  186. groups = colored_block_groups,
  187. sounds = colored_block_sound
  188. })
  189.  
  190. print ("register craft "..colorname)
  191.  
  192. minetest.register_craft( {
  193. type = "shapeless",
  194. output = colorname.." "..colored_block_yield,
  195. recipe = {
  196. neutral_block,
  197. "unifieddyes:"..shadename.."_"..huename
  198. }
  199. })
  200.  
  201. print ("register craft "..s50colorname)
  202.  
  203. minetest.register_craft( {
  204. type = "shapeless",
  205. output = colorname.." "..colored_block_yield,
  206. recipe = {
  207. neutral_block,
  208. "unifieddyes:"..shadename.."_"..huename.."_s50"
  209. }
  210. })
  211.  
  212. end
  213. end
  214.  
  215.  
  216. -- ============================================================
  217. -- The 5 levels of greyscale.
  218. --
  219. -- Oficially these are 0, 25, 50, 75, and 100% relative to white,
  220. -- but in practice, they're actually 7.5%, 25%, 50%, 75%, and 95%.
  221. -- (otherwise black and white would wash out).
  222.  
  223. for grey = 1,5 do
  224.  
  225. print ("grey loop start")
  226.  
  227. greyname = greys[grey]
  228. greyname2 = greys2[grey]
  229. greyname3 = greys3[grey]
  230.  
  231. greyshadename = colored_block_modname..":"..greyname
  232. pngname = colored_block_modname.."_"..greyname..".png"
  233. nodedesc = greyname2..colored_block_description
  234.  
  235. print ("register node "..greyshadename)
  236.  
  237. minetest.register_node(greyshadename, {
  238. description = nodedesc,
  239. tiles = { pngname },
  240. inventory_image = pngname,
  241. wield_image = pngname,
  242. sunlight_propagates = colored_block_sunlight,
  243. paramtype = "light",
  244. walkable = colored_block_walkable,
  245. groups = colored_block_groups,
  246. sounds = colored_block_sound
  247. })
  248.  
  249. print ("register craft "..greyshadename)
  250.  
  251. minetest.register_craft( {
  252. type = "shapeless",
  253. output = greyshadename.." "..colored_block_yield,
  254. recipe = {
  255. neutral_block,
  256. "unifieddyes:"..greyname3
  257. }
  258. })
  259.  
  260. end
  261.  
  262.  
  263. print("[" .. colored_block_modname .. "] Loaded!")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement