-
Notifications
You must be signed in to change notification settings - Fork 49
Description
type..
TActorInterface = class(TBESENNativeObject)
class is registered properly so it can be prototyped from:
BesenInst.RegisterNativeObject('Actor', TActorInterface);
So i try to create a object on my side, and pass it as parameter to javascript
JsPlayer: TBESENValue;
AResult: TBESENValue;
ta: Tactor;
JsCreatedPlayer: TActorInterface;
begin
TBESEN(BesenInst).GarbageCollector.Protect(OnCreatePlayer);
try
AResult.ValueType := bvtBOOLEAN;
ta:= Tactor.GetFromIndex(PlayerID);
JsCreatedPlayer:= TActorInterface.Create(BesenInst, TBESEN(BesenInst).ObjectPrototype, false);
JsCreatedPlayer.SetHandle(ta.GetHandle());
TBESEN(BesenInst).GarbageCollector.Add(JsCreatedPlayer);
TBESEN(BesenInst).GarbageCollector.Protect(TBESENObject(JsCreatedPlayer));
a[0]:= @JsPlayer;
JsPlayer := BESENObjectValue(TBESENObject(JsCreatedPlayer));
// todo: add parameter player ID
OnCreatePlayer.Call(BESENObjectValue(OnCreatePlayer), @a, 2, AResult);
except
on e: EBESENError do
begin
addtochat(Format('%s ( Line %d ): %s', [e.Name, TBESEN(BesenInst).LineNumber, e.Message]));
end;
on e: exception do
begin
addtochat(Format('%s ( Line %d ): %s', ['Exception', TBESEN(Instance).LineNumber, e.Message]));
end;
end;
If i print the object it's:
[object TActorInterface$Constructor] {}
Looks like some sort of empty object, it doesn't function properly in javascript (cannot change properties, etc.. ).
I've based my code on what i saw in https://github.com/Coldzer0/Cmulator/ project, i'm guessing i did something very wrong.
I'd just like to create an instance of native object, and pass it to function, so that properties and all can be correctly used as if it was created within javascript.
If you have a better method of contacting i'll take it, as i'm abusing tickets for help / support :( i'm in #besen channel but you are usually not reachable there.