![]() |
NPCServer updates
Today the npcservers have been updated. Here some of the updates:
- /style works again - improved /scripthelp which also lists object types that match - fixed int(random(lowerlimit, upperlimit)) which sometimes reached upperlimit (when the random number was too close to the upperlimit it was rounding to upperlimit) - scripts can now access image files (png, gif, jpeg) and also files inside the levels folder if the npcserver has the rights for that - if you call a function of another object which is non-public, then it will display that the function is not accessible, instead of saying that the function doesn't exist - graal script now supports function objects: this will print "param: 123" PHP Code:
PHP Code:
There is a protection against unsetting functions, since often scripts use the same name for functions and variables. If the variable is not linking to a function but the script contains a function with that name, then it will use the function defined in the script instead. You can however link to another function. |
Quote:
Edit: But what is the point of doing function objects? o.O |
Very nice updates, Stefan. :)
|
Function objects!
What do they do? Sounds like fun. Edit: The first one I understand as being able to assign a function name to a variable. Being able to add params to the functionname by calling the variable as the function and receiving it using the assigned function name to the variable. Ah, tested out the later, the beauty of it is you don't need to actually receive the function. Now that is sexy. Edit 2: There's only a few problems I'm having, like not being able to return information and work with objects inside the "embedded functions". |
Nice Stefan. :)
|
Quote:
|
Very nice! I wanted function pointers for something a while ago... but now I can't remember what it was :P
|
Cool...
|
now i remember! I wanted some OO functionality without using classes.
If I did this: PHP Code:
|
Quote:
|
So what about returning information through this, doesn't seem to work?
|
Quote:
PHP Code:
|
Aww...printf() in loops problem wasn't fixed :cry:.
|
Quote:
|
Quote:
PHP Code:
PHP Code:
|
Quote:
Wondering if it would be possible to have this.foo = public function () also, or something similar. Defining functions using this method in a TStaticVar results in a function inaccessible error in RC. Currently it is a bit of a pain to have to define a public function and copy it, if the functions you are defining are different for each object. |
Quote:
Quote:
|
I can't seem to get function objects to work as expected:
PHP Code:
PHP Code:
Do function objects only work on this. variables? |
Quote:
But so far all I've witnessed object functions to be usable with is this. prefix. I tried it with temp and it didn't work for the most part, I'll make sure to test that out again, but I think it should work in general tho. E: Definitely only useable with this. prefix. The question is if this is so limited, can we get some more effective or in-depth uses of pointer functions. At this time I don't really see the use. |
if ( func( "blah" ) )
vs. this.funct = func(); if ( this.funct( "blah" ) ) Any other uses? That doesn't make any sense to me. |
Quote:
PHP Code:
PHP Code:
|
Point is, this limits the amount of functions you catch and call.
|
Quote:
|
I honestly think this is useless and is just causing confusion. I get it, but at the same time it still confuses me
|
I find that the most practical thing about this function thing if for sorting... Basically, passing the function the depicts which value is greater.
|
Quote:
Quote:
They are very useful for controlling functions at execution time, and they are a lot more organised in event-driven system. |
Quote:
|
Quote:
Quote:
Quote:
|
Quote:
It is something I used in my mud system, you construct all mud objects in a single array and return the object reference with the function. Having a master list prevents the object from being destroyed because of lack of references. Though I don't know what Graal does when all references are removed, I expect it similar to Java. |
Quote:
|
I already know points are left behind but I meant the object itself. If it wasn't destroyed on loss of references it could still function.
|
Hmm...i doubt gscript has a garbage collector. Make a random global TStaticVar(), remove the code that made it and check up on it every now and then ^^.
|
Fun stuff!
Good job :) |
Quote:
About the "not accessible" error: I have fixed it, will upload new npcservers soon. About npc rights problems: The problem is that people write their account name wrong (wrong case), so the npcserver is not accepting it; to fix it write it correctly e.g. Shadow87 instead of shadow87, I will also upload new npcservers soon. |
Reviving thread here but are variable functions available on the client yet? I tried to make one but it didn't work :cry:
|
Quote:
PHP Code:
|
Quote:
|
Quote:
PHP Code:
|
strange, no idea but would ths work
PHP Code:
|
Quote:
|
All times are GMT +2. The time now is 01:26 AM. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.