Mod Tool: Difference between revisions

72 bytes added ,  17 October 2012
m
no edit summary
m (scripting: turning a function with arguments into a command)
mNo edit summary
Line 72: Line 72:
  ' this function can only be used inside the script where it was defined
  ' this function can only be used inside the script where it was defined
   
   
  function simple_math (a, b, mode)
  function simple_math (a, b, operator)
  if mode = "+" then
  if operator = "+" then
   simple_math = a + b
   simple_math = a + b
  elseif mode = "-" then
  elseif operator = "-" then
  simple_math = a - b
  simple_math = a - b
  elseif mode = "/" then
  elseif operator = "/" then
  simple_math = a / b
  simple_math = a / b
  elseif mode = "x" then
  elseif operator = "x" then
  simple_math = a * b
  simple_math = a * b
  else
  else
  logmessage "This opperator is not allowed. Use one of those:" & vbCrlf & "+ - / x"
  logmessage "The used operator is not allowed. Choose one of the following:" & vbCrlf & "+ - / x"
  end if
  end if
  end function
  end function
Line 125: Line 125:
  oArgs.Add "a",siArgumentInput,"0"
  oArgs.Add "a",siArgumentInput,"0"
  oArgs.Add "b",siArgumentInput,"0"
  oArgs.Add "b",siArgumentInput,"0"
  oArgs.Add "mode",siArgumentInput,"0"
  oArgs.Add "operator",siArgumentInput,"0"
  simple_math_Init = true
  simple_math_Init = true
  end function
  end function
   
   
  function simple_math_Execute( a, b, mode )
  function simple_math_Execute( a, b, operator )
  ' convert to double
  ' convert to double
  a = cdbl(a)
  a = cdbl(a)
  b = cdbl(b)
  b = cdbl(b)
 
 
  if mode = "+" then
  if operator = "+" then
  simple_math_Execute = a + b
  simple_math_Execute = a + b
  elseif mode = "-" then
  elseif operator = "-" then
  simple_math_Execute = a - b
  simple_math_Execute = a - b
  elseif mode = "/" then
  elseif operator = "/" then
  simple_math_Execute = a / b
  simple_math_Execute = a / b
  elseif mode = "x" then
  elseif operator = "x" then
  simple_math_Execute = a * b
  simple_math_Execute = a * b
  else
  else
  logmessage "This opperator is not allowed. Use one of those:" & vbCrlf & "+ - / x"
  logmessage "The used operator is not allowed. Choose one of the following:" & vbCrlf & "+ - / x"
  end if
  end if
  end function
  end function
8,452

edits