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: ooo im starting to understand! :D

Previous Thread :: Next Thread 
nickcool9999 is not online. nickcool9999
Joined: 04 Dec 2007
Total Posts: 1528
23 Apr 2016 03:48 AM
yep yep, tables are just memory addresses within your script. I knew it.

class1 = {name = "class1"}
class2 = {name = "class2"}

require(script.IModuleInterface)(class1)
require(script.IModuleInterface)(class2)

class1.onInit()

wait(5)

class2.onClick()

So you can just set up a ton of modules to override and overwrite function addresses.

I didnt even know that till now, super cool. makes modding a ton easier.
Report Abuse
Flux_Capacitor is not online. Flux_Capacitor
Joined: 07 Apr 2008
Total Posts: 45720
23 Apr 2016 03:51 AM
You're 'understanding' is pretty flawed. A table is not "a memory address" and you can't "override/overwrite function addresses" (that makes no sense too).
Report Abuse
Cuyler is not online. Cuyler
Joined: 27 Feb 2006
Total Posts: 3784
23 Apr 2016 03:55 AM
When you say memory addresses, I assume you mean the values you get by printing a table/function (without calling it). These are the memory addresses where the table/function are stored. You can't 'override function addresses' since they're just a pointer to where that function is stored in memory.


Report Abuse
nickcool9999 is not online. nickcool9999
Joined: 04 Dec 2007
Total Posts: 1528
23 Apr 2016 03:55 AM
I didn't explain it very well, but a table is a data structure.

What I meant to say is the variable used to store it actually just stores the address of it at which all the functions do the manipulations.

What i meant by override/overwrite is this:

}}}}}}}}}}}}1 modulescript sets the defaults:

return function(namespace)
-- @abstract IInterfaceBig

print(namespace.name.. " editting.")

namespace.onInit = function()
print("Unset")
end

namespace.onClick = function()
print("Unset")
end
end

}}}}}}}}}}}}}}the other modulescript gets that abstract code and realocates the function to its own scope. Whenever onInit will be called, this module will be referred to for the function scope instead and that opens up so many doors :D.

return function(namespace)

require(script.Parent.IInterfaceBig)(namespace)

namespace.onInit = function()
print("Declared!")
end

end
Report Abuse
Flux_Capacitor is not online. Flux_Capacitor
Joined: 07 Apr 2008
Total Posts: 45720
23 Apr 2016 03:57 AM
The magic of closures. The way you try to explain things is really misleading bud
Report Abuse
nickcool9999 is not online. nickcool9999
Joined: 04 Dec 2007
Total Posts: 1528
23 Apr 2016 04:00 AM
I wasn't wrong, I was just vague about it at first.

I was assuming you guys didnt want the modulescripts.
Report Abuse
Flux_Capacitor is not online. Flux_Capacitor
Joined: 07 Apr 2008
Total Posts: 45720
23 Apr 2016 04:01 AM
you were wrong because your terminology is wrong. but that's just me being pedantic apparently.
Report Abuse
Cuyler is not online. Cuyler
Joined: 27 Feb 2006
Total Posts: 3784
23 Apr 2016 04:03 AM
You can also get the fenv from the module script from any script that requires it:

ModuleScript:
local test = {}

test.testFunction = function(env)
return getfenv(env or 1)
end

return test

Script:
local ms = game:GetService('ReplicatedStorage'):WaitForChild('ModuleScript')
local test = require(ms)
local localEnv = test.testFunction(0)
local moduleEnv = test.testFunction(1)

for i, v in pairs(localEnv) do
print(i, v)
end

for i, v in pairs(moduleEnv) do
print(i, v)
end

Output:
script Script
script ModuleScript



Report Abuse
nickcool9999 is not online. nickcool9999
Joined: 04 Dec 2007
Total Posts: 1528
23 Apr 2016 04:04 AM
ok fine you can't "overwrite" function addresses. but you can override them :)

the variable used to access them can be manipulated into pointing to other scopes.
Report Abuse
Flux_Capacitor is not online. Flux_Capacitor
Joined: 07 Apr 2008
Total Posts: 45720
23 Apr 2016 04:05 AM
They're not called scopes either lol
Report Abuse
Cuyler is not online. Cuyler
Joined: 27 Feb 2006
Total Posts: 3784
23 Apr 2016 04:06 AM
The original scope and it's functions/tables can always be found. You're not 'overriding' them rather than creating an entirely new function cloned from the function in the original scope.


Report Abuse
nickcool9999 is not online. nickcool9999
Joined: 04 Dec 2007
Total Posts: 1528
23 Apr 2016 04:08 AM
"In computer programming, the scope of a name binding – an association of a name to an entity, such as a variable – is the part of a computer program where the binding is valid: where the name can be used to refer to the entity."

It is a scope... >.>
Report Abuse
Flux_Capacitor is not online. Flux_Capacitor
Joined: 07 Apr 2008
Total Posts: 45720
23 Apr 2016 04:09 AM
"is the part of a computer program where the binding is valid"
Exactly. You don't "point to other scopes" lmao.
Report Abuse
Cuyler is not online. Cuyler
Joined: 27 Feb 2006
Total Posts: 3784
23 Apr 2016 04:09 AM
What you're referring to in lua is an environment. Scopes can be created per script, but not across scripts.

http://www.lua.org/pil/14.3.html


Report Abuse
nickcool9999 is not online. nickcool9999
Joined: 04 Dec 2007
Total Posts: 1528
23 Apr 2016 04:10 AM
wait. cloned from the function in the original scope? ok thats confusing.

no. new functions are created on the spot and the table then points to that function....

saying function() end isnt a clone of any other function you've declared it's a new address with the commands ya've put in it.

ugh my brain. XD
Report Abuse
Flux_Capacitor is not online. Flux_Capacitor
Joined: 07 Apr 2008
Total Posts: 45720
23 Apr 2016 04:14 AM
Here, I explained a lot of this here a long time ago:

docs.google dot com/document/d/1A1SBjRqFKFxaw7_RnsI96CKzBCcAOkuDPOTG8DIZywA
Report Abuse
Cuyler is not online. Cuyler
Joined: 27 Feb 2006
Total Posts: 3784
23 Apr 2016 04:20 AM
"}}}}}}}}}}}}}}the other modulescript gets that abstract code and realocates the function to its own scope. Whenever onInit will be called, this module will be referred to for the function scope instead and that opens up so many doors :D."

Specifically: "realocates the function to its own scope."

The function isn't 'reallocated', it's literally the function at the original address is just passed directly to the script requiring it.

If you mean where you return a new function then yes, it's a new environment, but it doesn't reallocate the function. It just passes the original function inside a new function.


Report Abuse
nickcool9999 is not online. nickcool9999
Joined: 04 Dec 2007
Total Posts: 1528
23 Apr 2016 04:22 AM
cool yeah, but scope is a very general word.

function a(x)
local r
end

creates a scope from within the a function to which the r variable can only be accessed in.
in the case of that specific variable declaration the setting of r after that point would not be perpetuated to any lines before it. :D

it's just what i've noted, so the r (which is set after like "r=5" cant be used at any point before that within the function.

The environment is at which all the scopes are placed. yeah.

but i wasnt talking about the environment at which the functions were placed, i was talking about the variable space at which you can manipulate it...

a lot of miscommunications today.

Even in your document you state very clearly "Local variables are variables that only exist within its block, which is its scope."

so if you do this


do
local angry = 1
end

you cant print angry after the block is over. you cant print angry anywhere outside of this block or even before that line at which it is stated.
Report Abuse
Flux_Capacitor is not online. Flux_Capacitor
Joined: 07 Apr 2008
Total Posts: 45720
23 Apr 2016 04:25 AM
I'm not arguing with you about what scope is/is not, I'm telling you the terminology you are using is wrong.

"The environment is at which all the scopes are placed. yeah."
See, this here is wrong.

"but i wasnt talking about the environment at which the functions were placed, i was talking about the variable space at which you can manipulate it..."
Doesn't make sense.
Report Abuse
nickcool9999 is not online. nickcool9999
Joined: 04 Dec 2007
Total Posts: 1528
23 Apr 2016 04:26 AM
(and yes I am doing this post just to get extra information you guys from you ;>)

My notes are very well versed once recited and pracitced.
Report Abuse
nickcool9999 is not online. nickcool9999
Joined: 04 Dec 2007
Total Posts: 1528
23 Apr 2016 04:29 AM
""The environment is at which all the scopes are placed. yeah."
See, this here is wrong."

explain!

scope is general. it means you access variables within a space. is that not what you wrote? if that isnt what you mean you should correct it...
Report Abuse
Flux_Capacitor is not online. Flux_Capacitor
Joined: 07 Apr 2008
Total Posts: 45720
23 Apr 2016 04:35 AM
I explained it in that document...

An environment is just a Lua table of all the globals for some function.
A scope is just the life time of a variable...
Report Abuse
nickcool9999 is not online. nickcool9999
Joined: 04 Dec 2007
Total Posts: 1528
23 Apr 2016 04:37 AM
Yeah... that was the whole point of the abstraction and (VIRTUAL) overriding.

to emulate constructors.

I dont see the issue here.
Report Abuse
WolfgangVonPrinz is not online. WolfgangVonPrinz
Joined: 24 Oct 2013
Total Posts: 4656
23 Apr 2016 04:40 AM
Wasn't sure what you were referring to when you said "Environment" so I looked it up and after a fair bit of looking (Like 2 minutes :P), I got this: Definition of: runtime environment. runtime environment. A configuration of hardware and software. It includes the CPU type, operating system and any runtime engines or system software required by a particular category of applications.

You're using terms you don't really understand.


Scope is about the accessibility of 'visibility' of variables in your program.
Report Abuse
nickcool9999 is not online. nickcool9999
Joined: 04 Dec 2007
Total Posts: 1528
23 Apr 2016 04:44 AM
.......

I know I don't fully understand it but you guys keep contradicting your own information and being too vague about it. "You're wrong" "It doesnt make sense" you need to elaborate when making statements like that.

Whatever, I'm not getting anywhere with this.
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