Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   Graal V4 Main Forum (https://forums.graalonline.com/forums/forumdisplay.php?f=143)
-   -   Function Overrides (https://forums.graalonline.com/forums/showthread.php?t=61357)

Velox Cruentus 09-23-2005 03:28 AM

Function Overrides
 
The title says it, really...

Do you think you can make it such that objects can override particular commands? This would be useful in persay, classes that make an item act differently over a particular item, or if we want to override risky functions in order to log them... So on and so forth. Function Overrides.

ForgottenLegacy 09-23-2005 04:46 AM

Explain what you mean by 'override'? I'm thinking you could do a catchEvent type thing... Not sure though.

Velox Cruentus 09-23-2005 05:07 AM

function __echo(message)
{
sendtonc(player.account @ ":" @ message);
}

This overrides the default "echo" command.

ForgottenLegacy 09-24-2005 12:23 AM

Quote:

Originally Posted by Velox Cruentus
function __echo(message)
{
sendtonc(player.account @ ":" @ message);
}

This overrides the default "echo" command.

PHP Code:

(target).catchEvent(Object,PreviousEvent,NewEvent); 

Ex:

NPC Code:

player.catchEvent(player,"onKeyPressed","onAttacki ngTheKeyboard");
function onAttackingTheKeyboard(code,key) {
// Various scripts.
}



This is used in Guis quite a bit to catch and rename the "onAction" function with buttons to a new function name. Useful for many buttons that do simmilar things.

Velox Cruentus 09-24-2005 03:05 AM

Overriding means making a function that GOES OVER the current EXISTING function. It replaces the default function by the new one.

I don't want an alias of a function -- We have that possibility.

napo_p2p 09-24-2005 04:34 AM

I think would be a nice feature. Plus, it is a common trait of the newer object-oriented programming languages (I am not sure about the older ones).

Sildae 09-24-2005 12:58 PM

Quote:

Originally Posted by napo_p2p
Plus, it is a common trait of the newer object-oriented programming languages (I am not sure about the older ones).

Overriding functions is like the trait of object oriented programming languages. If a language does not support it, it is hardly object oriented.

Admins 09-24-2005 04:18 PM

Why that? For better consistency and security most of the time a lot of base functionality cannot be modified or overriden. I don't really think that it's needed, it could save time though if you have already a lot of code and don't want to change all the code to modify some base behaviour.

Velox Cruentus 09-24-2005 06:16 PM

Well -- One way would have classes overriding the default functions...

Lets say that I have a particular... Cat! And well, I have an animal NPC, and it's usually dogs! So when I join cats class to the animal NPC, it would override makeNoise() to say "Meow" instead of "Bark"

Inverness 09-25-2005 04:07 AM

Could make the base functions editable in Control-NPC like you can with Java.
I really want more flexibility in the NPC-Server

DarkFireXZ3 09-25-2005 08:14 AM

Interesting.. Inverness it would be better to have more over riding functions for the NPC-Control.


All times are GMT +2. The time now is 01:28 PM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.