View Issue Details

IDProjectCategoryView StatusLast Update
0003825The Dark ModScript/Defpublic22.08.2014 15:49
Reportertels Assigned To 
PrioritynormalSeverityfeatureReproducibilityN/A
Status newResolutionopen 
Summary0003825: callFunctionWithEntity(), callFunctionWithFloat(), callFunctionWithString()
DescriptionOften one wants to call a method on an entity's scriptobject, and there is indeed callFunction() (which should be actually named callMethod(), though).

However, it is not possible to pass arguments this way. While it is possible to workaround that with:

 if (ent.hasFunction( methodName ))
   {
   ent.setKey( "x_arg_call", someent.getName() );
   ent.callFunction( methodName );
   ent.removeKey( "x_arg_call" );
   }

and then one could retrieve the entity with:

  entity e = sys.getEntity( getKey("x_arg_call") );

But this is quite cumbersome and a lot slower than a native call with the entity as the argument. Plus, it is only possible to pass strings, but not native floats or booleans or entities.

So it would be nice to have callMethodWithEntity() and callMethodWithEntity():

 if (ent.hasFunction( methodName ))
   {
   ent.callFunctionWithEntity( methodName, someent );
   }
 if (ent.hasFunction( methodName ))
   {
   ent.callFunctionWithFloat( methodName, 1.1 );
   }
 if (ent.hasFunction( methodName ))
   {
   ent.callFunctionWithString( methodName, "some string" );
   }

and the scripting interface would check if there is a function on the script object with that name and matching parameter set and call it.
TagsNo tags attached.

Activities

There are no notes attached to this issue.

Issue History

Date Modified Username Field Change
22.08.2014 15:49 tels New Issue