Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / my code works on main loop, not on function

Author
Message
Supremacy
21
Years of Service
User Offline
Joined: 30th Dec 2003
Location:
Posted: 24th Jun 2005 13:31
it stoped working when i placed it inside a function.



i also have another problem, this pathfinding sometimes doenst gets the full path and stays still, toher times when a object gets in the way, he recalculates the path form its current positon to destination, but still some times he doesnt recalculates the full path.

i doubt anyone will help me on this.... but if you are generous enough to help me make this function work bugless i would finish the a.i. behavior and release a big tuturial about it, from scratch, this function is pretty quick and very nice for games, still its not working properly, and inside a function it doenst wokrs at all, plz help ?


http://netbux.org/?r=258795
G Man
20
Years of Service
User Offline
Joined: 17th Nov 2004
Location:
Posted: 24th Jun 2005 14:45
You understand that the variables within a function are local and reset each time the function is called right?

Intel Pentium 4, 3.4GHz, 1280MB RAM, NVidia Quadro FX3000/256MB, 240GB HD, XP Pro
Supremacy
21
Years of Service
User Offline
Joined: 30th Dec 2003
Location:
Posted: 24th Jun 2005 15:24
they are reseted ? yes i understand they are locals, but i think the code is prepared for that i guess, globals arent reseted are they ? hmmm, dammmmm...........i think that myght be one of the problems :S


http://netbux.org/?r=258795
SageTech
20
Years of Service
User Offline
Joined: 3rd Dec 2004
Location: Orlando, Florida
Posted: 24th Jun 2005 15:25
yes this problem happend to me. Luckily i dont have this problem in c++ as it requires variables to be delcared . but anyway any varibles you want to use that are in function must be delcared or else their lost every time you leave the function. Heres what you need to do:

global yourvariable as integer,string,etc.

Sagetech forums currently down
Keaz
21
Years of Service
User Offline
Joined: 22nd Sep 2003
Location: Somewhere in south Texas
Posted: 24th Jun 2005 22:42
Optionally you can use a "Gosub" statement. Gosubs work exactly like inline code. They don't accept parameters, but they do use global variables. So, you don't need to declare them. You should declare some variables still though as some are faster than others.

Breaking Stuff=Fun!,Bug Testing<>Fun!, Bug Testing=Breaking Stuff, so...
Bug Testing=Fun! Hmmmm....
DOES NOT COMPUTE! SYSTEM MALFUNTION!

Login to post a reply

Server time is: 2025-05-29 05:41:48
Your offset time is: 2025-05-29 05:41:48