From a36e231883d595bcba91d44e19f24b31eaf0431b Mon Sep 17 00:00:00 2001 From: Thorbjørn Lindeijer Date: Sun, 26 Feb 2012 23:28:43 +0100 Subject: A bunch of cleanups to example Lua scripts Mostly removed bulky copyright headers and fixed indentation and line length. Reviewed-by: Yohann Ferreira Reviewed-by: Erik Schilling --- example/scripts/crafting.lua | 44 ++++++++++++++++---------------------------- 1 file changed, 16 insertions(+), 28 deletions(-) (limited to 'example/scripts/crafting.lua') diff --git a/example/scripts/crafting.lua b/example/scripts/crafting.lua index eae26a4..54e8c9a 100644 --- a/example/scripts/crafting.lua +++ b/example/scripts/crafting.lua @@ -1,17 +1,8 @@ -------------------------------------------------------------- --- Example crafting script file -- --- -- --- This file allows you to implement your own crafting -- --- system. -- ----------------------------------------------------------------------------------- --- Copyright 2011 Manasource Development Team -- --- -- --- This file is part of Manasource. -- --- -- --- Manasource is free software; you can redistribute it and/or modify it -- --- under the terms of the GNU General Public License as published by the Free -- --- Software Foundation; either version 2 of the License, or any later version. -- ----------------------------------------------------------------------------------- +--[[ + + This file provides an example of a simple crafting system. + +--]] -- This function is called by the game engine when a character tries to craft -- something from items in its inventory @@ -19,10 +10,10 @@ function on_craft(ch, recipe) -- ch is the crafting character -- -- recipe is a table with the ingredients. - -- it is a common 1-based array. each element of this array is a table with the - -- two keys "id" and "amount". - -- The engine has already checked that the character owns enough of those things, - -- so you needn't do this again. + -- it is a common 1-based array. each element of this array is a table with + -- the two keys "id" and "amount". + -- The engine has already checked that the character owns enough of those + -- things, so you needn't do this again. -- uncomment one (but not both!) of the following three lines to enable the -- example crafting systems @@ -57,8 +48,8 @@ function craft_lax(ch, recipe) recipe[2].id == 9 and recipe[2].amount >= 1) -- and at least one wood then mana.chr_inv_change(ch, - 8, -2, --take away the iron - 9, -1, --take away the wood + 8, -2, -- take away the iron + 9, -1, -- take away the wood 5, 1 ) -- give a sword mana.chat_message(ch, "You've crafted a sword") return @@ -68,10 +59,9 @@ end -- this turns multiple occurences of the same item into one by adding up -- their amounts and sorts the recipe by item ID. --- This makes stuff a lot easier when your crafting system isn't supposed to care --- about the order items are in. +-- This makes stuff a lot easier when your crafting system isn't supposed to +-- care about the order items are in. function make_condensed_and_sorted_item_list(recipe) - local condensed = {} for index, item in pairs(recipe) do if condensed[item.id] == nil then @@ -90,10 +80,8 @@ function make_condensed_and_sorted_item_list(recipe) end table.sort(sorted, function(item1, item2) - return (item1.id < item2.id) - end - ) + return (item1.id < item2.id) + end) return sorted - -end \ No newline at end of file +end -- cgit