Gamestudio Links
Zorro Links
Newest Posts
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (AndrewAMD), 1,187 guests, and 3 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
just a small tip #106453
01/12/07 08:35
01/12/07 08:35
Joined: Aug 2004
Posts: 1,305
New York
PrenceOfDarkness Offline OP
Serious User
PrenceOfDarkness  Offline OP
Serious User

Joined: Aug 2004
Posts: 1,305
New York
Sorry this isn't really a contribution rather a small tip for newbies learning to script.

After a while your code can get complicated. In my current project I have just a little over 1300 lines of code so far. Every time I start working on something new I keep running into errors. The 2 main problems are: 1) sometimes my other functions/strings/variables might interfere 2) after editing over and over and over you start screwing the code up in ways you can't even see...

Here is the tip.. When adding a new feature/function or whatever, and your running into glitches/errors, try grabbing the function or part of the code that is giving you a hard time and simply make a new test.wmp and change your function name to main. Now run the project (make sure you include the variables/strings/pointers and so on). Now that you have it isolated you might find that the code works fine. If this is so then look at the rest of the code in your original project and find the problem. On the other hand, if your lucky you'll find the problem right away... Here is an example that drove me nutz for about 2 hours (I know it wont seem like a big deal now because it'll probably be alot easier to spot).

Find the problem with this script:

Code:
 var vtester = 9000.493;
string temp_str2;
string after_str;
var data_txt;
function main
{
data_txt = file_open_read("data.txt");
file_str_read(data_txt,temp_str2);

str_cpy(delimit_str,")");
file_str_read(data_txt,after_str);
str_cpy(delimit_str,",");
file_close(data_txt);
vtester = str_to_num(temp_str2);
vtester += 1;
str_for_num(temp_str,vtester);
str_cat(temp_str2,",");
str_cat(temp_str2,after_str);

data_txt = file_open_write("data.txt");
file_str_write(data_txt,temp_str2);
file_close(data_txt);
}



well did you find it? If you did great job. If you didn't look at this line str_for_num(temp_str,vtester); When i ran this into my isolated test.wmp the engine found the problem right away. I didn't define temp_str! However, I obviously had defined it for a different part of my project and the engine wasn't detecting it before.

After changing that line to str_for_num(temp_str2,vtester); everything worked perfectly. Another problem with my script is obviously the names I choose for my strings. I get lazy sometimes when I try something new and tell myself I'll go back and think of a better name later. This has in turn caused me a lot of pain.

Sorry if this was a big disappointment to anyone but I just aint going to giving away my top secret World of Warcraft 7 script just yet no matter how much u all beg lol.

edit: Oh and just 1 other thing i'd like to point out. SAVE YOUR FILES OFTEN. What i mean is make backup copies, in 2 ways.
1st in your work folder it's self, add a "backed up" folder. Periodically make a new folder in that folder and name it the date (011207 is fine). Inside that folder copy all the files to it (i like to just add the files/scripts i change). This is good because if you ever screw up to much you can always go back to an older date and start from there. You might also regret deleting something you could have used.
2nd, make copies of your work to a cd, or usb flash drive, or an SD card (or if ur crazy like me... every computer in ur house, every flash usb you own and SD card ). Remember you can only back up your work this way and not 3dgamestudio (the license says so, sorry).

Last edited by PrenceOfDarkness; 01/12/07 09:33.

"There is no problem that can't be solved with time and determination." -me
prenceofdarkness for instant messages on AIM.

Looking for a model designer
PLEASE, SEND ME A PRIVATE MESSAGE OR EMAIL IF YOU'RE INTERESTED.
Re: just a small tip [Re: PrenceOfDarkness] #106454
01/12/07 12:00
01/12/07 12:00
Joined: Mar 2006
Posts: 2,758
Antwerp,Belgium
frazzle Offline
Expert
frazzle  Offline
Expert

Joined: Mar 2006
Posts: 2,758
Antwerp,Belgium
It's nice introduction for debugging with strings I would say but your methode can be used for many other things so that's quite helpfull
You may consider writing a tutorial about debugging
Btw, I always write my new functions and action in a test level where it will be totaly debugged before adding it to the entire script but thxn for pointing it out here and offcourse saving your files is very very important, even make back ups from it ^^

Cheers

Frazzle


Antec® Case
Intel® X58 Chipset
Intel® i7 975 Quad Core
8 GB RAM DDR3
SSD OCZ®-VERTEX2 3.5 x4 ; HD 600 GB
NVIDIA® GeForce GTX 295 Memory 1795GB
Re: just a small tip [Re: frazzle] #106455
01/15/07 03:23
01/15/07 03:23
Joined: Aug 2004
Posts: 1,305
New York
PrenceOfDarkness Offline OP
Serious User
PrenceOfDarkness  Offline OP
Serious User

Joined: Aug 2004
Posts: 1,305
New York
Let me go ahead and give another great debuging idea then lol.

If your dealing with alot of strings and or variables in a single function or even alot of different functions, make a panel show all the values of the variables and strings your dealing with (make sure the panel displayed the updated results) then add a while loop after every major part of your script that waits until a button is press (ex. space bar) Before it continues while displaying all the strings and variables on the screen along with a number to indicate what line your up to (this can be done by simply having a variable named lineNumVar and pasting lineNumVar += 1; to the start of every line. If you do major jumps simply adjust lineNumVar to the appropriate line before continueing).

Now go through your code and press the space bar until you see something you didn't expect. The best way to do this is by printing out the peace of code and have it right next to you so you can quickly look to see if everything is checking out.

Start general then work your way down for the best results and to save time.

If a function calls 5 other functions update the strings and vars only before and after every function is called. Then you'll know which function is screwing up. Then go to that function and do the same thing.

This method is very thorough but very timw consuming. However I have yet to not find the bug using this meathod.

edit: Oh and one way to prevent bugs is actually simple. If your a fast typer and your copying a short command or sets of commands, you might want to just type it out. The reason for this is because if your copying and pasting but need to make a small change, you might forget to do so and create a tough problem to find later on. This might sound crazy and stupid, but after a while... say 3 hours of scripting non-stop, the brain starts to skip up on you. Believe me, all this is from personal experience. I hope it's helped a few people.




Last edited by PrenceOfDarkness; 01/15/07 09:36.

"There is no problem that can't be solved with time and determination." -me
prenceofdarkness for instant messages on AIM.

Looking for a model designer
PLEASE, SEND ME A PRIVATE MESSAGE OR EMAIL IF YOU'RE INTERESTED.
Re: just a small tip [Re: PrenceOfDarkness] #106456
01/15/07 19:48
01/15/07 19:48
Joined: Mar 2005
Posts: 296
Lithuania
S
Sader Offline
Member
Sader  Offline
Member
S

Joined: Mar 2005
Posts: 296
Lithuania
Watches are very usefull also

Re: just a small tip [Re: Sader] #106457
01/16/07 05:46
01/16/07 05:46
Joined: Aug 2004
Posts: 1,305
New York
PrenceOfDarkness Offline OP
Serious User
PrenceOfDarkness  Offline OP
Serious User

Joined: Aug 2004
Posts: 1,305
New York
ya but as far as watches go, their a bit harder to us with multiplayer games (if we are talking about SED watches that is). Another limit is watches are only good to track variables.


"There is no problem that can't be solved with time and determination." -me
prenceofdarkness for instant messages on AIM.

Looking for a model designer
PLEASE, SEND ME A PRIVATE MESSAGE OR EMAIL IF YOU'RE INTERESTED.

Moderated by  adoado, checkbutton, mk_1, Perro 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1