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.

Newcomers DBPro Corner / User Types

Author
Message
Libervurto
13
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 18th Feb 2013 12:13
This is a bit messy: shipClass(ship(shipsel(1)).class).name it gets the name of the class of the ship that is currently selected. Is there a better way to structure this? I need class to be a number for other reasons.

Could I do something like: ship(shipsel(1)).class.name?

TheComet
12
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 18th Feb 2013 17:55
Yes, you can nest UDTs:



Quote: "I need class to be a number for other reasons."


Instead of using "class", you'll have to use "class.index", otherwise it won't work.

TheComet

http://blankflankstudios.tumblr.com/
"You're all wrong. You're all idiots." - Fluffy Rabbit
"Bottom line, people are retarded." - Fluffy Rabbit
Libervurto
13
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 18th Feb 2013 18:24
oooooooh thanks.

MrValentine
AGK Backer
9
Years of Service
User Offline
Joined: 5th Dec 2010
Playing: FFVII
Posted: 18th Feb 2013 18:32
Ahahahahaah typo there TheComet? ^^ I was going to mention Composite and Nested UDTs too, but I am so new to them that I decided not to post earlier, thank you for confirming this I was going to mention Arrays as an alternative...



Libervurto
13
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 18th Feb 2013 19:21
Do I have to set the class.name for each ship or is there a way to set up an association between index and name? So if class.index = 1 then class.name = name$[1]
This is not really important, I'm just wondering what can be done with types.

TheComet
12
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 18th Feb 2013 20:02
You can use a UDT to reference an array index, if that's what you're asking.

The only limitation I found with UDTs is you can't have an array inside a type declaration. My work-around for that was usually to just create another UDT for that array, and then link them together later on.

TheComet

http://blankflankstudios.tumblr.com/
"You're all wrong. You're all idiots." - Fluffy Rabbit
"Bottom line, people are retarded." - Fluffy Rabbit
Phaelax
DBPro Master
16
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 18th Feb 2013 21:29
Something I should point out that I just discovered the other day. While you can pass a UDT variable into a function, you cannot pass a UDT defined array element into the function.




"You're all wrong. You're all idiots." ~Fluffy Rabbit
Nytus Sermus
7
Years of Service
User Offline
Joined: 17th Jan 2013
Location:
Posted: 19th Feb 2013 10:59 Edited at: 19th Feb 2013 11:00
@ Phaelax, not to be captain obvious but you should just assign the array's indexed variable to a temp variable before calling the function:



anyway the simplest workaround

You could be done already.....stop trying to re-invent the wheel.
Phaelax
DBPro Master
16
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 19th Feb 2013 17:39
I know that, never said it wasn't possible to work around it. But it's an annoyance. Just don't forget to define 'temp' as the same data type. (your example forgot that)

"You're all wrong. You're all idiots." ~Fluffy Rabbit

Login to post a reply

Server time is: 2020-01-19 15:24:22
Your offset time is: 2020-01-19 15:24:22