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 » Scripting Helpers
Home Search
 

Re: Comparing brick material isn't working

Previous Thread :: Next Thread 
ColdSmoke is online. ColdSmoke
Joined: 02 Jan 2012
Total Posts: 5784
21 Aug 2013 03:14 PM
In this dynamic fire I'm trying to create, things have a different chance of catching fire depending on their material, and In order to make this efficient I put material names and catch chances in tables and instead of having 9 ifs I have

local ML = {"Concrete","CorrodedMetal","DiamondPlate","Foil","Grass","Ice","Plastic","Slate","Wood"}
local MLT = {9,8,6,5,0.2,1,3,10,1}
for e = 1, #ML do --SPREAD START
if obj.Material == ML[e] then
local seed = math.random(1, 2*MLT[e])
-stuff
if seed <= 1 then
--stuff
end
end
end

But I'm having an issue. There's no error output, and the script seems to think that The blocks material doesn't match any of those in the table, even though the words in table match PERFECTLY with the actual material names. I'm not sure if this is a roblox bug or what's going on, but you can experiment in this uncopylocked place:

http://www.roblox.com/--place?id=127216292

And here's the whole unedited script:
____________________________________________________________________
function mngtude (subject)
local Volume = (subject.Size.x*subject.Size.y*subject.Size.z)
local Mag = (Volume+(Volume^.5))/512
if Mag > 1 then
Mag = 1
end
return Mag
end

local multiplier = mngtude(script.Parent)*25
print(mngtude(script.Parent))
print(multiplier)

local ML = {"Concrete","CorrodedMetal","DiamondPlate","Foil","Grass","Ice","Plastic","Slate","Wood"}
local MLT = {9,8,6,5,0.2,1,3,10,1}

while wait() do
local objects = game.Workspace:FindPartsInRegion3(
Region3.new(
Vector3.new(
(script.Parent.Position.x - script.Parent.Size.x/2) - multiplier,
(script.Parent.Position.y - script.Parent.Size.y/2) - multiplier,
(script.Parent.Position.z - script.Parent.Size.z/2) - multiplier
),
Vector3.new(
(script.Parent.Position.x + script.Parent.Size.x/2) + multiplier,
(script.Parent.Position.y + script.Parent.Size.y/2) + multiplier,
(script.Parent.Position.z + script.Parent.Size.z/2) + multiplier
)
),
script.Parent, 100
)
print(unpack(objects))
for i, obj in pairs(objects) do
print(obj.Name.."yolo")
for e = 1, #ML do --SPREAD START
if obj.Material == ML[e] then
local seed = math.random(1, 2*MLT[e])
print(seed)
print(obj)
if seed <= 1 then
print("Spread")
Instance.new("Fire", obj)
Fire = script:clone()
Fire.Parent = obj
end
end
end
end
end
Report Abuse
RaceToTheBottom is not online. RaceToTheBottom
Joined: 27 Jul 2013
Total Posts: 169
21 Aug 2013 04:07 PM
[ Content Deleted ]
Report Abuse
ZachBloxx is not online. ZachBloxx
Joined: 26 Jun 2013
Total Posts: 2833
21 Aug 2013 04:09 PM
You can use a string to set a material.
Report Abuse
mic144 is not online. mic144
Joined: 14 Oct 2009
Total Posts: 1598
21 Aug 2013 04:10 PM
^
Plus, it's mostlikely a bug.
Report Abuse
RaceToTheBottom is not online. RaceToTheBottom
Joined: 27 Jul 2013
Total Posts: 169
21 Aug 2013 04:12 PM
[ Content Deleted ]
Report Abuse
mic144 is not online. mic144
Joined: 14 Oct 2009
Total Posts: 1598
21 Aug 2013 04:15 PM
Maybe. Idk. Lets just wait and see.
Report Abuse
ColdSmoke is online. ColdSmoke
Joined: 02 Jan 2012
Total Posts: 5784
21 Aug 2013 04:19 PM
Em

Enum?

I'll go to wiki then...

Lobster in disguise
Report Abuse
JoshuaKempfert is not online. JoshuaKempfert
Joined: 16 Feb 2013
Total Posts: 2407
21 Aug 2013 04:22 PM
Enums are easy..
Report Abuse
mic144 is not online. mic144
Joined: 14 Oct 2009
Total Posts: 1598
21 Aug 2013 04:30 PM
Try this!:




function mngtude (subject)
local Volume = (subject.Size.x*subject.Size.y*subject.Size.z)
local Mag = Volume/512
if Mag < 1 then
Mag = 1
end
return Mag
end

local multiplier = mngtude(script.Parent)*8

print(multiplier)

local ML = {Enum.Material.Concrete,Enum.Material.CorrodedMetal,Enum.Material.DiamondPlate,Enum.Material.Foil,Enum.Material.Grass,Enum.Material.Ice,Enum.Material.Plastic,Enum.Material.Slate,Enum.Material.Wood}
local MLT = {9,8,6,5,0.2,1,3,10,1}

while wait() do
local objects = game.Workspace:FindPartsInRegion3(
Region3.new(
Vector3.new(
(script.Parent.Position.x - script.Parent.Size.x/2) - multiplier,
(script.Parent.Position.y - script.Parent.Size.y/2) - multiplier,
(script.Parent.Position.z - script.Parent.Size.z/2) - multiplier
),
Vector3.new(
(script.Parent.Position.x + script.Parent.Size.x/2) + multiplier,
(script.Parent.Position.y + script.Parent.Size.y/2) + multiplier,
(script.Parent.Position.z + script.Parent.Size.z/2) + multiplier
)
),
script.Parent, 100
)
print(unpack(objects))
for i, obj in pairs(objects) do
for i = 1, #ML do --SPREAD START
if obj.Material == ML[i] then
local seed = math.random(1, 2*MLT[i])
if seed <= 1 then
Instance.new("Fire", obj)
Fire = script:clone()
Fire.Parent = obj
end
end
end
end
end
Report Abuse
ColdSmoke is online. ColdSmoke
Joined: 02 Jan 2012
Total Posts: 5784
21 Aug 2013 04:46 PM
Ah! Thanks a ton! it works perfectly.

Now to finish the script and control the fires c:

Lobster in disguise
Report Abuse
Notunknown99 is not online. Notunknown99
Joined: 05 Sep 2008
Total Posts: 25360
21 Aug 2013 04:46 PM
If Part.Material.Name == String then

Also, you can do

{"Material Name" == ThatNumber, "Material Name 2" == ThatNumber}
Report Abuse
mic144 is not online. mic144
Joined: 14 Oct 2009
Total Posts: 1598
21 Aug 2013 04:48 PM
Anytime ColdSmoke. c:
Report Abuse
ColdSmoke is online. ColdSmoke
Joined: 02 Jan 2012
Total Posts: 5784
21 Aug 2013 04:57 PM
So down where the script copies itself, I changed the if to this

if seed <= 1 and not obj:FindFirstChild("Fire")then
print("Spread")
Instance.new("Fire", obj)
Fire = script:clone()
Fire.Parent = obj
wait(1)
end

But it still continues even if the obj has a child named Fire
Any idea why this is?

Lobster in disguise
Report Abuse
Constructor189 is not online. Constructor189
Joined: 28 Apr 2013
Total Posts: 219
21 Aug 2013 04:58 PM
"yolo"
Report Abuse
Notunknown99 is not online. Notunknown99
Joined: 05 Sep 2008
Total Posts: 25360
21 Aug 2013 04:58 PM
@Constructor189: ""yolo""

Please implode.
Report Abuse
ZachBloxx is not online. ZachBloxx
Joined: 26 Jun 2013
Total Posts: 2833
21 Aug 2013 04:59 PM
Or explode.
Report Abuse
mic144 is not online. mic144
Joined: 14 Oct 2009
Total Posts: 1598
21 Aug 2013 05:01 PM
if (seed <= 1) and (obj:FindFirstChild("Fire") ~= nil) then
print("Spread")
Instance.new("Fire", obj)
Fire = script:clone()
Fire.Parent = obj
wait(1)
end
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • 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