generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: string patterns

Previous Thread :: Next Thread 
PlaceEveryBlock is not online. PlaceEveryBlock
Joined: 27 Nov 2011
Total Posts: 62
21 Aug 2015 10:01 AM
I'm just learning string patterns so idk if this is right in any way. Script:

local code = script.code
script.code.Changed:connect(function()
print"processingCode"

for w in string.gmatch(code.Value, "%w+") do
print(w)
if w == "q" or w == "%d" then
local sound = Instance.new("Sound", game.Workspace)
sound.SoundId = "http://www.roblox.com/asset/?id=152715799"
sound.Volume = 15
sound:Play()
end

if w =="%d" then
print"************************************"
wait(w * .1)
end


end
end)

Example of a code:0 q 21 q 11 q 11 q 20 q 4 q

Output:
processingCode
0
q
21
q
11
q
11
q
20
q
4
q

I just need this to play the sound when it goes over a q, then wait the time * 0.1. Any tips?


Report Abuse
PlaceEveryBlock is not online. PlaceEveryBlock
Joined: 27 Nov 2011
Total Posts: 62
21 Aug 2015 10:02 AM
doesn't print the asterisks
Report Abuse
phoenix53124 is not online. phoenix53124
Joined: 25 Feb 2009
Total Posts: 4889
21 Aug 2015 10:18 AM
Um...what's with the "if w=="%d" then"?

_s = "This is a string. 5"

for pattern_match in string.gmatch(_s,"%d+") do
print(pattern_match)
end

-->5
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image