![]() |
Function overriding
I've brought this up a few times before, but this would be insanely useful and I think it deserves its own thread.
Function overriding would allow you to essentially overwrite default commands. For example, if you wanted to create your own tileset layout without a custom movement system (syntax up for debate): PHP Code:
A simple example: PHP Code:
PHP Code:
PHP Code:
I have no idea how hard this would be to implement, but if it's not too difficult, it would be a huge improvement to GScript. |
This is normally called "function overriding".
And, it is "already possible" in GS2 in some technical sense. If you have access to a variable containing a function pointer (i.e., it was defined as an anonymous function), then you can override it. The problem is that all the existing functions are not defined as anonymous functions. Personally, I'd like to see the libraries be written in terms of higher order functions: e.g., onwall would accept the tiletype function as a parameter. This way you would rarely need to override things. This would be more work to do though. As for your second point, since GS2 does have some sort of OO support, I do agree that prototypes would be a good addition. Edit: Also, it's fairly critical that we get closure support soon (meaning that you can access variables outside the anonymous function from inside it) natively, rather than using my ugly hack for it. |
I think this is a good idea, working with type1 and noticing a lot of the functions didn't work I wanted to try and fix it.. never did but I figured out a better type1 template. >.>
But I also would have loved to override the movement system, which I could be confused about the exact message / statement, but from what I think I understand this is about overriding built in functions? Anyway, I hate how moving north east and south east the player faces right; moving north west the player faces left. Why does the player face down in south west? Again, assuming I got what WhiteDragon was saying about the libraries .. unless he didn't mean for us to see them.. I would love to see and edit the basic functions too. I was hoping I could find the tile system and see if I could edit that.. then looking at an online tile editor I was hoping I could at least organize that to be together in looks but still hold their functions ... like 0x1A0 could be next to 0x1D1 but I didn't understand the Online Tile Editor at all lol.. it didn't have any tile arrays.. Sorry if I got both comments all mixed up :x |
Quote:
I meant something like onwall accepting the tiletype function as a parameter: PHP Code:
Anyways, this would be a monumental amount of work and is just a pipedream. :) Snapping back to reality, it is important for overriding, prototypes, and closures to be implemented. I'd like to see some attention be given to these 3 things, because it would let the developers 'fix' a lot of problems with the default stuff without involving Stefan or rewriting everything from scratch. |
Ooh I see.. I can't say I fully understand, but I know on my pet system I have a problem making move serverside and it kinda just stops the moving script.. I suppose it is better than walking on a wall though.. I suppose I could find a way around this somehow but I am not an experienced NAT lol..
Anyway, my fault. :] |
Want this. Alternative syntax suggestion:
PHP Code:
|
Quote:
PHP Code:
I would also really like to see the prototype idea implemented. |
All times are GMT +2. The time now is 05:01 PM. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.