SRL Archive - General

MSI API - To make it easier for others to create extras.


Gu3st...

2011-01-05 14:19:34

As we have it right now, we have to hard-code defines and stuff like that into the include to make Extras work. Cstrikes Extra is an awfully good example of this.. A lot of people has been asking about a world walker, and each time we've said "We haven't implemented it yet", and I find that to be a bad way of doing it, so I had to think about ways to do it so people can use Extras "plug-and-play" mode.

This way, the person that made the Extra can implement the Extra himself. All the user has to do is to include it.

How? Well… One way of doing this is to make an array of procedures like SRL does: (but there could be other ways)
{ const SRL_Procs Constants;
Description: Constants for SRL_Procs. }
const
srl_AntiBan = 0; // Your AntiBan procedure to be called during various SRL functions and procedures. (Flag, FFlag)
srl_OnFindMod = 1; // After a player or Jagex mod is detected talking in the chat box.
srl_OnFindDead = 2; // After the text 'Oh dear you are dead' is detected.
srl_OnFindFight = 3; // After detecting a fighting random.
srl_OnFindTrade = 4; // After the trade has been attempted (either success or failure).
srl_OnNextPlayer = 5; // While the players are logged out and before CurrentPlayer changes.
srl_OnSendStats = 6; // After SRL Script Stats are sent to the server.
srl_OnRandomCall = 7; // Called in FindNormalRandoms, FindInventoryRandoms, FindNonInventoryRandoms. (NOT ONLY WHEN RANDOMS ARE DETECTED).
srl_OnFindRandom = 8; // After a random event is detected. (FNR, FIR, FNIR, FT)
srl_OnLogOut = 9; // Just before the player is logged out.
srl_InNextPlayerLoop = 10; // During the infinite loop in NextPlayer when all players are inactive.
srl_OnCustomRC = 11; // When custom RC trigger has been given.
srl_OnExitToLobby = 12; // On exit to lobby
srl_OnLogIn = 13; // Right after player has successfully logged in.

{ var SRL_Procs: array [0..12] of procedure();
Description: Varibles to store user-defined procs to be called in SRL. }
var
SRL_Procs: array [0..13] of procedure();

Now the Extra creator (in my example cstrike) can do MSI_OnWalkToCall := @cstrike_WalkTo; and MSI would check if the respecting msi_proc is set before calling MSI's WalkTo. If it's set then it'll skip MSI's WalkTo and do the Extra's walkto, if it's not then we'll use MSI's Extra.

In the case that there's more than one Extra that requires a proc, we could make it that the user has to choose which one to use or both of them or something like that… We'll figure that out later; after all.. This is the 'Planning' sub-forum ;)

This would open a lot of doors to people who want to contribute to MSI the Extra way (Like Boreas, who is working on CTWB (Color Tile Walking Base). If this Extra was in MSI, then the development of that project would increase a lot (because atm if you want to help development of that project the scripter has to edit all they're GetMyPos to CTWB_GetMyPos)).

We could have MSI_OnFormOpen/Close, MSI_OnLogin/out, MSI_OnScriptChange and so on.

I really, really, really want this to happen, and this would also make it possible for me to realize one of my dreams…. more on that later ;)

Any comments?

Coh3n

2011-01-05 15:17:38

From: Zyt3x
As we have it right now, we have to hard-code defines and stuff like that into the include to make extensions work (right?), and I find that to be a bad way of doing it, so I had to think about ways to do it so people can use extensions "plug-and-play" mode.

What? :o I have no idea what you mean. You just put extensions in Simba's extensions folder.

From: Zyt3x

This would open a lot of doors to people who want to contribute to MSI the extension way (Like Boreas, who is working on CTWB (Color Tile Walking Base). If this extension was in MSI, then the development of that project would increase a lot (because atm if you want to help development of that project the scripter has to edit all they're GetMyPos to CTWB_GetMyPos)).

Again, what? I don't understand how having that extension would help development? By extensions, do you mean Extra? Because extensions and extras are completely different.

From: Zyt3x

We could have MSI_OnFormOpen/Close, MSI_OnLogin/out, MSI_OnScriptChange and so on.

Yes I like the idea, but I don't see how it relates to Boreas' project. :o

Gu3st...

2011-01-05 16:36:25

From: Coh3n
What? :o I have no idea what you mean. You just put extensions in Simba's extensions folder.

Again, what? I don't understand how having that extension would help development? By extensions, do you mean Extra? Because extensions and extras are completely different.

I don't think I expressed myself clearly enough :( I'll rephrase the first post…

From: Coh3n
Yes I like the idea, but I don't see how it relates to Boreas' project. :o
To help Boreas with his project, the scripter has to change all his GetMyPos to CTWB_GetMyPos. with an API scripter wouldn't have to do that, as Boreas could've done OnGetMyPosCall := @CTWB_GetMyPos or something like that.


Edit: I hope you get my idea now, Coh3n? :)

Coh3n

2011-01-05 16:45:55

From: Zyt3x
I don't think I expressed myself clearly enough :( I'll rephrase the first post…

To help Boreas with his project, the scripter has to change all his GetMyPos to CTWB_GetMyPos. with an API scripter wouldn't have to do that, as Boreas could've done OnGetMyPosCall := @CTWB_GetMyPos or something like that.

Okay yeah, but that would have to be in reflection/SRL, not just MSI.

Gu3st...

2011-01-05 17:31:27

From: Coh3n
Okay yeah, but that would have to be in reflection/SRL, not just MSI.
Hmm… Yeah… :o You're right.. Kinda lame of me to use that as an example… :duh:

Coh3n

2011-01-05 17:48:44

Just reread the first post, and now I understand. I was confused because you keep using the word 'extension' when you're talking about an 'extra'. Extensions are for Simba (srl.sex, reflection.sex, and msi.sex), and Extras are for MSI (Cstrike's world walker).

What you're suggesting is the same as we have now, just in a different way. Right now, defines are used so it would be like

procedure Walk;
begin
{$IFDEF WORLD_WALKER}
WorldWalk();
{$ELSE}
MSI_Walk();
{$ENDIF}
end;
Where (if I understand correctly) yours would be

procedure Walk;
begin
if (MSI_OnCall[call_OnWalk] <> nil) then
MSI_OnCall[call_OnWalk]()
else
MSI_Walk();
end;
The difference is not everything is compiled when using defines.

I think I like your idea better. We could even add a procedure to RunMe.simba (like DeclareSettings) where to user can choose which to use (completely optional of course).

procedure DeclareOnCalls;
begin
MSI_OnCall[call_OnWalk] := @WorldWalk_Cstrike();
MSI_OnCall[call_GetMyPos] := @CTWB_GetMyPos();
end;
Although I'm not sure if that would work properly as some functions would require different parameters than others.

Gu3st...

2011-01-05 17:55:20

From: Coh3n
Just reread the first post, and now I understand. I was confused because you keep using the word 'extension' when you're talking about an 'extra'. Extensions are for Simba (srl.sex, reflection.sex, and msi.sex), and Extras are for MSI (Cstrike's world walker).
Ah right!! Yes, I meant extra :)

From: Coh3n
What you're suggesting is the same as we have now, just in a different way. Right now, defines are used so it would be like

procedure Walk;
begin
{$IFDEF WORLD_WALKER}
WorldWalk();
{$ELSE}
MSI_Walk();
{$ENDIF}
end;
Is that Walk; inside an extra? If that's the case then I'd say that I do not really like that, but I guess it would work good enough

From: Coh3n
Where (if I understand correctly) yours would be

procedure Walk;
begin
if (MSI_OnCall[call_OnWalk] <> nil) then
MSI_OnCall[call_OnWalk]()
else
MSI_Walk();
end;
The difference is not everything is compiled when using defines.

I think I like your idea better. We could even add a procedure to RunMe.simba (like DeclareSettings) where to user can choose which to use (completely optional of course).

procedure DeclareOnCalls;
begin
MSI_OnCall[call_OnWalk] := @WorldWalk_Cstrike();
MSI_OnCall[call_GetMyPos] := @CTWB_GetMyPos();
end;
Although I'm not sure if that would work properly as some functions would require different parameters than others.

I think I have misunderstood how MSI is setting up it's extras…
I mean, I know what defines is and how it works, but I though if we wanted to use it in MSI we had to do changes to Setup.simba and stuff like that…

Coh3n

2011-01-05 18:03:36

From: Zyt3x
Is that Walk; inside an extra? If that's the case then I'd say that I do not really like that, but I guess it would work good enough

No. :p I was just using that as an example. I made it up.

From: Zyt3x

I think I have misunderstood how MSI is setting up it's extras…
I mean, I know what defines is and how it works, but I though if we wanted to use it in MSI we had to do changes to Setup.simba and stuff like that…

Right now you just have to comment/uncomment the extras you want to use in Extras.simba, but I think they could be commented/uncommented in RunMe.simba now that I think about it.

NCDS

2011-01-05 18:54:44

From: Coh3n
No. :p I was just using that as an example. I made it up.


Right now you just have to comment/uncomment the extras you want to use in Extras.simba, but I think they could be commented/uncommented in RunMe.simba now that I think about it.


Perhaps there could be an 'Extras' page on the form?

Coh3n

2011-01-05 18:57:45

From: NCDS
Perhaps there could be an 'Extras' page on the form?

Yeah may not be a bad idea. Should be done when we actually start using extras.

Sir R. M8gic1an

2011-01-06 08:30:20

I honestly like the pointers idea.

It's just the way it's been going.


const
MSI_StartWalk
MSI_WhileWalk
MSI_EndWalk

MSI_Find
MSI_Get

MSI_OnInvFull
MSI_OnInvEmpty

MSI_Antiban
MSI_Respond
MSI_ActHuman


Procedure LoadMining;
begin
MSIProcs[MSI_StartWalk] := cs_Walk();
MSIProcs[MSI_WhileWalk] := RM_WalkMode();
MSIProcs[MSI_EndWalk] := MSI_ReCenter();

//...
end;


Just my first thoughts.

~RM

Coh3n

2011-01-06 11:54:17

Me too, we just need a way to handle parameters.

Gu3st...

2011-01-06 17:54:09

Tbh, I don't really understand "What you're suggesting is the same as we have now, just in a different way." Coh3n. Would you care to elaborate please? :)

When I look at the MSI code, there is nothing that even looks like this idea, we have defines, which have to be hard-coded into the include, while my idea would make it possible for the extra's creator to make it work without having to alter anything in the include

NCDS

2011-01-06 19:09:09

From: Zyt3x
Tbh, I don't really understand "What you're suggesting is the same as we have now, just in a different way." Coh3n. Would you care to elaborate please? :)

When I look at the MSI code, there is nothing that even looks like this idea, we have defines, which have to be hard-coded into the include, while my idea would make it possible for the extra's creator to make it work without having to alter anything in the include


What you posted does the same thing, just differently.

Personally I like the fact that with defines, not all the un-used extras need to be compiled, but pointers are cool too. :p

Coh3n

2011-01-07 15:12:51

From: Zyt3x
Tbh, I don't really understand "What you're suggesting is the same as we have now, just in a different way." Coh3n. Would you care to elaborate please? :)

When I look at the MSI code, there is nothing that even looks like this idea, we have defines, which have to be hard-coded into the include, while my idea would make it possible for the extra's creator to make it work without having to alter anything in the include

Both ideas essentially do the same thing. They're both ways of using Extras.