Author Topic: Scripting tips  (Read 1605 times)

Can you guys post some scripting tips, don't worry I know a little about weapon scripting. I edit weapon_gun alot

Some tips:
Proper indentation is key.
On the next line atfter a {, add a tab, on the line where a } is included, remove a tab.

Stuck? Rip apart another mod and find some useful things.

Need to find a command? Start up a game. In the console, press space then keep hitting tab till you find something interesting. End the thing with ();
There's a good chance it will give you an error saying incorrect number of arguements. Use this error to see how you should set up the function.
For finding client functions, type localClientConnection.dump();
For finding player functions, type localClientConnection.player. dump();
And so on.

Check coding help.
There may be someone asking the same question.
Check the stickies. They are extremely useful.
Can't find what you're looking for? Make a topic about a specific code.

Some tips:
Proper indentation is key.
On the next line atfter a {, add a tab, on the line where a } is included, remove a tab.

Stuck? Rip apart another mod and find some useful things.

Need to find a command? Start up a game. In the console, press space then keep hitting tab till you find something interesting. End the thing with ();
There's a good chance it will give you an error saying incorrect number of arguements. Use this error to see how you should set up the function.
For finding client functions, type localClientConnection.dump();
For finding player functions, type localClientConnection.player. dump();
And so on.

Check coding help.
There may be someone asking the same question.
Check the stickies. They are extremely useful.
Can't find what you're looking for? Make a topic about a specific code.

can you teach me how to make server.cs

If you're making weapons, try to make one that does something original and new. Another generic slightly-inaccurate machine gun will not really improve the selection.

If you're making weapons, try to make one that does something original and new. Another generic slightly-inaccurate machine gun will not really improve the selection.

Thanks for the note, but i want to know the basics of making a weapon.

can you teach me how to make server.cs
For scripting in Blockland, they are simply text files with a different extension (.cs, .txt are extensions). So, you open up notepad, start making some code. Save As... Then in the filename box, put "server.cs" WITH the "
If you have "Hide extensions for known filetypes" turned off, you could just rename it to server.cs afterwards. Do not do this if "Hide extensions for known filetypes" is turned on, or else it becomes server.cs.txt
For a program. I'd prefer Notepad.

For scripting in Blockland, they are simply text files with a different extension (.cs, .txt are extensions). So, you open up notepad, start making some code. Save As... Then in the filename box, put "server.cs" WITH the "
If you have "Hide extensions for known filetypes" turned off, you could just rename it to server.cs afterwards. Do not do this if "Hide extensions for known filetypes" is turned on, or else it becomes server.cs.txt
For a program. I'd prefer Notepad.

kthnx, now when i shoot it the bullets go straight. How do i make the bullets not shoot straight

Check the shotgun script. It will have a scatter somewere in there.

Check the shotgun script. It will have a scatter somewere in there.

i wont know where to check

Code: [Select]
function YourGunNameImage::onFire(%this,%obj,%slot)
{
%projectile = %this.projectile;
%spread = NUMBER;   //Make this somewhere between 0.1(maybe higher, high spread) to 0.01(low spread)
%vector = %obj.getMuzzleVector(%slot);
%objectVelocity = %obj.getVelocity();
%vector1 = VectorScale(%vector, %projectile.muzzleVelocity);
%vector2 = VectorScale(%objectVelocity, %projectile.velInheritFactor);
%velocity = VectorAdd(%vector1,%vector2);
%x = (getRandom() - 0.5) * 2 * 3.1415926 * %spread;
%y = (getRandom() - 0.5) * 2 * 3.1415926 * %spread;
%z = (getRandom() - 0.5) * 2 * 3.1415926 * %spread;
%mat = MatrixCreateFromEuler(%x @ " " @ %y @ " " @ %z);
%velocity = MatrixMulVector(%mat, %velocity);
%p = new (%this.projectileType)()
{
dataBlock = %projectile;
initialVelocity = %velocity;
initialPosition = %obj.getMuzzlePoint(%slot);
sourceObject = %obj;
sourceSlot = %slot;
client = %obj.client;
};
MissionCleanup.add(%p);
return %p;
}

Replace NUMBER with how much you want it to spread, and YourGunNameImage with your gun's image name.

heres the script i'm using, put it in weapon_gun

http://www.mediafire.com/download.php?2znzn0jzlom


it doesnt overwrite anything, i made sure of it
« Last Edit: November 01, 2008, 01:48:47 PM by Jannet »

Thanks for the note, but i want to know the basics of making a weapon.

Here's an idea take a unique weapon, say like the spear-rifle, copy the .zip, rename it, and then mess around; by maybe changing the projectiles, the amounts, or the damage type, until you get something new. Then make sure that it is nothing like anyone elses weapons, test it on a friends server, get some feedback, change some stuff until its good, and then release it.

weapongunImage should be gunImage.
Edit: And don't release, use this as practice.

weapongunImage should be gunImage.
Edit: And don't release, use this as practice.

THANKS, i wont release dont worry

Thanks, I wont release don't worry
Please don't. Also fixed.