String To Image Tutorial: Difference between revisions

From Legacy Roblox Wiki
Jump to navigationJump to search
>WildSurvival
New page: {{CatUp|Tutorial}} ==Introduction== Converting a String to an Image is where lets say I have the string "Hello World!". Converting this to an image would be making a brick for eac...
>JulienDethurens
Corrected a mistake.
 
(9 intermediate revisions by 3 users not shown)
Line 1: Line 1:
{{CatUp|Tutorial}}
{{CatUp|Tutorial}}
 
{{EmphasisBox|Warning: This tutorial does not turn a string into a decal. It creates bricks with decals of letters on.}}
==Introduction==
==Introduction==
Converting a [[String]] to an [[Image]] is where lets say I have the string "Hello World!". Converting this to an image would be making a brick for each letter and placing a decal on it with the letter. Were going to do this by using a function to make it easier, not having to do it manually. This can be used for many features in a game, like a Player's Sign on their house or etc.
Converting a [[String]] to an [[Image]] is where let's say I have the string "Hello World!". Converting this to an image would be making a brick for each letter and placing a decal on it with the letter. Were going to do this by using a function to make it easier, not having to do it manually. This can be used for many features in a game, like a Player's Sign on their house or etc.


==Image Table==
==Image Table==
First off, you will need a table of images for each character. You can make your own or use someone elses. I will be using one provided by xXLegoXx.
First off, you will need a table of images for each character. You can make your own or use someone elses. I will be using one provided by xXLegoXx.


<pre>
Heres the link to the Table : [http://www.roblox.com/Character-Table-item?id=55987833 Here]
Characters = {}
Characters["-"] = "http://www.roblox.com/asset/?id=7287752"
Characters["#"] = "http://www.roblox.com/asset/?id=7287754"
Characters["$"] = "http://www.roblox.com/asset/?id=7287756"
Characters["%"] = "http://www.roblox.com/asset/?id=7287761"
Characters["&"] = "http://www.roblox.com/asset/?id=7287765"
Characters["("] = "http://www.roblox.com/asset/?id=7287773"
Characters[")"] = "http://www.roblox.com/asset/?id=7287775"
Characters["@"] = "http://www.roblox.com/asset/?id=7287777"
Characters["["] = "http://www.roblox.com/asset/?id=7287779"
Characters["]"] = "http://www.roblox.com/asset/?id=7287783"
Characters["^"] = "http://www.roblox.com/asset/?id=7287785"
Characters["_"] = "http://www.roblox.com/asset/?id=7287789"
Characters["`"] = "http://www.roblox.com/asset/?id=7287800"
Characters["{"] = "http://www.roblox.com/asset/?id=7287806"
Characters["}"] = "http://www.roblox.com/asset/?id=7287813"
Characters["~"] = "http://www.roblox.com/asset/?id=7287822"
Characters["+"] = "http://www.roblox.com/asset/?id=7287829"
Characters["="] = "http://www.roblox.com/asset/?id=7287833"
Characters["0"] = "http://www.roblox.com/asset/?id=7287836"
Characters["1"] = "http://www.roblox.com/asset/?id=7287840"
Characters["2"] = "http://www.roblox.com/asset/?id=7287843"
Characters["3"] = "http://www.roblox.com/asset/?id=7287849"
Characters["4"] = "http://www.roblox.com/asset/?id=7287853"
Characters["5"] = "http://www.roblox.com/asset/?id=7287856"
Characters["6"] = "http://www.roblox.com/asset/?id=7287860"
Characters["7"] = "http://www.roblox.com/asset/?id=7287866"
Characters["8"] = "http://www.roblox.com/asset/?id=7287871"
Characters["9"] = "http://www.roblox.com/asset/?id=7287880"
Characters["a"] = "http://www.roblox.com/asset/?id=7287884"
Characters["A"] = "http://www.roblox.com/asset/?id=7287888"
Characters["b"] = "http://www.roblox.com/asset/?id=7287897"
Characters["\\"] = "http://www.roblox.com/asset/?id=7287902"
Characters["B"] = "http://www.roblox.com/asset/?id=7287908"
Characters["c"] = "http://www.roblox.com/asset/?id=7287939"
Characters["C"] = "http://www.roblox.com/asset/?id=7287941"
Characters[":"] = "http://www.roblox.com/asset/?id=7287943"
Characters[","] = "http://www.roblox.com/asset/?id=7287949"
Characters["d"] = "http://www.roblox.com/asset/?id=7287952"
Characters["D"] = "http://www.roblox.com/asset/?id=7287956"
Characters["e"] = "http://www.roblox.com/asset/?id=7287964"
Characters["E"] = "http://www.roblox.com/asset/?id=7287970"
Characters["!"] = "http://www.roblox.com/asset/?id=7287977"
Characters["f"] = "http://www.roblox.com/asset/?id=7287981"
Characters["F"] = "http://www.roblox.com/asset/?id=7287987"
Characters["g"] = "http://www.roblox.com/asset/?id=7287990"
Characters["G"] = "http://www.roblox.com/asset/?id=7287994"
Characters[">"] = "http://www.roblox.com/asset/?id=7287996"
Characters["h"] = "http://www.roblox.com/asset/?id=7287998"
Characters["H"] = "http://www.roblox.com/asset/?id=7288002"
Characters["i"] = "http://www.roblox.com/asset/?id=7288006"
Characters["\""] = "http://www.roblox.com/asset/?id=7288015"
Characters["\'"] = "http://www.roblox.com/asset/?id=7288018"
Characters["I"] = "http://www.roblox.com/asset/?id=7288022"
Characters["j"] = "http://www.roblox.com/asset/?id=7288027"
Characters["J"] = "http://www.roblox.com/asset/?id=7288034"
Characters["k"] = "http://www.roblox.com/asset/?id=7288038"
Characters["K"] = "http://www.roblox.com/asset/?id=7288048"
Characters["l"] = "http://www.roblox.com/asset/?id=7288372"
Characters["<"] = "http://www.roblox.com/asset/?id=7288379"
Characters["|"] = "http://www.roblox.com/asset/?id=7288384"
Characters["L"] = "http://www.roblox.com/asset/?id=7288388"
Characters["m"] = "http://www.roblox.com/asset/?id=7288393"
Characters["M"] = "http://www.roblox.com/asset/?id=7288397"
Characters["n"] = "http://www.roblox.com/asset/?id=7288418"
Characters["N"] = "http://www.roblox.com/asset/?id=7288423"
Characters["o"] = "http://www.roblox.com/asset/?id=7288425"
Characters["O"] = "http://www.roblox.com/asset/id=7288429"
Characters["p"] = "http://www.roblox.com/asset/?id=7288431"
Characters["."] = "http://www.roblox.com/asset/?id=7288437"
Characters["P"] = "http://www.roblox.com/asset/?id=7300857"
Characters["q"] = "http://www.roblox.com/asset/?id=7288441"
Characters["Q"] = "http://www.roblox.com/asset/?id=7288447"
Characters["?"] = "http://www.roblox.com/asset/?id=7288453"
Characters["r"] = "http://www.roblox.com/asset/?id=7288530"
Characters["R"] = "http://www.roblox.com/asset/?id=7288532"
Characters["s"] = "http://www.roblox.com/asset/?id=7288535"
Characters[";"] = "http://www.roblox.com/asset/?id=7288540"
Characters["/"] = "http://www.roblox.com/asset/?id=7288542"
Characters["S"] = "http://www.roblox.com/asset/?id=7288544"
Characters["t"] = "http://www.roblox.com/asset/?id=7288554"
Characters["T"] = "http://www.roblox.com/asset/?id=7288559"
Characters["u"] = "http://www.roblox.com/asset/?id=7288562"
Characters["U"] = "http://www.roblox.com/asset/?id=7288566"
Characters["v"] = "http://www.roblox.com/asset/?id=7288570"
Characters["V"] = "http://www.roblox.com/asset/?id=7288574"
Characters["W"] = "http://www.roblox.com/asset/?id=7288576"
Characters["w"] = "http://www.roblox.com/asset/?id=7288584"
Characters["x"] = "http://www.roblox.com/asset/?id=7288598"
Characters["X"] = "http://www.roblox.com/asset/?id=7288600"
Characters["y"] = "http://www.roblox.com/asset/?id=7288606"
Characters["Y"] = "http://www.roblox.com/asset/?id=7288611"
Characters["z"] = "http://www.roblox.com/asset/?id=7288618"
Characters["Z"] = "http://www.roblox.com/asset/?id=7288621"
Characters[" "] = ""
</pre>


==Creating the function==
==Creating the function==
Line 127: Line 31:
TextImage("Hello World!")
TextImage("Hello World!")
</pre>
</pre>
==Results==
[[Image:RobloxScreenShot07092011_173535887.jpg]]
[[Category: Scripting Tutorials]]

Latest revision as of 05:39, 16 April 2012

Warning: This tutorial does not turn a string into a decal. It creates bricks with decals of letters on.

Introduction

Converting a String to an Image is where let's say I have the string "Hello World!". Converting this to an image would be making a brick for each letter and placing a decal on it with the letter. Were going to do this by using a function to make it easier, not having to do it manually. This can be used for many features in a game, like a Player's Sign on their house or etc.

Image Table

First off, you will need a table of images for each character. You can make your own or use someone elses. I will be using one provided by xXLegoXx.

Heres the link to the Table : Here

Creating the function

function TextImage(Text)
   for i=1,string.len(Text) do -- string.lens returns the number of characters in "Text". We need to sort through each to get the image.
      Letter = string.sub(Text,i,i) -- returns only the current letter
      Block = Instance.new("Part")-- This is where we start to make the image
      Block.Size = Vector3.new(1,1,1)
      Block.Anchored = true
      Decal = Instance.new("Decal")
      Decal.Parent = Block
      Decal.Texture = Characters[Letter] -- This gets the image of the letter in the character table.
      Block.Parent = script
      Block.Position = Block.Position + (Vector3.new(0,Block.Size.Y,0) * i)
      Block.Name = i
   end
end

Now call the function

TextImage("Hello World!")

Results