Rophs Posted July 21, 2014 Report Share Posted July 21, 2014 Does MDScript offer features of OOP? Quote Link to comment Share on other sites More sharing options...
Kaya Posted July 21, 2014 Report Share Posted July 21, 2014 (edited) Sadly the closest you can get to it is arrays, as far as I know. You can't even define your own functions. Edit: You can define your own functions. Edited February 23, 2016 by samon Quote Link to comment Share on other sites More sharing options...
DarkRaptor Posted July 22, 2014 Report Share Posted July 22, 2014 You can find a compilation of the MDScript available functions in the Wikia: http://magicduel.wikia.com/wiki/Category:MDScript Quote Link to comment Share on other sites More sharing options...
Kaya Posted February 23, 2016 Report Share Posted February 23, 2016 (edited) I tried playing around with MDScript a little more and apparently you can use functions. That being said I haven't found a way to use variables from outside a function (other than passing them as parameters and returning them) inside the function. In that sense it is more like functional programming than OOP. Also it doesn't appear to be possible to use MDScript specific methods inside a user defined function. e.g: function bar() { echo @vv; //Always echoes nothing @vv = 'bar'; } @vv = 'foo'; bar(); echo @vv; //echoes foo function baz(@vv) { @vv = 'baz'; return @vv; } baz(@vv); echo @vv; //still foo @vx = baz(@vv); echo @vv; //still foo echo @vx; //vx is now baz function err() { echo uv('id'); } err(); //Gives an error because uv is undefined Edited February 23, 2016 by samon Quote Link to comment Share on other sites More sharing options...
Root Admin Chewett Posted February 23, 2016 Root Admin Report Share Posted February 23, 2016 That being said I haven't found a way to use variables from outside a function (other than passing them as parameters and returning them) inside the function.Tried using global keyword?Also it doesn't appear to be possible to use MDScript specific methods inside a user defined function.Tried passing them in? Quote Link to comment Share on other sites More sharing options...
Kaya Posted February 23, 2016 Report Share Posted February 23, 2016 Global is a restricted keyword (thrice even) so that doesn't work. As for passing in the methods, you can pass in the return values, but other than that not sure how it would work. (It is, for fairly obvious reasons, not possible to call a method stored in a variable, if that is what you mean.) Quote Link to comment Share on other sites More sharing options...
Root Admin Chewett Posted February 23, 2016 Root Admin Report Share Posted February 23, 2016 Global is a restricted keyword (thrice even) so that doesn't work.I shall add that to my list to review. we can probably expose the functions by default or via namespacing.As for passing in the methods, you can pass in the return values, but other than that not sure how it would work. (It is, for fairly obvious reasons, not possible to call a method stored in a variable, if that is what you mean.)Not possible in MDscript, or PHP? http://php.net/manual/en/functions.variable-functions.php Quote Link to comment Share on other sites More sharing options...
Kaya Posted February 24, 2016 Report Share Posted February 24, 2016 Not possible in MDscript, or PHP? http://php.net/manual/en/functions.variable-functions.php Not possible in MDScript, which makes sense because there is no control over what code is saved inside the variable, allowing it to bypass all restrictions. Quote Link to comment Share on other sites More sharing options...
I am Bored Posted February 26, 2016 Report Share Posted February 26, 2016 You can use MDScript specific functions from within your own functions, but you have to add: (prepare function) on the first line inside the body of the function. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.