General Question

Mr_Grimm's avatar

How to make a custom script?

Asked by Mr_Grimm (412points) December 16th, 2010

I’m wondering how to make a custom script. This can pertain to .exe* or .bat* that have to do with commands the computer to do something. Or game scripts. Like scripts that make explosions and stuff like that, or make entities, or props change colors. I’ve observed that people have done these things for games like half-life 2 deathmatch, or Garrys mod. I have been downloading scripts and skins that have been made. I’m assuming they made these scrips and skins from scratch in code format. I would just like to know the secret to these projects. if you have any helpful hints.. please post them here. Please help! thank you!

Observing members: 0 Composing members: 0

3 Answers

Vortico's avatar

A script can pertain to a file with code in any programming language.

A .bat file is a list of Windows console commands to rename/move a batch of files or run a batch of programs. However, a script in a game like Half Life 2 will most likely be in the C programming language or a custom-made scripting language by the makers of the game. If you would like to make your own scripts, a section of the game manual or an online source for that game may help you. Each game has its own specific commands, so it’s a matter of learning the syntax and keeping a close reference to the parameters of each command.

anartist's avatar

bat [batch] files are rarely used nowadays. They were a simple set of DOS commands to be done in sequence from the early days of computing and would be unlikely to do what you are looking for.

If you want to try things in some simpler scripting languages, like JavaScript or PHP, get a syntax list and download some free scripts you like and start by modifying them. That will help you get comfortable with the process. Flash Action Script you can create more easily using the Flash program. This is how “script kiddies” [mediocre hackers] learn.

this is not as complex as trying to take up programming in C

koanhead's avatar

First, you need to ensure that the interpreter for your desired scripting language is present on the system. For gaming scripts this will likely be Python or Lua. You will not be scripting in C; C is a compiled language and scripts are interpreted by definition, though the C and Bourne shells have similar syntax.
Once you know that the correct interpreter is present, you can go find a good tutorial on the Web. There are good Python references and tutorials available, I can’t speak for Lua.
If you use Windows, you will want to install and learn either Powershell or MINGW. MINGW is Minimal GNU for Windows and will give you useful tools. Both Macintosh and Linux come with powerful scripting environments by default. I don’t know any Applescript so I won’t address it here.
The most commonly used shell in Linux/UNIX these days is bash. Bash is both the command-line environment and the script interpreter. It’s powerful and flexible.

To write a script, just fire up your favorite text editor. Scripts are just plain old text files.
At the beginning of the script you will write a header. In UNIX this looks something like:

#! /bin/bash

The “hash bang” at the beginning tells the shell that the file is, in fact, a script. The following path tells the shell where to find the correct interpreter to run the script (in this case, bash- but it could just as easily be ”#! /usr/bin/python” or something).
After the header comes the code. Every time you make a change, you need to save the file in order to see it work. You can keep the file open while debugging though.
In order to see your script in action, just type “sh [filename]” where [filename] is whatever you called the script.
It worked similarly in DOS and probably also in the Windows command line. The interpreter is called “command.com”, the scripts are called “batchfiles” and given the suffix .bat. You don’t need to add the header in .bat files AFAIK.
*.exe files are generally compiled binaries and not scripts. It may be possible to give a script that suffix and get it to work but I doubt it.

The interpreter for Javascript is just your friendly neighborhood web browser. Javascript can be embedded in webpages or written separately and included in webpages using <script src=“foo”>. You need to know HTML to use Javascript effectively.
The interpreter for PHP is a web server. If you don’t have a web server installed, PHP is not very useful. There is a command line interpreter for PHP, and it works, but I would not recommend its use in this way.

Answer this question

Login

or

Join

to answer.

This question is in the General Section. Responses must be helpful and on-topic.

Your answer will be saved while you login or join.

Have a question? Ask Fluther!

What do you know more about?
or
Knowledge Networking @ Fluther