Jump to content
wyn10

RS2 Template.

Recommended Posts

No declareplayers in the OSI/RS2 template? Wat.

 

Change to...

 

program New;

{$DEFINE RS2}
{$DEFINE OSI_Color_Anti_Randoms}
{$DEFINE SMART}                   // Comment out to disable SMART

{$I OSI\OSI.scar}

const
 Player_Booleans_Count = 2;
 Player_Integers_Count = 2;
 Player_TIA_Count = 1;

 procedure DeclarePlayer;
var
 I: LongInt;
begin
 SetLength(Players, 1);
 for I := 0 to High(Players) do
 begin
   SetLength(Players[i].Integers, Player_Integers_Count);
   SetLength(Players[i].Booleans, Player_Booleans_Count);
   SetLength(Players[i].TIA, Player_TIA_Count);
 end;

 with Players[0] do
 begin
   Name := '';
   Pass := '';
   Pin := '';
   WorldInfo := [True, -1];
   Active := True;

 end;
end;

procedure ScriptTerminate;
begin
 FreeOSI;
end;

begin
 SetUpOSI;
 DeclarePlayer;
end.

 

Thanks.

Link to comment
Share on other sites

As im not too updated with scar scripting as I am with c language programming. I would have to notice though is Longint really right? I know a long in C# and I believe same in c++ is 64 bit which is a bit overkill for the ammount of numbers and the length of such numbers.

I think you can use a byte instead, or even a short. which is 8 and 16 signed. Much different if the whole code is written wrong and upgarded to code, this will help processors and people who dont exactly have an updated pc.

 

As I said im not a huge scar scripter as of yet but basic programming knowledge says it is overkill and takes up alot more processing than what is actually needed. So I do hope I dont get flamed by not knowing the value types in pascal available

Link to comment
Share on other sites

wyn10 I have a better way

 

As im not too updated with scar scripting as I am with c language programming. I would have to notice though is Longint really right? I know a long in C# and I believe same in c++ is 64 bit which is a bit overkill for the ammount of numbers and the length of such numbers.

I think you can use a byte instead, or even a short. which is 8 and 16 signed. Much different if the whole code is written wrong and upgarded to code, this will help processors and people who dont exactly have an updated pc.

 

As I said im not a huge scar scripter as of yet but basic programming knowledge says it is overkill and takes up alot more processing than what is actually needed. So I do hope I dont get flamed by not knowing the value types in pascal available

Turns out different types are some what sketchy when it comes to stuff like longint, integer, byte, int64. You really have to know what you're doing in SCAR when using them otherwise you run into major problems. I've found it's just best to use integer unless you need int64 and only use longint or byte if you're trying to make an existing type... just to be on the safe side.

Link to comment
Share on other sites

wyn10 I have a better way

 

 

Turns out different types are some what sketchy when it comes to stuff like longint, integer, byte, int64. You really have to know what you're doing in SCAR when using them otherwise you run into major problems. I've found it's just best to use integer unless you need int64 and only use longint or byte if you're trying to make an existing type... just to be on the safe side.

 

Hmm, they're as "sketchy" as in any language, you just have to know how different types behave.

Link to comment
Share on other sites

Byte is a really good one to use, if you have a base of short ammount of numbers being presented. Its the fastest way to process. But as you said many people perfer to use int because of the range.

 

You sure in scar that Longint is 32 signed? long is usually 64 signed thats weird.

 

Than again we are talking about pascal now :P

Link to comment
Share on other sites

Byte is a really good one to use, if you have a base of short ammount of numbers being presented. Its the fastest way to process. But as you said many people perfer to use int because of the range.

 

You sure in scar that Longint is 32 signed? long is usually 64 signed thats weird.

 

Than again we are talking about pascal now :P

 

http://www.delphibasics.co.uk/RTL.asp?Name=LongInt

 

The article states that LongInt is guaranteed to be a 32-bit Integer in Delphi, however, Integer is always 32-bit. "NativeInt" was added to Delphi as Integer datatype which changes along with the system architecture.

Link to comment
Share on other sites

The thing with a program working as it needs to and a program with lifetime stability are two totally different objects to look at. Of course we can write code and make it work. The question after the code is written is, "Is this the best way to go about it?" "Is there any overkill for the processor?" "Is the limetime management the best I can get it"

Link to comment
Share on other sites

There we go, as I said I wasnt too keen on how delphi and scar scripting and programming works. everywhere is different to a bit. Anyways After seeing that I think Shortint is your best bet. 8 signed,

"The ShortInt type is the smallest form of signed integer, occupying 8 bits (1 byte) of storage.

 

It supports only the integers from -128 to 127. "

 

Unless you need more, this would be the best practice for Application Lifetime

Link to comment
Share on other sites

I think the biggest issue with the programming languages of today are that. most languages are the same per say of how types works and the memory and process of each. The type names and how they are referenced are different in just about 100% of every programming language compared to another.

 

I wish the world of programming could just all get along, saying this though we as programmers have a great thing being given to us with .net. Before programming languages were really hard to talk to, framework as such now helps the communication process between each much available together combined. Its in the CCL which is why the framework is one of the best to use now. c,c++,c#,vb,.net,ajax,java so many other languages can now communicate together in a working enviroment. Not saying it is easy to accomplish such as "just throw the code in" but it is. This is why I love the .net framework. Not to mention its future for working together of languages.

 

---------- Post added at 03:59 AM ---------- Previous post was at 03:58 AM ----------

 

Didnt see byte in there :P ya ur right.

Link to comment
Share on other sites

http://www.delphibasics.co.uk/ Most stuff you can use in SCAR is the same as in Delphi.

 

Most stuff true, but most script users and inexperienced script writers don't know and end up doing stuff with them or use preexisting stuff that is made with the wrong type and something goes horribly wrong.

 

If you are writing some specific method or something and know what you're doing then it's not a problem.

 

But if I started using different types of strings and bytes in OSI wherever possible it would cause mass chaos.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
  • Create New...