모듈:Test/Bananas: 두 판 사이의 차이

위키백과, 우리 모두의 백과사전.
내용 삭제됨 내용 추가됨
편집 요약 없음
편집 요약 없음
7번째 줄: 7번째 줄:
local num_pears = param.args.pears
local num_pears = param.args.pears


return 'There are ' .. num_bananas .. ' bananas, ' .. num_apples .. ' apples, and ' .. num_pears .. 'pears.'
return 'There are ' .. num_bananas .. ' bananas, ' .. num_apples .. ' apples, and ' .. num_pears .. ' pears.'
end
end



2018년 5월 17일 (목) 11:33 판

local p = {}

-----------------------------------------------------------------------------------------------------------
function p.count_fruit(param)
   local num_bananas = param.args.bananas
   local num_apples = param.args.apples
   local num_pears = param.args.pears

  return 'There are ' .. num_bananas .. ' bananas, ' .. num_apples .. ' apples, and ' .. num_pears .. ' pears.'  
end

-- Named arguments, used like: {{#invoke:BananasArgs|count_fruit|bananas=5|apples=3}}
--function p.count_fruit(frame)
--	local num_bananas = frame.args.bananas
--	local num_apples = frame.args.apples
--	return 'I have ' .. num_bananas .. ' bananas and ' .. num_apples .. ' apples'
--end

-----------------------------------------------------------------------------------------------------------

function p.add(param)
    local num1 = tonumber(param.args[1])
    local num2 = tonumber(param.args[2])
    return num1 + num2
end

function p.subtract(param)
    local num1 = tonumber(param.args[1])
    local num2 = tonumber(param.args[2])
    return num1 - num2
end

function p.multiply(param)
    local num1 = tonumber(param.args[1])
    local num2 = tonumber(param.args[2])
    return num1 * num2
end

function p.divide(param)
    local num1 = tonumber(param.args[1])
    local num2 = tonumber(param.args[2])
    return num1 / num2
end


-- Two arguments, used like: {{#invoke:BananasArgs|add|5|3}}
--function p.add(frame)
--	local num1 = tonumber(frame.args[1])
--	local num2 = tonumber(frame.args[2])
--	return num1 + num2
--end

-----------------------------------------------------------------------------------------------------------

function p.hello2(name)
   local name1=name.args[1]
   return "안녕하세요, " .. name1 .. "!"
end

function p.hello3(name)
  local name1=name.args[1]
   return "안녕하세요, " .. name1 .."!"
end

function p.hello4(name)
   local name1=name.args[1]
   return "안녕하세요, " .. name1.."!"
end

-- One argument, used like: {{#invoke:BananasArgs|hello|Fred}} 
--function p.hello2(frame)
--	local name = frame.args[1] -- in this example, args[1] is the word Fred 
--	return "Hello, " .. name .. "!" -- .. name .. replace by the word Fred
--end

-----------------------------------------------------------------------------------------------------------

function p.hello()
   return "안녕하세요, 루아입니다."
end

return p

-- 헬로 월드!
-- local p = {}
 
-- function p.hello()
--    return "Hello, world!"
--end
 
--return p