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 / Need some code help please

Author
Message
Dragon slayer
19
Years of Service
User Offline
Joined: 3rd Nov 2006
Location: Bourbonnais Illinois
Posted: 20th Jun 2013 21:52
I can post all the code if necessary. I have a UDT with about 17 variables the udt is called characterT. I am trying to create a character called plrChar. Everything works fine the program automatically sets stats with a struct called roll: and the randomize command. I have a variable in the udt called spell_points. In the program there will be 4 magic users. conjurer, wizard, magician and sorcerer. For the rest of the characters the spell_points will be set to 0 but for these 4 if the user creates one of these the spell points will be set to 10. This is some code I tried and it didn't work.

if plrChar.class = wizard or conjurer or magician or sorcerer
plrChar.spell_points = 10
else
plrChar.spell_points = 0
endif

I am not sure if I wrote this if stmt right. I get an error with @ FS and some stuff I don't get.

Any ideas on how to do this? for loop maybe?

I know it can be done just not quite sure how to go about it!

Thanks Dragonslayer
TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 20th Jun 2013 22:01 Edited at: 20th Jun 2013 22:01
This:


Will not do what you want it to. It will always be true, no matter what value plrChar.class has.

Fix:


Quote: "I get an error with @ FS and some stuff I don't get."


Not sure what that means. You'll need to elaborate.

TheComet


Yesterday is History, Tomorrow is a Mystery, but Today is a Gift. That is why it is called "present".
Dragon slayer
19
Years of Service
User Offline
Joined: 3rd Nov 2006
Location: Bourbonnais Illinois
Posted: 20th Jun 2013 22:28
Thanks! I know I have seen that type of code. I will try it If it works great if not I should get the same error, if so I will post it here
Dragon slayer
19
Years of Service
User Offline
Joined: 3rd Nov 2006
Location: Bourbonnais Illinois
Posted: 20th Jun 2013 22:46
Here is all the code. the code in question is in the createCharacter function with a comment above it



This is the error I get even with the code Comet showed me

Types 'plrChar' and 'FS@createCharacter@wizard' are incompatible at line 247.
Phaelax
DBPro Master
23
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 21st Jun 2013 00:35
You have characterT.class as defined as a string, but in your IF statement you're trying to compare it to an integer. Incompatible types. You need to wrap those words in double quotes to make them strings.




As another note, since you're defining plrChar.class by user input, you should consider comparing the strings using lower$() or upper$(), because the string comparison is not case-insensitive.

Dragon slayer
19
Years of Service
User Offline
Joined: 3rd Nov 2006
Location: Bourbonnais Illinois
Posted: 21st Jun 2013 00:47
This makes sense to me. I will check this out later because I want to see where I made a mistake in my code not just change it so it works but not know why. I have to step out now so will look into it later!
Dragon slayer
19
Years of Service
User Offline
Joined: 3rd Nov 2006
Location: Bourbonnais Illinois
Posted: 21st Jun 2013 04:27
I fixed this works fine. Going to check out the string comparison stuff. Not the only place in the code I will need that. Also as it is right now They could type anything in those options and the program will work. I will put some code in that if they put something other than the class options or race options that are listed they will get a message to put in only the options that are listed.
Dragon slayer
19
Years of Service
User Offline
Joined: 3rd Nov 2006
Location: Bourbonnais Illinois
Posted: 21st Jun 2013 07:05
Phaelax
I clicked on the banner in your sig and checked out the site it took me to. Is that your site? If so I saw something on there that said shipping out, going to serve the country. Are or were you a soldier?

I was for 10 years. Got to go play in the sand in 90-91. I was a Cav soldier. 3/7 Cav in Mannheim Germany for 3 years then 1st Cav. Ft Hood Texas. Also did 3 years in the Marine Corps right out of high school.
Phaelax
DBPro Master
23
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 21st Jun 2013 18:11
I stayed stateside for training. It wasn't suppose to be for very long, but a fractured hip kept me in therapy for months.

Most of my DB-related stuff is on another site: http://dbcodecorner.com/

Dragon slayer
19
Years of Service
User Offline
Joined: 3rd Nov 2006
Location: Bourbonnais Illinois
Posted: 21st Jun 2013 21:11
Bookmarked that site. You still in?
Libervurto
20
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 21st Jun 2013 21:39 Edited at: 21st Jun 2013 21:40
You could use bitwise comparison if you structure the classes in the right way.


The difficulty in learning is not acquiring new knowledge but relinquishing the old.
TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 22nd Jun 2013 15:48
Try this



TheComet

Dragon slayer
19
Years of Service
User Offline
Joined: 3rd Nov 2006
Location: Bourbonnais Illinois
Posted: 24th Jun 2013 03:18
Still having problems with this code. Had it working then made some changes and now it prints 0 no matter how I re-arrange it. Any help would be appreciated!!!

Chris Tate
DBPro Master
17
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 24th Jun 2013 04:09
Just a quick glance shows that the players class has not been set anywhere in the program.

Was it you who I recommended the use of file data to? A lot of those text commands and character classes could have been set in a lookup file in an encrypted INI or XML format.

What you've done is literally set each class one by one in code, instead of using a for loop to extract the information from a file.

At least while learning; it would be easier for you to store your text and character data in an array, then use print commands or text commands in iterators such as for loops.

Anyhow, good luck with this.

Phaelax
DBPro Master
23
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 24th Jun 2013 12:23
*Sternly shakes fist* COMET!

revenant chaos
DBPro Master
19
Years of Service
User Offline
Joined: 21st Mar 2007
Location: Robbinsdale, MN
Posted: 24th Jun 2013 13:26
Quote: "*Sternly shakes fist* COMET!"
LOL I second that, posting an image that looks like a codebox is just wrong XD
Dragon slayer
19
Years of Service
User Offline
Joined: 3rd Nov 2006
Location: Bourbonnais Illinois
Posted: 24th Jun 2013 19:03
On my phone now will try both ways on smaller code. When I get it figured out and working I will get it working in this code. Thanks!

Login to post a reply

Server time is: 2026-07-08 10:17:12
Your offset time is: 2026-07-08 10:17:12