SRL Archive - OSR Intermediate Scripting Tutorials

Tips To improve your Script


Bad Boy JH

2010-12-08 22:21:16

This is going to be a list of little tips and tricks to help you increase your scripts readability, and most will help you script.

Tip 1 : Constants
Constants are my best friend when I script.
When you want to open a bank, and each player has a different bank location, you might use
R_OpenBankBoth(Players[CurrentPlayer].Strings[0]);
I have at the top of my script
const
whichBank = 0
so when I use it in my script, I can use
R_OpenBankBooth(Players[CurrentPlayer].String[WhichBank]);
This helps me remember which variable I am using, and to not accidentaly use one I already have used. It also helps people read your script.

Tip 2 : function Load____(Which____: Integer)
When I write any script, I use functions like, LoadPath, LoadDTM, and these basically have all the DTMs stored in 1 function, and I can call them quickly, without pasting the code everywhere. If something changes, its easy to find and change, without searching through my code.
Also, rather than using Integers eg
LoadDTM(0)
combine with Tip 1 and use
LoadDTM(IronOre).

At this stage, this will do me, If anyone else has input, add it in.

Death12652

2010-12-10 00:08:01

Nice tutorial I used to use constants a lot. Switched over to another method I like but I still use constants in my scripts. Good job.