iLiminate
|
  |
| Joined: 26 Feb 2012 |
| Total Posts: 388 |
|
|
| 06 Jan 2014 03:00 PM |
_G["top"] = function(part,type) -- Format is (type = {color,material}) types = {snow,grass,grassedge,sand,dirt,water} snow = {"White","Sand"} grass = {"Camo"--[[A very nice green]],"Grass"} grassedge = {"Olive", "Grass"} -- for areas with holes sand = {"Cool yellow","Sand"} dirt = {"Reddish brown","Slate"} water = {"Deep blue","Smooth Plastic"} top = Instance.new("Part",game.Workspace) top.Anchored = true top.Size = Vector3.new(part.Size.X - 0.1,0.2,part.Size.Z -0.1) top.CFrame = part.CFrame + Vector3.new(0,top.Size.Y/2 + part.Size.Y/2 -0.19,0) top.TopSurface = "Smooth" top.BottomSurface = "Smooth" top.BrickColor = BrickColor.types[type][1] top.Material = types[type[2]] end So what the script does it it takes a block(part) and it adds a block the same dimensions on top of it and colors and adds material to it. However I cannot get the table to spit out a value. I get this from output: 14:55:32.205 - Workspace.Script:20: attempt to index field 'types' (a nil value) 14:55:32.206 - Script 'Workspace.Script', Line 20 - field top 14:55:32.206 - Script 'Workspace.Script', Line 23 14:55:32.206 - stack end |
|
|
| Report Abuse |
|
|
Azarth
|
  |
| Joined: 17 Aug 2012 |
| Total Posts: 2760 |
|
|
| 06 Jan 2014 03:02 PM |
| Make them strings and spell them correctly. |
|
|
| Report Abuse |
|
|
hachibey
|
  |
| Joined: 09 Jun 2007 |
| Total Posts: 518 |
|
|
| 06 Jan 2014 03:05 PM |
| Thats not the problem. Look at lines 19 and 20 and tell me what the problem is. |
|
|
| Report Abuse |
|
|
iLiminate
|
  |
| Joined: 26 Feb 2012 |
| Total Posts: 388 |
|
|
| 06 Jan 2014 03:09 PM |
Lines 19 and 20 are: top.BottomSurface = "Smooth" top.BrickColor = BrickColor.types[type][1]
P.S. I tried BrickColor.types[type[1]] too and it didnt work. I have no clue how to initialize the values from inside one table to another, do i have to use metatable? |
|
|
| Report Abuse |
|
|
Azarth
|
  |
| Joined: 17 Aug 2012 |
| Total Posts: 2760 |
|
|
| 06 Jan 2014 03:12 PM |
| There is no BrickColor.Types, only BrickColor.new and BrickColor.random(). |
|
|
| Report Abuse |
|
|
iLiminate
|
  |
| Joined: 26 Feb 2012 |
| Total Posts: 388 |
|
|
| 06 Jan 2014 03:44 PM |
Well, yes but I thought i could do like, BrickColor.White except with BrickColor.types because types[type[1]] = White |
|
|
| Report Abuse |
|
|
crouton04
|
  |
| Joined: 07 Jul 2010 |
| Total Posts: 4459 |
|
|
| 06 Jan 2014 04:11 PM |
Lol
BrickColor = { type = {White = "White"} }
part.BrickColor = BrickColor.type.White |
|
|
| Report Abuse |
|
|
smiley599
|
  |
| Joined: 23 Jan 2010 |
| Total Posts: 21869 |
|
|
| 06 Jan 2014 04:21 PM |
| The 'types' table should be after the other tables I think. |
|
|
| Report Abuse |
|
|
iLiminate
|
  |
| Joined: 26 Feb 2012 |
| Total Posts: 388 |
|
| |
|
iLiminate
|
  |
| Joined: 26 Feb 2012 |
| Total Posts: 388 |
|
| |
|
crouton04
|
  |
| Joined: 07 Jul 2010 |
| Total Posts: 4459 |
|
|
| 07 Jan 2014 02:15 PM |
More of a shortcut is:
BrickColor = {White = BrickColor.new("White");Red = BrickColor.new("Bright red");Blue = BrickColor.new("Navy blue")}
part = Instance.new("Part",Workspace)
part.BrickColor = BrickColor.White |
|
|
| Report Abuse |
|
|
iLiminate
|
  |
| Joined: 26 Feb 2012 |
| Total Posts: 388 |
|
|
| 07 Jan 2014 04:23 PM |
Instead of doing the whole table thing, I just decided to do a if else statement about 1 million* lines long. -*Not actually a million-
-=No, I don't hack=- ~The Hacker~ [iLiminate] |
|
|
| Report Abuse |
|
|
Bebee2
|
  |
| Joined: 17 May 2009 |
| Total Posts: 3985 |
|
|
| 07 Jan 2014 04:26 PM |
_G["top"] = function(self,part,type) -- Format is (type = {color,material}) types = {snow,grass,grassedge,sand,dirt,water} snow = {"White","Sand"} grass = {"Camo"--[[A very nice green]],"Grass"} grassedge = {"Olive", "Grass"} -- for areas with holes sand = {"Cool yellow","Sand"} dirt = {"Reddish brown","Slate"} water = {"Deep blue","Smooth Plastic"}
top = Instance.new("Part",game.Workspace) top.Anchored = true top.Size = Vector3.new(part.Size.X - 0.1,0.2,part.Size.Z -0.1) top.CFrame = part.CFrame + Vector3.new(0,top.Size.Y/2 + part.Size.Y/2 -0.19,0) top.TopSurface = "Smooth" top.BottomSurface = "Smooth" top.BrickColor = BrickColor.types[type][1] top.Material = types[type[2]] end
What you did wrong is that you forgot "to add the first parameter" that is premade when you make parameters in a function inside a table. A method returns the table it is in as the first argument, which you forgot. |
|
|
| Report Abuse |
|
|
crouton04
|
  |
| Joined: 07 Jul 2010 |
| Total Posts: 4459 |
|
|
| 07 Jan 2014 04:35 PM |
| Thats way more complicated, I'd stick to the easy simple table. |
|
|
| Report Abuse |
|
|
iLiminate
|
  |
| Joined: 26 Feb 2012 |
| Total Posts: 388 |
|
|
| 07 Jan 2014 04:41 PM |
@bebee so _G["top"] = function(part,type) -- Format is (type = {color,material}) types = {snow,grass,grassedge,sand,dirt,water} snow = {"White","Sand"} grass = {"Camo"--[[A very nice green]],"Grass"} grassedge = {"Olive", "Grass"} -- for areas with holes sand = {"Cool yellow","Sand"} dirt = {"Reddish brown","Slate"} water = {"Deep blue","Smooth Plastic"}
top = Instance.new("Part",game.Workspace) top.Anchored = true top.Size = Vector3.new(part.Size.X - 0.1,0.2,part.Size.Z -0.1) top.CFrame = part.CFrame + Vector3.new(0,top.Size.Y/2 + part.Size.Y/2 -0.19,0) top.TopSurface = "Smooth" top.BottomSurface = "Smooth" top.BrickColor = BrickColor.types[type[2]] top.Material = types[type[3]] end
that?
-=No, I don't hack=- ~The Hacker~ [iLiminate] |
|
|
| Report Abuse |
|
|
Bebee2
|
  |
| Joined: 17 May 2009 |
| Total Posts: 3985 |
|
|
| 07 Jan 2014 04:47 PM |
No.
Just compare the first line of your script to mine. |
|
|
| Report Abuse |
|
|
iLiminate
|
  |
| Joined: 26 Feb 2012 |
| Total Posts: 388 |
|
|
| 07 Jan 2014 04:50 PM |
Ok, thanks, I see it now.
-=No, I don't hack=- ~The Hacker~ [iLiminate] |
|
|
| Report Abuse |
|
|