SRL Archive - Development

Simba Plugin Templates


Dgby714

2011-06-12 22:55:22

FreePascal
library libDG;

{$mode objfpc}{$H+}

uses
cmem, Classes, Sysutils;

function a(): integer;
begin
Result := 42;
end;

function GetFunctionCount(): Integer; stdcall; export;
begin
Result := 1;
end;

function GetFunctionInfo(x: Integer; var ProcAddr: Pointer; var ProcDef: PChar): Integer; stdcall; export;
begin
case x of
0: begin
ProcAddr := @a;
StrPCopy(ProcDef, 'function a(): integer;');
end;
else
x := -1;
end;
Result := x;
end;

exports GetFunctionCount;
exports GetFunctionInfo;

initialization
end.

C
#include <string.h>

static int __stdcall a() {
return 42;
}

static int __stdcall GetFuncCount(void) {
return 1;
}

static int __stdcall GetFuncInfo(int x, void **addr, char **def) {
switch (x) {
case 0:
*addr = (void *)&a;
strcpy(*def, "function a(): integer;");
break;
default:
x = -1;
}
return x;
}

int GetFunctionCount(void) __attribute__((alias("GetFuncCount@0")));
int GetFunctionInfo(int x, void **addr, char **def) __attribute__((alias("GetFuncInfo@12")));

Feel Free to post more info. =)

Wizzup?

2011-06-13 05:17:25

We should probably also discuss memory sharing somewhere. (I|Someone) actually need to look into that. :)

Dgby714

2011-06-13 09:20:32

From: Wizzup?
We should probably also discuss memory sharing somewhere. (I|Someone) actually need to look into that. :)


Edit: Will add, =)

masterBB

2011-07-12 14:36:05

Didn't feel like creating my own thread, it's not possible to use functions and types from simba in a FreePascal plugin, right?

Dgby714

2011-07-12 14:48:19

From: masterBB
Didn't feel like creating my own thread, it's not possible to use functions and types from simba in a FreePascal plugin, right?


Use MML and you can.

masterBB

2011-07-12 14:49:21

From: Dgby714
Use MML and you can.


Thanks, was looking for something like that.

Dgby714

2011-07-12 14:54:54

From: masterBB
Thanks, was looking for something like that.


You're gonna need "Units/MMLCore" from Simba's repo, add it as a unit to your project.

Dynamite

2012-01-13 06:20:11

Would I (be able to) include SRL in the plugin or the script that uses the plugin?

-Boom

Brandon

2012-01-13 06:37:54

Script uses the plugin.. Had this problem last night with a dll I wrote. Was told the same thing n it only makes sense no? But yeah plugins cannot use script functions.

Though u can write the entire function in the plugin :P which I believe u can because I've done it multiple times for that bitmap downloaded. Then have Simba call ur plugin functions

Dynamite

2012-01-13 06:45:29

Wait so could I do -
SCRIPT
program blah;
{.include srl/srl.simba}
// include the plugin

Begin
MineRock('This function is in the plugin and also uses SRL');
End.

Would that work?

-Boom

Brandon

2012-01-13 06:52:44

Yeah u can do that as long as everything needed is defined inside the plugin.. Ud probably have a lot of work to do to get that to work since u can't use the srl include.. Can only use mml and it's mufasa types Also not sure if it'll be able to use smart but I can write up one for u n test of it works if u like

Markus

2012-01-13 06:59:35

You can get client data yes.

Dynamite

2012-01-13 07:11:14

Ok thanks guys :-)

-Boom

KingKong

2012-01-13 07:27:41

From: Dynamite
Wait so could I do -
SCRIPT
program blah;
{.include srl/srl.simba}
// include the plugin

Begin
MineRock('This function is in the plugin and also uses SRL');
End.

Would that work?

-Boom

No that won't work. A plugin cannot 'see' what's outside(srl include for example). So the MineRock function will not work since it needs srl include, but the srl include is not inside the dll.

Dynamite

2012-01-13 07:30:56

From: KingKong
No that won't work. A plugin cannot 'see' what's outside(srl include for example). So the MineRock function will not work since it needs srl include, but the srl include is not inside the dll.


Could I include srl as a unit in the plugin?

-Boom

KingKong

2012-01-13 08:07:10

not really, since srl has like gazllion files and you'd have to add them all. What exactly do you want to do? Make your script faster?

Dynamite

2012-01-13 09:12:34

I am looking into plugins to hide the main source of a script.

-Boom

Home

2012-01-13 09:20:31

From: Dynamite
I am looking into plugins to hide the main source of a script.

-Boom


Not sure is it possible but do the same was as RID does ?


~Home

Dynamite

2012-01-13 09:21:48

From: Home
Not sure is it possible but do the same was as RID does ?


~Home


What does RiD do? :-)

-Boom

RISK

2012-01-13 09:27:29

Doesn't RiD access a server from the script to access the true script? Kind of like how Impsoft does it.

Dynamite

2012-01-13 09:34:12

From: RISK
Doesn't RiD access a server from the script to access the true script? Kind of like how Impsoft does it.


I was thinking of doing that but a user could just look at the link and follow it.

-Boom

RISK

2012-01-13 09:38:08

Isn't there a way to send a 'Message' to the server and have the URL that the script interacts with actually give the script? So that if the user of the script follows the URL in the script, it wouldn't do anything because they can't send that 'Message'?

I'm not very experienced with anything like that, but.

Dynamite

2012-01-13 09:39:37

Hmm, yes that could be possible… I think.

-Boom

Sex

2012-03-06 23:39:54

We should have Lape plugin examples here as well.

FreePascal:

library libDG;

{$mode objfpc}{$H+}

uses
Classes, SysUtils, lptypes;

{$R *.res}

procedure a(Params : PParamArray; Result : Pointer);
begin
PLongInt(Result)^ := 42;
end;

function GetFunctionCount(): Integer; stdcall; export;
begin
Result := 1;
end;

function GetFunctionInfo(x: Integer; var ProcAddr: Pointer; var ProcDef: PChar): Integer; stdcall; export;
begin
case x of
0: begin
ProcAddr := @a;
StrPCopy(ProcDef, 'function a(): integer;');
end;
else
x := -1;
end;
Result := x;
end;

exports GetFunctionCount;
exports GetFunctionInfo;

initialization
end.
You'll also need to add the lptypes (Lape types) unit to your project…