share/hedgewars/Data/Scripts/Utils.lua
changeset 15970 a803428704fd
parent 14811 d65e25e211d4
equal deleted inserted replaced
15969:9128bb16aaf5 15970:a803428704fd
   125 	else
   125 	else
   126 		return integerSqrt((math.abs(x)^2) + (math.abs(y) ^ 2))
   126 		return integerSqrt((math.abs(x)^2) + (math.abs(y) ^ 2))
   127 	end
   127 	end
   128 end
   128 end
   129 
   129 
       
   130 -- Insert parameters %1 to %9 into an engine string and returns the result.
       
   131 -- * text: engine string with parameters (from GetEngineString)
       
   132 -- * ...: Arguments to insert into the string. The number of arguments MUST match
       
   133 --        the number of available arguments of the engine string
       
   134 --
       
   135 -- Example: formatEngineString(GetEngineString("TMsgStrId", sidWinner), "My Team")
       
   136 -- to create a string showing the winning team.
       
   137 function formatEngineString(text, ...)
       
   138     local input = text
       
   139     for i=1, 9 do
       
   140        text = string.gsub(text, "%%"..i, "%%s")
       
   141     end
       
   142     text = string.format(text, ...)
       
   143     return text
       
   144 end
       
   145 
   130 --[[ GLOBAL VARIABLES ]]
   146 --[[ GLOBAL VARIABLES ]]
   131 
   147 
   132 -- Shared common land color values for land sprites.
   148 -- Shared common land color values for land sprites.
   133 -- These are useful if you want to make the land type visible.
   149 -- These are useful if you want to make the land type visible.
   134 -- To be used as tint argument of PlaceSprite.
   150 -- To be used as tint argument of PlaceSprite.