Author Topic: General scripting help  (Read 1800 times)

0 Members and 1 Guest are viewing this topic.

Offline TAMAman

  • Major(1)
  • Posts: 12
General scripting help
« on: May 14, 2008, 09:57:47 pm »
Hey guys,

I am fluent in C++, and Pascal doesn't look too hard to pick up. I've read the official scripting guide and the Pascal tutorial thing, but there are some things that I'm still not too sure about.

In the scripting guide, it doesn't give a very good idea of syntax. I could have just missed it, but in C++, logic works like this:

if (thisvar == 1)

if (thisvar)

if (!thisvar)

What would be the equivalents of those if statements in Pascal? Also I'm not sure about the official scripting API because it seems to be missing some functions like copy() and a few other random ones that I've seen around. Is there an official scripting IRC help chat? If anyone out there feels like helping, I'd appreciate an IM chat just for questions. Don't worry, I'm no scripting newb...I just want to learn the syntax/tips/tricks.

Thanks guys.
My DM server: tama.servegame.com (default port)

Offline Toumaz

  • Veteran
  • *****
  • Posts: 1904
Re: General scripting help
« Reply #1 on: May 14, 2008, 11:10:45 pm »
if (thisvar == 1)
if (thisvar)
if (!thisvar)
if thisvar = 1 then [begin ... end]
if thisvar then [begin ... end]
if not thisvar then [begin ... end]

Is there an official scripting IRC help chat?
#soldat.devs on QuakeNet.

Offline TAMAman

  • Major(1)
  • Posts: 12
Re: General scripting help
« Reply #2 on: May 16, 2008, 09:19:48 pm »
Alright cool. Where can I find help on Copy()? And how about assignment, like =, /=, +=?

Are there any string functions? Like strins, strmid?

What I'm trying to do is code a command that has two parameters, one is a reason. The reason param is more than one word, so I figure I use GetPiece in a loop to add all the words it finds onto a temp. string.
« Last Edit: May 16, 2008, 09:25:55 pm by TAMAman »
My DM server: tama.servegame.com (default port)

Offline Toumaz

  • Veteran
  • *****
  • Posts: 1904
Re: General scripting help
« Reply #3 on: May 16, 2008, 11:43:31 pm »
Copy is copy(string, start, length) (I don't know if this is what you're really after), and would be what you're looking for to use instead of strmid. strins is Insert(text, string, index). There's Delete() too, but I don't know its arguments by heart. strlen is Length(string).

Assignments are done using :=, and the C equivalent of division or multiplication is x := x / y. For addition and substraction you'll have to use that method too, or inc()/dec().

As for the command, I'd just suggest you to use Copy and Length to copy it directly instead of splitting it up like that.
« Last Edit: May 16, 2008, 11:45:11 pm by Toumaz »

Offline TAMAman

  • Major(1)
  • Posts: 12
Re: General scripting help
« Reply #4 on: May 17, 2008, 01:21:19 am »
Ahaaaaa.
Copy is what I'm looking for. Thanks for the help. Is there a full API for this scripting core? Aka a complete list of scripting functions so I don't have to keep asking? The Encense one doesn't seem to include all of them.
My DM server: tama.servegame.com (default port)


Offline Toumaz

  • Veteran
  • *****
  • Posts: 1904
Re: General scripting help
« Reply #6 on: May 17, 2008, 01:28:16 am »
Ahaaaaa.
Copy is what I'm looking for. Thanks for the help. Is there a full API for this scripting core? Aka a complete list of scripting functions so I don't have to keep asking?

None that I know of (there might be some help available at devs.soldat.pl, but I'm not entirely sure). I'm afraid you'll have to resort to Google and the links provided in the EnEsCe scripting help for that. There's always the crude method of looking at other's people's scripts, too.

Offline DorkeyDear

  • Veteran
  • *****
  • Posts: 1507
  • I also go by Curt or menturi
Re: General scripting help
« Reply #7 on: May 17, 2008, 07:14:31 am »
He did give a list a while ago:
Code: [Select]
function inttostr(i: Int64): string;
function inttostr(i: Integer): string;
function strtoint(s: string): Longint;
function strtointdef(s: string; def: Longint): Longint;
function copy(s: string; ifrom, icount: Longint): string
function pos(substr, s: string): Longint;
procedure delete(var s: string; ifrom, icount: Longint);
procedure insert(s: string; var s2: string; ipos: Longint);
function getarraylength: integer;
Function StrGet(var S : String; I : Integer) : Char;
procedure StrSet(c : Char; I : Integer; var s : String);
Function WStrGet(var S : WideString; I : Integer) : WideChar;
procedure WStrSet(c : WideChar; I : Integer; var s : WideString);
Function StrGet2(S : String; I : Integer) : Char;
Function AnsiUppercase(s : string) : string;
Function AnsiLowercase(s : string) : string;
Function Uppercase(s : string) : string;
Function Lowercase(s : string) : string;
Function Trim(s : string) : string;
function Length(s : string) : Integer;
procedure SetLength;
function Low: Int64;
function High: Int64;
procedure Dec;
procedure Inc;
Function Sin(e : Extended) : Extended;
Function Cos(e : Extended) : Extended;
Function Sqrt(e : Extended) : Extended;
Function Round(e : Extended) : Longint;
Function Trunc(e : Extended) : Longint;
Function Int(e : Extended) : Extended;
Function Pi : Extended;
Function Abs(e : Extended) : Extended;
function StrToFloat(s: string): Extended;
Function FloatToStr(e : Extended) : String;
Function Padl(s : string;I : longInt) : string;
Function Padr(s : string;I : longInt) : string;
Function Padz(s : string;I : longInt) : string;
Function Replicate(c : char;I : longInt) : string;
Function StringOfChar(c : char;I : longInt) : string;
function Unassigned: Variant;
function VarIsEmpty(const V: Variant): Boolean;
function Null: Variant;
function VarIsNull(const V: Variant): Boolean;
function VarType(const V: Variant): TVarType;
procedure RaiseLastException;
procedure RaiseException(Ex: TIFException; Param: string);
function ExceptionType: TIFException;
function ExceptionParam: string;
function ExceptionProc: Cardinal;
function ExceptionPos: Cardinal;
function ExceptionToString(er: TIFException; Param: string): string;
function StrToInt64(s: string): int64;
function Int64ToStr(i: Int64): string;
function SizeOf: Longint;
function IDispatchInvoke(Self: IDispatch; PropertySet: Boolean; const Name: String; Par: array of variant): variant;

function GetTickCount():cardinal
I added GetTickCount at the bottom

Offline TAMAman

  • Major(1)
  • Posts: 12
Re: General scripting help
« Reply #8 on: May 18, 2008, 01:29:11 pm »
Oh awesome, thx again.

Date Posted: May 17, 2008, 02:11:14 pm
Okay another question: What is the equivalent of the return statement in Pascal? Also, is there any function to check if a player is connected, by ID?
My DM server: tama.servegame.com (default port)

Offline Toumaz

  • Veteran
  • *****
  • Posts: 1904
Re: General scripting help
« Reply #9 on: May 18, 2008, 01:36:34 pm »
What is the equivalent of the return statement in Pascal?
Unless I'm mistaken, in order to set the return value of a function, simply assign a value to result. Then , optionally, exit.

Also, is there any function to check if a player is connected, by ID?
GetPlayerStat(ID, 'active')

Offline TAMAman

  • Major(1)
  • Posts: 12
Re: General scripting help
« Reply #10 on: May 18, 2008, 01:57:19 pm »
What is the equivalent of the return statement in Pascal?
Unless I'm mistaken, in order to set the return value of a function, simply assign a value to result. Then , optionally, exit.
Also, is there any function to check if a player is connected, by ID?
GetPlayerStat(ID, 'active')

Okay great. Thanks once again.
My DM server: tama.servegame.com (default port)