Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Today's Posts

 
 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #13  
Old 07-01-2011, 09:22 AM
MrDunne MrDunne is offline
Registered User
Join Date: Aug 2010
Posts: 38
MrDunne is on a distinguished road
Quote:
Originally Posted by Chompy View Post
Elaborate.
Quote:
Originally Posted by WhiteDragon View Post
There are a few problems.
  • In certain cases, when passing around an anonymous function, you lose the ability to call it. I think the problem is when you call the anonymous function from a different class than it was defined, but I'm not certain exactly when it happens. (If someone wants to debug this, please do.)

    My current hack around this is, given a function temp.f, doing (@temp.f)(), which casts the function pointer to a string like "function_913727", which is a global variable and can be called from anywhere as a result.
  • When a class using anonymous functions is updated, most things break until you update the NPC/Weapon that they are joined to.
Mainly this. There's also this:

PHP Code:
function onCreated() {
  
temp.func myTest();
  (@ 
temp.func)();

  
myOtherTest(function () {
    echo(
"yeah baby");
  });
}

function 
myTest() {
  return function () {
    echo(
"yeah baby");
  };
}

function 
myOtherTest(func) {
  (@ 
func)();

Produces the following:

HTML Code:
Script compiler output for *scratch*:
error: unexpected token: function at line 3: myOtherTest(function () {
error: unexpected token: ( at line 3: myOtherTest(function () {
error: unexpected token: ) at line 3: myOtherTest(function () {
error: unexpected token: ) at line 5: });
error: unexpected token: function at line 13: return function () {
error: unexpected token: ( at line 13: return function () {
error: unexpected token: ) at line 13: return function () {
It doesn't seem right to me.
Reply With Quote
 


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 05:10 PM.


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