DragonPrime - LoGD Resource Community
Welcome Guest
  • Good evening, Guest.
    Please log in, or register.
  • September 15, 2019, 07:03:34 PM
Home Forums News Downloads Login Register Advanced Search
* * *
DragonPrime Menu
Resource Pages

Pages: [1] 2 3   Go Down
Author Topic: Coding Tips  (Read 25587 times)
0 Members and 1 Guest are viewing this topic.
Mod God
Offline Offline

Posts: 5484

View Profile WWW
« on: April 29, 2004, 04:55:45 PM »

I'm sure the 'pros' here have seen some pretty raunchy creations, and grimace everytime they observe some common coding mistakes.  

I'd like to develop an area of this site that will act as a bit of a 'How to', or 'What not to do'.  

Give me your thoughts and/or ideas, and I'll compile them all together into a usable page...

Play the latest beta version here on DragonPrime
« Reply #1 on: April 29, 2004, 04:58:54 PM »

If you get a parse error, its probably because you missed either a paranthesis somewhere, or a squiggly bracket (is there a proper name for {}?).

If you output an html link, you need a blank addnav going to the same place.

If you get a white page with html displayed, its probably because a sql query is wrong somehow.

Those are the big/common ones from my experience. Wink
« Reply #2 on: April 29, 2004, 05:33:19 PM »

I grimace every time I open a module to edit it, and I find out that the author wrote it in Wordpad.  Wordpad-formatted text makes me cry


In the spirit of the other thread that's going on here, lines should be 80 characters long.  Maybe 90.  Thousands of characters long is right out.
« Reply #3 on: May 12, 2004, 02:17:33 PM »

also, although it's not such a big deal, tabbing is extremely helpful when you're trying to understand code.

I indent all things within {}'s, it makes it much easier to follow especially if the code has a lot of if and else statements.  It also makes it much easier to find mistakes that way.
« Reply #4 on: May 13, 2004, 07:09:20 AM »

I'm not a tab guy, but I am a spacer...chomping up 8 spaces every time I get to a new codeblock gets to be wasteful when I'm trying to stick to 80 columns, and I've been so ingrained to indent by 3 spaces after writing my own stuff for so long that it works for me - 3 spaces is enough to show the indentation and separate it from the preceeding line, but not so much that 5 blocks in, I'm wasting half of my screen.
« Reply #5 on: May 13, 2004, 10:28:56 AM »

mmm, I should probably note that I use Crimson Editor, and I have tabs set to be two spaces, so 5 layers down it still doesn't take up much of the page, but it does make everything very easy to understand.

I use tabs because some people like more space, some people like less, and if you're using a half decent program to write code in you can tell it how wide a tab is Smiley
« Reply #6 on: May 13, 2004, 12:48:05 PM »

I usually space it out 3 or have tab set to 3 in Quanta.  Of course for longer statements... that's what word wrap is for! ,(^^)'
« Reply #7 on: July 18, 2004, 02:30:58 AM »

2 tips from me, mybe useful

1) comment your }
if (!$i) {
} //if
makes it much easier to find missing } (-->avoid pharse errors)

2) use an editor with syntax highligthning, use tabs for structured code
(e.g. quanta, ulatredit....)

3) Have fun

« Last Edit: July 18, 2004, 02:31:54 AM by SkyPhy » Logged
Old Dog
Mod God
Offline Offline

Posts: 1047

LoGD Buff!

View Profile WWW
« Reply #8 on: January 23, 2005, 07:12:48 PM »

I find that the numerous php script websites to be very useful - there already exists tons of scripts already made and can easily be adapted to the the LoGD game - there is no sense in re-inventing the wheel.

Having an offline server with the LoGD game installed is one of the best tips going! (thanks Talisman!!)  You easily can write your game scripts and test them offline for bugs and faults. Doing so also allows you to make real time corrections and without disrupting a live online game and upsetting players. You easily find all the bugs and any code errors that may exist and able to test to your hearts content, ALL before uploading your mod to dragonprime and letting the chips fall where they may and abusing others who have hopes that your code is stable enough to run on a live server. Using a free program such as EASYPHP is all you need to install a server on your home pc and make it your LoGD workstation and test server.

It was already mentioned and I agree, using a php editor with syntax highlighting is the way to go - I like Crimson Editior cause it does php and the css files both needed for LoGD and it has the capablity to do so much more, ....and its free!

« Reply #9 on: January 23, 2005, 08:55:56 PM »

I haven't tried Crimson Editor, but I love UltraEdit.

One of my favorite features is the Compare utility.
Mod God
Offline Offline

Posts: 3598

short, sweet and to the point

View Profile
« Reply #10 on: January 23, 2005, 09:11:03 PM »

:slips quietly out of her shadows

another place to look for programs to use for checking and/or editing code is this thread here:

« Last Edit: January 23, 2005, 10:06:38 PM by Elessa » Logged

Uuma ma ten rashwe, ta tuluva a lle

Play the latest beta version here on LoGD DragonPrime - Axebridge
« Reply #11 on: September 02, 2005, 01:59:26 AM »

Me uses "Notepad++" which has perfect highlightning!

No more searching for the ending bracket!

When you put your mouse over a bracket it shows you the ending bracket of it!

codign tips...

Comment all!
Always say what your code will do!

Give an extra large description for a script

Make clean code - with tabs and so sone... it's been said already Wink

Try to sort your code - don't throw all your parts of code in a .php-file... make blocks that everyone knows what belongs to what...

(Sry for my "good" English ^^' )
« Reply #12 on: August 18, 2006, 02:00:31 PM »

 I find when trying to learn something new the best way to do it is find somewhere in the game that does almost what you wanna do and take that code and place it into it's own test file.Then add and delete things from it so you can see how it works.  Once you have a basic understanding of how the code is accomplishing what you wanna do try modifying it to fit your needs.  After doing this you should have a much better understanding of the mechanics of what you wanna accomplish.
Mod God
Offline Offline

Posts: 1544

Dfly... you know, as in DaveFly

View Profile
« Reply #13 on: August 18, 2006, 03:27:44 PM »

I thought I would put in a couple of things I've learned from the "what not to do" file...

1.  Try to "close your lines".  This is important for translation of your module:

output("This is how I used to write text
   until I learned that it made
   it difficult for translation.");

Instead, just do it all in one line or break it up:
output("This is how I used to write text until I");
output("learned that it made it difficult for translation.");

2.  Try to give your variables helpful names:

is not so useful

instead, name your variable a little smarter:

3.  Remember that you need to have:
 global $session;
in a function if you are going to change a $session['user']['whatever']

function supercool_givegold(){
    global $session;

4.  Name your functions with your module name in it:

Not Cool:
function gold(){

function modulename_gold(){

5.  Remember when to use == and when to use =

In general, inside an if() statement, you are checking with ==
if ($important==1)

If you are doing something with translate_inline, use ==

If you are changing or re-setting a variable, use =


Check out my Last Module:
The Dragon Eggs Expansion

About my Retirement:

See my complete module list here:
« Reply #14 on: August 18, 2006, 04:10:00 PM »

the tips are ok, but for 1.x.x


 Support for version 0.9.7 (Obsolete)  |  v0.9.7 Technical Help

<--forum topic ^^
Pages: [1] 2 3   Go Up
Jump to:  

DragonPrime Notices
Please take the time to read the FAQ and browse the DragonPedia

Support Us
No funds raised yet this year
Your help is greatly appreciated!
Recent Topics
DragonPrime LoGD
Who's Online
90 Guests, 0 Users
Home Forums News Downloads Login Register Advanced Search