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: Semi-complicated script

Previous Thread :: Next Thread 
Woodstauk4 is not online. Woodstauk4
Joined: 27 Dec 2010
Total Posts: 3061
29 Dec 2012 10:57 PM
Well, here I am again with this compiler script. Most of you probably ignored the 20 or so threads I previously made about this :L

Anyway, a new problem has arisen, and I have absolutely no idea as to why it has or how to fix it.

In two lines, I changed a bit of string manipulation (thanks to kingkiller1000:) ), but sadly now, I get an error message saying 'string expected'. That's it. I can't actually test the output for the function itself causes hundreds of errors when testing for properties and gets the errors I need discarded... hehe...

The script DID work before this change, and I am positive these are the only changes made to the script since!

Two lines were changed in total, I'll show the changes here.

compilation=compilation.." local o"..tostring(num).."=Instance.new(\""..obj.ClassName.."\","..obj.Parent:GetFullName()..")"

was changed to

compilation=compilation.." local o"..tostring(num).."=Instance.new(\""..obj.ClassName.."\",game"..obj.Parent:GetFullName():gsub("[^%.]+", "[\"%1\"]"):gsub("%.", "")..")"


and


endcomp=endcomp.." o"..tostring(num).."."..ObjectProperties[i].."="..obj[ObjectProperties[i]]:GetFullName()

was changed to

endcomp=endcomp.." o"..tostring(num).."."..ObjectProperties[i].."=game"..obj[ObjectProperties[i]]:GetFullName():gsub("[^%.]+", "[\"%1\"]"):gsub("%.", "")



:GetFullName():gsub("[^%.]+", "[\"%1\"]"):gsub("%.", "") alone performed on an object has no errors, and does return a string value!


(Thanks for the help in advance)


I truly don't understand what is happening here... and I know people are going to be all "Gimmeh teh whole scropt11"

Well, I'll post it. Shield your eyes.





_G.Compile=function(object)
ypcall(function()

-- Just tables with properties here ----------------------------------------
local TextProperties={"SoundId","MeshId","TextureId","C0","C1","MaxVelocity","ShirtTemplate","Graphic","PantsTemplate","Face","BottomSurface","TopSurface","LeftSurface","RightSurface","Part0","Part1","MeshType","Name","Value","MaxValue","MinValue","Text","Reflectance","Transparency","Heat","TeamName","Health","MaxHealth","Brightness","FogEnd","FogStart","Size","D","P","Elasticity","FormFactor","Friction","Shape","GeographicLatitude","Texture","BackgroundTransparency","Image"}
local BoolProperties={"Anchored","CanCollide","Disabled","Value","Locked","CharacterAutoLoads","Visable","Sit","Jump","PlatformStand"}
local BrickColorProperties={"BrickColor","Color","TeamColor","HeadColor","TorsoColor","LeftLegColor","LeftArmColor","RightLegColor","RightArmColor","Value"}
local Color3Properties={"Color","SecondaryColor","Ambient","ColorShift_Bottom","ColorShift_Top","ShadowColor","FogColor","Value","BorderColor3","BackgroundColor3"}
local Vector3Properties={"Size","Position","maxForce","maxTorque","position","Velocity","RotVelocity","Value"}
local ObjectProperties={"Torso","Head","RightLeg","LeftLeg","Part0","Part1"}


-- end of the tables of properties----------------------------------------------


local compilation=""
local endcomp=""
local nom=0

function compile(obj,num)
if obj.ClassName~="Status"and obj.Parent~=game and obj.Parent~=Players and obj~=game then

-- CHANGED LINE
compilation=compilation.." local o"..tostring(num).."=Instance.new(\""..obj.ClassName.."\",game"..obj.Parent:GetFullName():gsub("[^%.]+", "[\"%1\"]"):gsub("%.", "")..")"
-- CHANGED LINE

for i=1,#TextProperties do
ypcall(function()
if obj[TextProperties[i]]and obj[TextProperties[i]]~=obj:FindFirstChild(TextProperties[i])then
compilation=compilation.." o"..tostring(num).."."..TextProperties[i].."=\""..obj[TextProperties[i]].."\""
end
end)
end

for i=1,#BoolProperties do
ypcall(function()
if obj[BoolProperties[i]]and obj[BoolProperties[i]]~=obj:FindFirstChild(BoolProperties[i])then
compilation=compilation.." o"..tostring(num).."."..BoolProperties[i].."="..obj[BoolProperties[i]]
end
end)
end

for i=1,#BrickColorProperties do
ypcall(function()
if obj[BrickColorProperties[i]]and obj[BrickColorProperties[i]]~=obj:FindFirstChild(BrickColorProperties[i])then
compilation=compilation.." o"..tostring(num).."."..BrickColorProperties[i].."=BrickColor.new(\""..obj[BrickColorProperties[i]].."\")"
end
end)
end

for i=1,#Color3Properties do
ypcall(function()
if obj[Color3Properties[i]]and obj[Color3Properties[i]]~=obj:FindFirstChild(Color3Properties[i])then
compilation=compilation.." o"..tostring(num).."."..Color3Properties[i].."=Color3.new("..obj[Color3Properties[i]]..")"
end
end)
end

for i=1,#Vector3Properties do
ypcall(function()
if obj[Vector3Properties[i]]and obj[Vector3Properties[i]]~=obj:FindFirstChild(Vector3Properties[i])then
compilation=compilation.." o"..tostring(num).."."..Vector3Properties[i].."=Vector3.new("..obj[Vector3Properties[i]]..")"
end
end)
end

for i=1,#ObjectProperties do
ypcall(function()
if obj[ObjectProperties[i]]and obj[ObjectProperties[i]]~=obj:FindFirstChild(ObjectProperties[i])then

-- CHANGED LINE
endcomp=endcomp.." o"..tostring(num).."."..ObjectProperties[i].."=game"..obj[ObjectProperties[i]]:GetFullName():gsub("[^%.]+", "[\"%1\"]"):gsub("%.", "")
-- CHANGED LINE

end
end)
end

for _,v in pairs(obj:GetChildren())do
nom=nom+1
compile(v,nom)
end
end
end
compile(object,nom)
return compilation..endcomp
end)
end
Report Abuse
kungfuman32 is not online. kungfuman32
Joined: 12 Dec 2008
Total Posts: 9172
29 Dec 2012 10:58 PM
Go to scripters.
Report Abuse
Woodstauk4 is not online. Woodstauk4
Joined: 27 Dec 2010
Total Posts: 3061
29 Dec 2012 11:03 PM
I'm requesting for help. This is the correct forum.
Report Abuse
kingkiller1000 is not online. kingkiller1000
Joined: 12 Dec 2008
Total Posts: 26415
29 Dec 2012 11:07 PM
Did you get a line number?
Report Abuse
Woodstauk4 is not online. Woodstauk4
Joined: 27 Dec 2010
Total Posts: 3061
29 Dec 2012 11:08 PM
No, the error was given by another script calling the function. If I call the function from within that script, the error message gets discarded.
Report Abuse
Woodstauk4 is not online. Woodstauk4
Joined: 27 Dec 2010
Total Posts: 3061
29 Dec 2012 11:12 PM
Nevermind.

I deleted most of the properties temporarily (none that would affect the function being called in this instance)

Still, there was no error except

00:11:21 - String expected
00:11:21 - Script "Workspace.Script", Line 67
00:11:21 - stack end

Line 67(Just one line more than the posted script, calling the function):
Workspace.Message.Text=_G.Compile(Workspace.Message)
Report Abuse
Woodstauk4 is not online. Woodstauk4
Joined: 27 Dec 2010
Total Posts: 3061
30 Dec 2012 10:54 AM
Bump.
Report Abuse
Woodstauk4 is not online. Woodstauk4
Joined: 27 Dec 2010
Total Posts: 3061
30 Dec 2012 12:17 PM
Anyone have an ideas? :l
Report Abuse
Woodstauk4 is not online. Woodstauk4
Joined: 27 Dec 2010
Total Posts: 3061
30 Dec 2012 01:59 PM
Bump T_T
Report Abuse
Woodstauk4 is not online. Woodstauk4
Joined: 27 Dec 2010
Total Posts: 3061
31 Dec 2012 01:24 PM
Bump... >_>
Report Abuse
doombringer42 is not online. doombringer42
Joined: 13 Nov 2007
Total Posts: 5445
31 Dec 2012 01:28 PM
when indexing an instance, the index must be a string.

that's what i can get from that error. you tried to index an instance by a non-string object.

¬ LuaLearners Elite/Writer
Report Abuse
Woodstauk4 is not online. Woodstauk4
Joined: 27 Dec 2010
Total Posts: 3061
31 Dec 2012 01:33 PM
The index is a string.

each starts off like this:


" local o"..tostring(num).."=Instance.new(\""classname",game["Serviice"]["Object"]["Parent"]"\")" etc

the ## is always changing, as in the compile function one of the parameters is 'num'. num changes after each object has been compiled into a string, so it starts off with the first object being o0, then o1, then o2, then o3, etc. It does stay a string :/
Report Abuse
Woodstauk4 is not online. Woodstauk4
Joined: 27 Dec 2010
Total Posts: 3061
31 Dec 2012 01:34 PM
and I made sure to put a space before each time I index a new string/make a line to change properties so that can't be the problem, either, incase anyone thinks that in the future.
Report Abuse
doombringer42 is not online. doombringer42
Joined: 13 Nov 2007
Total Posts: 5445
31 Dec 2012 01:36 PM
well i don't know then. all i can tell you is to check again. i don't have the patience to sift through your entire script :\

¬ LuaLearners Elite/Writer
Report Abuse
C0D3Y is not online. C0D3Y
Joined: 24 Jul 2010
Total Posts: 1692
31 Dec 2012 01:44 PM
What is " local o"..tostring(num).."=Instance.new(\""classname",game["Serviice"]["Object"]["Parent"]"\")" supposed to be? Can you show me what it would print out if you just put it in a print()? I think I can help, but I'm not exactly sure where each part ends.
Report Abuse
Woodstauk4 is not online. Woodstauk4
Joined: 27 Dec 2010
Total Posts: 3061
31 Dec 2012 01:54 PM
print(_G.Compile(Workspace.Message))

would be

local o0=Instance.new("Message",game["Workspace"]) o0.Name="Message" o0.Text=""


I just did a test when I got rid of all but 1 property from each table, and it worked when I called it... I wonder if one of the properties is the reason why it breaks? I don't understand why, they're all in ypcalls... could it be the sheer number of errors it causes?

But even so, why would that cause the function not to return a string? So confused :l
Report Abuse
C0D3Y is not online. C0D3Y
Joined: 24 Jul 2010
Total Posts: 1692
31 Dec 2012 02:00 PM
" local o"..tostring(num).."=Instance.new(\"--Ends the text

"classname",game["Serviice"]["Object"]["Parent"]"\")"--Breaks it

You can't have TextLabel.Text = "Test1""Test2" It will do nothing. That's your problem. You _can_ however, have TextLabel.Text = ' "Test1""Test2" ' which will not error. Hope that helps a bit.
Report Abuse
Woodstauk4 is not online. Woodstauk4
Joined: 27 Dec 2010
Total Posts: 3061
31 Dec 2012 02:03 PM
Nevermind. I got it to work, I just added a few lines to get rid of the error messages before printing the compiled object


wait(1)
for i=1,500 do print(" ")end
wait(1)
print(compilation..endcomp)

and it worked. Mostly.

The only problem is that all the objects created are in the exact same position, so when I compiled my character, my head, hats, legs, and arms are all inside my torso. I wonder how I can fix that...
Report Abuse
Woodstauk4 is not online. Woodstauk4
Joined: 27 Dec 2010
Total Posts: 3061
31 Dec 2012 02:04 PM
@c0dy
the \ operator exempts a character from execution but keeps it as a string, so the first " there would not end the string, but when printed an actual quote would still come out. But thanks anyway
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