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: Making a method

Previous Thread :: Next Thread 
ichigokurosakih is not online. ichigokurosakih
Joined: 11 Jun 2010
Total Posts: 409
18 Jun 2014 06:29 PM
Is it possible to create our own methods that work on a certain instance?

Like :GetMass()

function part:GetMass()

end

Something like that.
Report Abuse
Jason27993 is not online. Jason27993
Joined: 25 Sep 2010
Total Posts: 345
18 Jun 2014 06:31 PM
i think its possible, but y u no use a function like

function changetransparency(part,transparency)
if part and transparency then
part.Transparency=transparency
else
print("SCRIPT ERROR: Part or Transparency not defined!")
end
end
Report Abuse
ichigokurosakih is not online. ichigokurosakih
Joined: 11 Jun 2010
Total Posts: 409
18 Jun 2014 09:29 PM
I don't know, I just feel like creating a method xd.
Report Abuse
ichigokurosakih is not online. ichigokurosakih
Joined: 11 Jun 2010
Total Posts: 409
18 Jun 2014 09:45 PM
D: <-
Report Abuse
thedestroyer115 is not online. thedestroyer115
Joined: 19 Dec 2010
Total Posts: 11546
18 Jun 2014 10:04 PM
This is possible, but you're going to need to use some pretty haxy custom environments.

Why do you want to do this?
Report Abuse
ichigokurosakih is not online. ichigokurosakih
Joined: 11 Jun 2010
Total Posts: 409
18 Jun 2014 10:17 PM
Like I said, I just want to know :U.
There's no actual reasons;
Report Abuse
ichigokurosakih is not online. ichigokurosakih
Joined: 11 Jun 2010
Total Posts: 409
18 Jun 2014 11:12 PM
:U
Report Abuse
ichigokurosakih is not online. ichigokurosakih
Joined: 11 Jun 2010
Total Posts: 409
19 Jun 2014 03:42 AM
ForumPost:ThrowSpell("Bump")
Report Abuse
ichigokurosakih is not online. ichigokurosakih
Joined: 11 Jun 2010
Total Posts: 409
19 Jun 2014 06:32 AM
zzz
Report Abuse
TheLuaUser is not online. TheLuaUser
Joined: 22 May 2012
Total Posts: 1405
19 Jun 2014 06:48 AM
Website.Forum["Scripting Helpers"]["Making a method"]:Bump()
Report Abuse
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
19 Jun 2014 06:48 AM
I can't make it for an instance, but I can provide an example, one sec.
Report Abuse
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
19 Jun 2014 06:59 AM
This is a snippet from my car simulator that I wrote in standard Lua.

Location = {GetLocalCar = {
Gas = function()
print("Car moving!")
end,
Brake = function()
print("Car stopped!")
end,
Reverse = function()
print("Car moving backwards...")
end
}
}

function Gas()
Location.GetLocalCar:Gas()
end

function Brake()
Location.GetLocalCar:Brake()
end

function Reverse()
Location.GetLocalCar:Reverse()
end

local speed = 0
Report Abuse
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
19 Jun 2014 08:17 AM
Did my example help?
Report Abuse
DhatBoiiPapi is not online. DhatBoiiPapi
Joined: 27 May 2013
Total Posts: 701
19 Jun 2014 08:46 AM
@OP, it is very possible.

But you need to use a ModuleScript and use some haxy lua to operate it properly.
Report Abuse
einsteinK is not online. einsteinK
Joined: 22 May 2011
Total Posts: 1015
19 Jun 2014 08:54 AM
dhatboiipapi means (I guess) you need to use a sandbox
Report Abuse
DhatBoiiPapi is not online. DhatBoiiPapi
Joined: 27 May 2013
Total Posts: 701
19 Jun 2014 09:17 AM
well i mean the modulescripts is kinda like a way to declare custom functions as such

http://wiki.roblox.com/index.php?title=Module_scripts

this clear things up
Report Abuse
secretidagent is not online. secretidagent
Joined: 07 Nov 2010
Total Posts: 1600
19 Jun 2014 09:58 AM
You can always do a function like this:

function math.add(x,y)
if x ~= nil and y ~= nil then --this is just an example
return x+y
end
end

print(math.add(4,3)) -- 7
Report Abuse
thedestroyer115 is not online. thedestroyer115
Joined: 19 Dec 2010
Total Posts: 11546
19 Jun 2014 01:46 PM
@warspyking
You are simply running functions that are members of a table. He wants to run methods for an instance.
Report Abuse
DhatBoiiPapi is not online. DhatBoiiPapi
Joined: 27 May 2013
Total Posts: 701
19 Jun 2014 02:07 PM
As again.
Look at the process of ModuleScript
Report Abuse
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
19 Jun 2014 03:18 PM
Location = {GetLocalCar = {
Gas = function()
print("Car moving!")
end,
Brake = function()
print("Car stopped!")
end,
Reverse = function()
print("Car moving backwards...")
end
}
}

function Gas()
Location.GetLocalCar:Gas()
end

function Brake()
Location.GetLocalCar:Brake()
end

function Reverse()
Location.GetLocalCar:Reverse()
end

local speed = 0




That's what a method is! -_-
Report Abuse
thedestroyer115 is not online. thedestroyer115
Joined: 19 Dec 2010
Total Posts: 11546
19 Jun 2014 03:20 PM
I am simply telling you that what you are doing is not the desired result he wants.

I am not arguing that functions in tables are not methods.
Report Abuse
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
19 Jun 2014 03:22 PM
I don't really see how he would be able to do this though. But what I did is nessecary to create methods.
Report Abuse
thedestroyer115 is not online. thedestroyer115
Joined: 19 Dec 2010
Total Posts: 11546
19 Jun 2014 03:23 PM
Haxy methods with environments.

That's how!
Report Abuse
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
19 Jun 2014 03:30 PM
If you think It's so easy, show me :P
Report Abuse
thedestroyer115 is not online. thedestroyer115
Joined: 19 Dec 2010
Total Posts: 11546
19 Jun 2014 03:32 PM
Did I say it was easy?

:|
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