Log in

View Full Version : Scripting Question



NEWTOSIMBA
01-08-2012, 12:53 AM
Hello all,

Just a few questions about this programming language that the guru's on this site will know:

- When declaring variables, at what point (local or global) is good placement for a variable being used by multiple functions?

- Is there any built in functions that sort a string and split it according to a certain character. (In VB.Net it is variable.split(","))

- Is there a variable that holds a x and y coordinate? Or does everyone just make two separate integers?

- Is there a command that edits the speed between a right click and a choose option?

- What is the proper syntax to add one to a integer variable?
(In VB.Net it is variable += 1)

I did search the forum for answers and for questions 1 & 3 there was answers but I am still unclear and would appreciate some insight from any fellow user that is willing to help.

Thanks,
Newtosimba

PatDuffy
01-08-2012, 12:57 AM
Hello all,

Just a few questions about this programming language that the guru's on this site will know:

- When declaring variables, at what point (local or global) is good placement for a variable being used by multiple functions?

- Is there any built in functions that sort a string and split it according to a certain character. (In VB.Net it is variable.split(","))

- Is there a variable that holds a x and y coordinate? Or does everyone just make two separate intergers?

- What is the proper syntax to add one to a interger variable? (In VB.Net it is variable += 1)

I did search the forum for answers and for questions 1 & 3 there was answers but I am still unclear and would appreciate some insight from any fellow user that is willing to help.

Thanks,
Newtosimba

-

1. It is better to declare most variables locally because they take less memory use. Global variables are okay to have, but should not be overdone.

2. There is a function for that, but I cannot remember what it is...sorry

3. a TPoint hold an (x,y) position as a point.

4. Inc(Variable) increased by 1, there are also similar functions that can increase a variable by other numbers than 1

E: GF Dgby :p

Dgby714
01-08-2012, 12:57 AM
Hello all,

Just a few questions about this programming language that the guru's on this site will know:

- When declaring variables, at what point (local or global) is good placement for a variable being used by multiple functions?

- Is there any built in functions that sort a string and split it according to a certain character. (In VB.Net it is variable.split(","))

- Is there a variable that holds a x and y coordinate? Or does everyone just make two separate intergers?

- What is the proper syntax to add one to a interger variable? (In VB.Net it is variable += 1)

I did search the forum for answers and for questions 1 & 3 there was answers but I am still unclear and would appreciate some insight from any fellow user that is willing to help.

Thanks,
Newtosimba

-

Global, but only if absolutely necessary.

Explode(del, str: string): TStringArray;

TPoint = record X, Y: LongInt; end;

Inc(x); IncEx(x, 1);

E: Ninja'd

BraK
01-08-2012, 01:01 AM
When declaring variables, at what point (local or global) is good placement for a variable being used by multiple functions?

You could pass the variable using the Parameters of a function. Generally you'd like to avoid Globals. Also you could house all the functions using the same variable inside a function or procedure and have those have a local variable to pass around. An idea for this would be making a mainloop and using a local variable for the Mainloop function.


Is there a variable that holds a x and y coordinate? Or does everyone just make two separate intergers?

You can make a TPoint Variable. All a Tpoint is is x, y coordinates. you can convert them both ways using these ways.



Var
TP: Tpoint;

TP := Point(x, y);

// using the tpoint.

X := TP.X;
Y := TP.Y;




What is the proper syntax to add one to a interger variable?

You can use Inc(Var); or IncEx(var, Amount); the amount is the amount to increase by.


E: Double Ninja'd

Dgby714
01-08-2012, 01:03 AM
You could pass the variable using the Parameters of a function. Generally you'd like to avoid Globals. Also you could house all the functions using the same variable inside a function or procedure and have those have a local variable to pass around. An idea for this would be making a mainloop and using a local variable for the Mainloop function.



You can make a TPoint Variable. All a Tpoint is is x, y coordinates. you can convert them both ways using these ways.



Var
TP: Tpoint;

TP := Point(x, y);

// using the tpoint.

X := TP.X;
Y := TP.Y;




You can use Inc(Var); or IncEx(var, Amount); the amount is the amount to increase by.


E: Double Ninja'd

You is slow! Tho much more helpful.

Dgby714
01-08-2012, 01:05 AM
- Is there a command that edits the speed between a right click and a choose option

Add a Wait(TimeInMS); in between the procedure calls. TimeInMS is how long to wait for.

NEWTOSIMBA
01-08-2012, 01:32 AM
Holy $H17, I am actually stunned and overwhelmed by this community. Thank you all so much everything is clear and you can expect my first script within the week. ;)

PatDuffy
01-08-2012, 01:34 AM
Holy $H17, I am actually stunned and overwhelmed by this community. Thank you all so much everything is clear and you can expect my first script within the week. ;)

Yes we are quite helpful, almost in an annoying way :p

Don't rush your learning, it's better to take your time and understand everything than to copy/paste things just to get a "script done".

NEWTOSIMBA
01-08-2012, 01:42 AM
Yes we are quite helpful, almost in an annoying way :p

Don't rush your learning, it's better to take your time and understand everything than to copy/paste things just to get a "script done".

O not to worry my script will be original. I have previous programming knowledge in other languages, but the syntax is pretty different. Thankfully my algorithms are interchangeable :)

Dgby714
01-08-2012, 01:44 AM
O not to worry my script will be original. I have previous programming knowledge in other languages, but the syntax is pretty different. Thankfully my algorithms are interchangeable :)

What is with the ridiculous username? If you request a change (http://villavu.com/forum/showthread.php?p=772114) they will prob give to to you...

NEWTOSIMBA
01-08-2012, 01:56 AM
What is with the ridiculous username? If you request a change (http://villavu.com/forum/showthread.php?p=772114) they will prob give to to you...

Well tbh, I was just going to come here to leech but after reading through each section and reading the way everyone interacts, I really liked it. I guess you could say I came for the scripts but stayed for the community.