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 / user defined types confusion

Author
Message
That1Smart Guy
17
Years of Service
User Offline
Joined: 26th Feb 2009
Location: Somewhere...... yep
Posted: 13th Mar 2010 07:46
can some1 proofread this code? im lost on why it says i havent created the player1 variable



dark coder
23
Years of Service
User Offline
Joined: 6th Oct 2002
Location: Japan
Posted: 13th Mar 2010 07:59 Edited at: 13th Mar 2010 08:00
Types and variables aren't created at runtime, so putting them in a gosub is pointless and because DBPro's parser is less than good, the actual declaration order of types does matter(it must be defined before its use for it to work in all cases).

If I shift the UDT and variable declaration to the top then it almost works, but I had to remove 'player1.currentweapon = MAKE MEMORY(7)' as I have no idea what you're trying to do there. You don't need to allocate any memory yourself for UDTs within each other, they will pretty much act as if you just added more variables to the existing UDT.

Daniel wright 2311
User Banned
Posted: 13th Mar 2010 07:59 Edited at: 13th Mar 2010 08:03
put this somewhere in your code before you call the action then you will be fine, the 2 in the marks is your player modle number so what ever this is the 2 needs to be changed to that.




edit: also i noticed you put your types bellow the actions, they need to be above your actions.

That1Smart Guy
17
Years of Service
User Offline
Joined: 26th Feb 2009
Location: Somewhere...... yep
Posted: 13th Mar 2010 16:37
dark coder:

the make memeory(7) thing was me trying to turn "plaeyer1.currentweapon" into a pointer to a weapon object. I want to create the different weapons at the start, and then during game have the player's current weapon be a pointer to the weapon he is holding, that way i dont waste memory by creating a whole other weapon object inside the player object

Sepnon
16
Years of Service
User Offline
Joined: 7th Feb 2010
Location: Brazil
Posted: 13th Mar 2010 18:40

!!

Login to post a reply

Server time is: 2026-07-26 23:41:08
Your offset time is: 2026-07-26 23:41:08