Vaulcus
|
  |
| Joined: 06 Nov 2012 |
| Total Posts: 380 |
|
|
| 22 Dec 2014 02:35 PM |
| How do you know if your considered 'good' or at least better than most. :/ |
|
|
| Report Abuse |
|
|
eLunate
|
  |
| Joined: 29 Jul 2014 |
| Total Posts: 13268 |
|
|
| 22 Dec 2014 02:37 PM |
A good scripter is one that isn't lazy. Take this purposefully annoying code for example:
local Basiero,m,p,s = {},math,print,setmetatable; function Basiero:novigxu(vortaro) local novaBasiero = { Vortaro=vortaro or { "Rawr", "Grr", "Nrrgh", "Nrra'h" }; {m.random,p}} self.__index=self; return s(novaBasiero,self); end
function Basiero:diru(I) self [1] [2] (self.Vortaro[I or (self [1][1])(#self.Vortaro)) end
local Basieron = Basiero:novigxu() Basieron:diru()
A good scripter would understand exactly what is happening and could tell you what the output would be hehe |
|
|
| Report Abuse |
|
|
|
| 22 Dec 2014 02:44 PM |
| You missed something eLunate |
|
|
| Report Abuse |
|
|
Goulstem
|
  |
| Joined: 04 Jul 2012 |
| Total Posts: 7177 |
|
| |
|
eLunate
|
  |
| Joined: 29 Jul 2014 |
| Total Posts: 13268 |
|
|
| 22 Dec 2014 02:55 PM |
"Grrr
Rawr"
You lose. You're wrong. |
|
|
| Report Abuse |
|
|
eLunate
|
  |
| Joined: 29 Jul 2014 |
| Total Posts: 13268 |
|
|
| 22 Dec 2014 02:57 PM |
| Yes I realise I did miss a bracket. That was typed up on my phone just shhh |
|
|
| Report Abuse |
|
|
Vaulcus
|
  |
| Joined: 06 Nov 2012 |
| Total Posts: 380 |
|
|
| 22 Dec 2014 02:59 PM |
Well I couldn't for the life of me understand such code. :/
I can tell that:
Line 1: Making four variables and setting them to four different values Line 2: Method with one parameter Line 3: Outer table (non-nested) Line 4-10: Nested tables (multidimensional table?) Line 11: IDEK Line 12: s was set to 'setmetatable' so yeah, it's just a reference to the other function Line 13: Obviously end to the method
Line 15-End: IDEK
|
|
|
| Report Abuse |
|
|
eLunate
|
  |
| Joined: 29 Jul 2014 |
| Total Posts: 13268 |
|
|
| 22 Dec 2014 03:03 PM |
| A good scripter should be able to look through the code and tell me exactly what the output should be, because they know where everything is coming from. There's not even any excessive math or stuff that requires any more than logic in that. |
|
|
| Report Abuse |
|
|
Vaulcus
|
  |
| Joined: 06 Nov 2012 |
| Total Posts: 380 |
|
|
| 22 Dec 2014 03:14 PM |
I've looked through it for I think twenty minutes now. I considered this ten minutes ago but dismissed it. Wouldn't it cause an error?
Right here > Basieron:diru()
Cause diru() is a method of Basiero, not Basieron.
I may be horribly wrong. :/ |
|
|
| Report Abuse |
|
|
eLunate
|
  |
| Joined: 29 Jul 2014 |
| Total Posts: 13268 |
|
|
| 22 Dec 2014 03:14 PM |
| Nope. Go look up metatables hehe |
|
|
| Report Abuse |
|
|
Xsitsu
|
  |
| Joined: 28 Jul 2009 |
| Total Posts: 2921 |
|
|
| 22 Dec 2014 03:17 PM |
Just run it through studio.
Nrra'h |
|
|
| Report Abuse |
|
|
morash
|
  |
| Joined: 22 May 2010 |
| Total Posts: 5834 |
|
|
| 22 Dec 2014 03:17 PM |
| I would understand it better if it were written with more English like names, for I do not understand Spanish. |
|
|
| Report Abuse |
|
|
|
| 22 Dec 2014 03:18 PM |
| I don't understand Spanish either. |
|
|
| Report Abuse |
|
|
Vaulcus
|
  |
| Joined: 06 Nov 2012 |
| Total Posts: 380 |
|
|
| 22 Dec 2014 03:23 PM |
I don't know why I wish to solve this so badly. D:
Does it return a random number followed by "Nrra'h"? |
|
|
| Report Abuse |
|
|
eLunate
|
  |
| Joined: 29 Jul 2014 |
| Total Posts: 13268 |
|
| |
|
Vaulcus
|
  |
| Joined: 06 Nov 2012 |
| Total Posts: 380 |
|
|
| 22 Dec 2014 03:32 PM |
I think I can partially explain it:
Code:
function Basiero:diru(I) self [1] [2] (self.Vortaro[I or (self [1][1])(#self.Vortaro)) end
local Basieron = Basiero:novigxu() Basieron:diru()
Explanation:
Basieron:diru() -- No parameter supplied so it goes to the default value
(self.Vortaro[I or (self [1][1])(#self.Vortaro)]) #self.Vortaro refers to the fourth element of Vortato, which is Nrra'h. :/ self [1][1] is just another way of saying self.Vortaro. |
|
|
| Report Abuse |
|
|
morash
|
  |
| Joined: 22 May 2010 |
| Total Posts: 5834 |
|
|
| 22 Dec 2014 03:35 PM |
Editing the script for my own purposes without editing the function :P
local a,math,print,setmetatable = {},math,print,setmetatable;--Bam, changed nothing. function a:b(input) local c = { d=input or { "Rawr", "Grr", "Nrrgh", "Nrra'h" }; {math.random,print}} self.__index=self; return setmetatable(c,self); end
function a:e(I) self [1] [2] (self.d[I or (self [1][1])(#self.d)) end
local f = a:b() f:e()
It would print either "Rawr","Grr","Nrrgh","Nrra'h" since self[1][2] is print, self[1][1] is math.random, and your imputing the random function with the number of elements in the default d. Correct? |
|
|
| Report Abuse |
|
|
morash
|
  |
| Joined: 22 May 2010 |
| Total Posts: 5834 |
|
|
| 22 Dec 2014 03:36 PM |
| Actually it would error because you forgot to close your index. :P |
|
|
| Report Abuse |
|
|
eLunate
|
  |
| Joined: 29 Jul 2014 |
| Total Posts: 13268 |
|
|
| 22 Dec 2014 03:37 PM |
| Congratulations for being the first person to not be lazy, and taking the time to actually understand what the script does give yourself a gold star you win. |
|
|
| Report Abuse |
|
|
Vaulcus
|
  |
| Joined: 06 Nov 2012 |
| Total Posts: 380 |
|
|
| 22 Dec 2014 03:37 PM |
| Well okay. Obviously I have work to do. I usually comment and format my code more. D: |
|
|
| Report Abuse |
|
|
eLunate
|
  |
| Joined: 29 Jul 2014 |
| Total Posts: 13268 |
|
|
| 22 Dec 2014 03:37 PM |
Yes I am aware I forgot the closing ] here self [1] [2] (self.Vortaro[I or (self [1][1])(#self.Vortaro)]) |
|
|
| Report Abuse |
|
|
Vaulcus
|
  |
| Joined: 06 Nov 2012 |
| Total Posts: 380 |
|
|
| 22 Dec 2014 03:39 PM |
| Also, I thought self[1][2] was the print function, but I thought Lua indexes started at 1 (even though other languages start with 0) so that part messed me up. :/ Would self.Vortaro be self[0]??? |
|
|
| Report Abuse |
|
|
morash
|
  |
| Joined: 22 May 2010 |
| Total Posts: 5834 |
|
|
| 22 Dec 2014 03:41 PM |
self.Vortaro = self["Vortaro"]
Vortaro is an index. |
|
|
| Report Abuse |
|
|
Vaulcus
|
  |
| Joined: 06 Nov 2012 |
| Total Posts: 380 |
|
|
| 22 Dec 2014 03:42 PM |
| I looked it up and Lua starts at 1... I honestly understand nothing of this. Why is [1][2] referring to the second element in the SECOND table??? D: |
|
|
| Report Abuse |
|
|
Vaulcus
|
  |
| Joined: 06 Nov 2012 |
| Total Posts: 380 |
|
|
| 22 Dec 2014 03:43 PM |
| Oh. Well thank you anyways. I think now is a good time to close this thread. |
|
|
| Report Abuse |
|
|