|
| 09 Feb 2012 07:21 PM |
I'm creating some stuff, but forgot how to Edit a script with a script. Would I need to do something like..
__G.Txt = "print("HAI")" lsc = script.LocalScript:clone() lsc.Parent = game.Workspace lsc.Disabled = false
And In The LocalScript...
loadstring(__G.Txt)()
??? I have no idea XD I just went out on a limb.
`*\~-{ Are we there yet T.T? }-~/*` |
|
|
| Report Abuse |
|
|
miz656
|
  |
| Joined: 19 Jul 2010 |
| Total Posts: 15336 |
|
| |
|
|
| 09 Feb 2012 07:28 PM |
Thats all that I got wrong... So it would work?
`*\~-{ Are we there yet T.T? }-~/*` |
|
|
| Report Abuse |
|
|
miz656
|
  |
| Joined: 19 Jul 2010 |
| Total Posts: 15336 |
|
|
| 09 Feb 2012 07:47 PM |
I would use _G for a table. Example
_G.table = {"HAI"}
--code
Other script
print(_G.table[1]) |
|
|
| Report Abuse |
|
|
aboy5643
|
  |
| Joined: 08 Oct 2010 |
| Total Posts: 5458 |
|
|
| 09 Feb 2012 07:58 PM |
"And In The LocalScript..."
There's your issue. _G cannot be accessed from local scripts. Sorry :) Consider using value objects? |
|
|
| Report Abuse |
|
|
miz656
|
  |
| Joined: 19 Jul 2010 |
| Total Posts: 15336 |
|
|
| 09 Feb 2012 08:02 PM |
@aboy
Really? Because I remember testing something in Billilands about that and it printed in the localscript....Hmm...Must be a glitch in Billilands. |
|
|
| Report Abuse |
|
|
aboy5643
|
  |
| Joined: 08 Oct 2010 |
| Total Posts: 5458 |
|
|
| 09 Feb 2012 08:04 PM |
@miz
._____. I hate how you act like you know everything, tell people what you think you know, and then are horribly incorrect.
_G IS a table. It's environment has a scope of ALL regular scripts. For his purpose he CAN do _G["something"] = function(arg) print(arg) end if he wants. You can put anything in there just like any variable. Yes, you can do a table, but that's more costly in memory (and performance as the machine has to look in a table in a table for a value) Please don't say anything unless you are ACTUALLY correct. |
|
|
| Report Abuse |
|
|
miz656
|
  |
| Joined: 19 Jul 2010 |
| Total Posts: 15336 |
|
|
| 09 Feb 2012 08:08 PM |
__G.Txt = "print("HAI")"
From the fact he wants to do something like this I would use a table...Just saying...
Though, I'm not gonna argue with you because you're that kinda guy who whilps peoples heads off. You're like a polish mexican sumbrero, except you actually have salsa. |
|
|
| Report Abuse |
|
|
aboy5643
|
  |
| Joined: 08 Oct 2010 |
| Total Posts: 5458 |
|
|
| 09 Feb 2012 08:13 PM |
>Obvious 8 year old
Moving on... __G.Txt -- One too many underscores; there's only one underscore in the global table
"print("HAI")" --ummm... lots
So he should use:
_G.Txt = function() --[[You need to execute it so you need a function to call]] print("HAI") --[[What he wanted]] end --close dah function
_G.Txt()
>HAI |
|
|
| Report Abuse |
|
|
|
| 09 Feb 2012 08:18 PM |
"_G.Txt()"
_G:Txt()
'Cause the colon makes it look cool |
|
|
| Report Abuse |
|
|
aboy5643
|
  |
| Joined: 08 Oct 2010 |
| Total Posts: 5458 |
|
|
| 09 Feb 2012 08:24 PM |
| ... Except that makes a method which doesn't work as Txt is a child of the table _G |
|
|
| Report Abuse |
|
|
miz656
|
  |
| Joined: 19 Jul 2010 |
| Total Posts: 15336 |
|
|
| 09 Feb 2012 08:34 PM |
@aboy
Wow, you don't not give up do you. Do kids pick on you a lot in school? |
|
|
| Report Abuse |
|
|
|
| 09 Feb 2012 08:37 PM |
"... Except that makes a method which doesn't work as Txt is a child of the table _G"
I don't get it? |
|
|
| Report Abuse |
|
|
aboy5643
|
  |
| Joined: 08 Oct 2010 |
| Total Posts: 5458 |
|
|
| 09 Feb 2012 08:41 PM |
@miz
No, I'm making sure he isn't misinformed now. Second question: No, why would they?? That would mean I don't talk back or defend myself. |
|
|
| Report Abuse |
|
|
miz656
|
  |
| Joined: 19 Jul 2010 |
| Total Posts: 15336 |
|
|
| 09 Feb 2012 08:55 PM |
| Well why do you have to be so cruel? |
|
|
| Report Abuse |
|
|
|
| 09 Feb 2012 09:12 PM |
None of you fixed the _G problem he had.
_G.Txt = 'print("HAI")'
He needed to instantiate the string with different quoting mechanisms, or use the escape character to add quotes to the string.
Though the issue of LocalScript _G and Script _G remains the same and has been explained before.
Miz, you DON'T always know what you're talking about. Just accept that you're sometimes incorrect. I can accept when I'm wrong, why can't you?
He's not cruel for telling you that you're wrong, and that you need to learn more before you teach about something you don't truly understand. And the fact that he shouldn't have to tell you that is the proof he's not being cruel.
Oh, and _G IS a table. |
|
|
| Report Abuse |
|
|
|
| 09 Feb 2012 09:15 PM |
"Though the issue of LocalScript _G and Script _G remains the same and has been explained before."
I guess it wasn't explained correctly.
Normal Scripts share a _G table SEPARATE from LocalScripts. A Script _G is different from a LocalScript _G. This is because LocalScripts are client-sided instead of being server-sided. This also means each player has his own client-sided _G table.
The same thing applies with the shared global table. |
|
|
| Report Abuse |
|
|
miz656
|
  |
| Joined: 19 Jul 2010 |
| Total Posts: 15336 |
|
|
| 09 Feb 2012 09:15 PM |
@AFF
Derp. I know I'm wrong. Everyone is wrong. It's just though that he will never respect me for who I am just because I made this terrible mistake when I was a beginner.
And yeah, I knew that after a 1/2 hour later when I looked it up. |
|
|
| Report Abuse |
|
|
|
| 09 Feb 2012 09:16 PM |
"It's just though that he will never respect me for who I am just because I made this terrible mistake when I was a beginner."
When did he say he doesn't respect you? He didn't say anything of the sort. All he said was that you need to learn more about the topics you try to teach, as teaching a topic without full understanding leads to bad teaching. |
|
|
| Report Abuse |
|
|
DXPower
|
  |
| Joined: 21 Oct 2008 |
| Total Posts: 2866 |
|
|
| 09 Feb 2012 09:19 PM |
Don't you need to call _G like this:
_G["Txt"] = [Data here]
All hail the Power of DX! |
|
|
| Report Abuse |
|
|
|
| 09 Feb 2012 09:20 PM |
_G is just a table, meaning you can use any indexing method you want.
Table = {}
Table.Value = "New" print( Table.Value ) --> New
:P |
|
|
| Report Abuse |
|
|
miz656
|
  |
| Joined: 19 Jul 2010 |
| Total Posts: 15336 |
|
|
| 09 Feb 2012 09:20 PM |
I can tell he doesn't respect me because he's always made me from the start when zar was my teacher.
You're positive. You're telling I'm doing stuff wrong in a good way, which I like. I respect that more. While I can tell he's doing it in a negative way thinking I'm an idiot. |
|
|
| Report Abuse |
|
|
|
| 09 Feb 2012 09:24 PM |
Just because he has a negative tone doesn't mean he doesn't respect you or think you're an idiot. He could be having a bad day. You don't know. I am actually quite annoyed with you the same way he's annoyed with you. I try not to bring emotions into my messages, as it can lead to quite an argument, which is beyond the level of a debate.
Truth is truth, no matter how you take it. |
|
|
| Report Abuse |
|
|
|
| 09 Feb 2012 09:28 PM |
So basicly, I can't use _G in a normal script to access in a LocalScript And I'm Still wondering if I can just do _G.Txt = 'print("HAI")'
Then In Another Normal Script...
loadstring(_G.Txt)()
@AFF You described it well, just I'm not sure of my theory. :)
`*\~-{ Are we there yet T.T? }-~/*` |
|
|
| Report Abuse |
|
|
|
| 09 Feb 2012 09:31 PM |
"So basicly, I can't use _G in a normal script to access in a LocalScript"
Correct.
"And I'm Still wondering if I can just do _G.Txt = 'print("HAI")' Then In Another Normal Script... loadstring(_G.Txt)()"
Correct.
Here are a few ways you could have instantiated the text:
_G.Txt = [[print("HAI")]] _G.Txt = [=[print("HAI")]=] .... Up to 6 = signs _G.Txt = "print(\"HAI\")" |
|
|
| Report Abuse |
|
|