Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ SMAUG ➜ SMAUG coding ➜ EXP problem in score

EXP problem in score

It is now over 60 days since the last post. This thread is closed.     Refresh page


Pages: 1 2  

Posted by Ithildin   USA  (262 posts)  Bio
Date Sun 22 Feb 2004 03:35 AM (UTC)
Message
here's what part of my score looks like:

PRACT: 2 Hitpoints: 20 of 37
EXP : 2000 Mana: 100 of 100


i want the Exp to look like this:

Xp Needed : 1750
Xp Current : 107

here's what my code looks like:


pager_printf_color(ch, "&CEXP  : &W%-9d    &CMana: &B%-5d &Cof &b%5d   &CMKills:  &W%5d    &CAutoLoot(&W%c&C)\n\r",
		ch->exp, ch->mana, ch->max_mana, ch->pcdata->mkills, xIS_SET(ch->act, PLR_AUTOLOOT) ? 'X' : ' ');


i'm not really sure what to fix here.

i tried this:


"&CEXP  : &W%-9d  &Cof %9d


but that doesn't work. any thoughts or suggestions?
Top

Posted by Ithildin   USA  (262 posts)  Bio
Date Reply #1 on Sun 22 Feb 2004 04:05 AM (UTC)
Message
i've been tryin all sorts of things. could someone at least help me gain some knowledge of what the %-9d is and such? then i could probably just figure it out on my own.
Top

Posted by Greven   Canada  (835 posts)  Bio
Date Reply #2 on Sun 22 Feb 2004 04:08 AM (UTC)
Message
Check your man page for format. That should tell you all you need to know in that context. The other option is show us exactly what you did, with the full code that didn't work, and HOW it didn't work. Did it crash, or display the wrong stuff?

Nobody ever expects the spanish inquisition!

darkwarriors.net:4848
http://darkwarriors.net
Top

Posted by Ithildin   USA  (262 posts)  Bio
Date Reply #3 on Sun 22 Feb 2004 04:16 AM (UTC)
Message
when i tried that code that i showed. it came up with this:

Exp : 2000 of 100 Mana 100 of 0

so it was confusing what i put in with the max_mana. i tried making a max_exp sh_int in mud.h but i still didn't know what those numbers were for. ie the %-9d and such.
Top

Posted by Greven   Canada  (835 posts)  Bio
Date Reply #4 on Sun 22 Feb 2004 04:22 AM (UTC)
Message
Did you check the man page? "man format" will discribe the difference between "%-9d" and "%d". However, in the actual line, is your adding a nother print variable (%d, for example), you need to add something to fill in that info. Now, as for what to use, you need to look for code that might already utilize this, like do_level. Looking at the smaugfuss code, you need something like this:
pager_printf_color(ch, "&CEXP  : &W%-9d of %-9d   &CMana: &B%-5d &Cof &b%5d   &CMKills:  &W%5d    &CAutoLoot(&W%c&C)\n\r",
		ch->exp, exp_level(ch, ch->level+1) - ch->exp, ch->mana, ch->max_mana, ch->pcdata->mkills, xIS_SET(ch->act, PLR_AUTOLOOT) ? 'X' : ' ');


I added a %-9d, so I had to add something to print into it, which is the exp_level part.

That should work for you.

Nobody ever expects the spanish inquisition!

darkwarriors.net:4848
http://darkwarriors.net
Top

Posted by Ithildin   USA  (262 posts)  Bio
Date Reply #5 on Sun 22 Feb 2004 04:36 AM (UTC)
Message
thanks so much for you help. first of all, i'm not really sure what you mean by man page. but i did try what you said and it worked..but wasn't what i was needing.

it worked out like this

EXP : 2840 of 70

what i'm wanting it to say is:

EXP : 2840 of 2910

so i'm guessin i would add something somewhere.

ok, scratch that. here's what i did after that. i just deleted the - ch->exp part and it works fine.

Thanks.

i feel stupid, but could you explain what the man page is?
Top

Posted by Greven   Canada  (835 posts)  Bio
Date Reply #6 on Sun 22 Feb 2004 04:43 AM (UTC)
Message
man stands for manual( I assume ). It will give you information you need on commands, code, functions, etc. You access it with "man <string>", in this case, "man format". You can scroll up and down(if it has enough text to not fit on your screen). This one tells you the command, a short description, an introduction, details on it, special notes from the author, and keywords for the man page. This explains the different between using -, +, 0, and #.

Hope that helps.

Nobody ever expects the spanish inquisition!

darkwarriors.net:4848
http://darkwarriors.net
Top

Posted by Seifz   (24 posts)  Bio
Date Reply #7 on Sun 22 Feb 2004 04:51 AM (UTC)
Message
Access it from where? I've never heard of this but if it does exist, that would be awesome. Score is next on my list, after fixing that who list.
Top

Posted by Greven   Canada  (835 posts)  Bio
Date Reply #8 on Sun 22 Feb 2004 04:52 AM (UTC)
Message
You access it at your command prompt. You need to be using a *nix system, or cygwin with the man package.

Nobody ever expects the spanish inquisition!

darkwarriors.net:4848
http://darkwarriors.net
Top

Posted by Seifz   (24 posts)  Bio
Date Reply #9 on Sun 22 Feb 2004 04:56 AM (UTC)
Message
Man package? I'll have to look for that and make sure to download it. Thanks for the tip.
Top

Posted by Ithildin   USA  (262 posts)  Bio
Date Reply #10 on Sun 22 Feb 2004 04:59 AM (UTC)
Message
i'm using windows version... :(

i tried cygwin once, but i couldn't get it to work right.

if i ever went back, would it be hard to switch from windows to cygwin?
Top

Posted by Seifz   (24 posts)  Bio
Date Reply #11 on Sun 22 Feb 2004 05:04 AM (UTC)
Message
I really doubt that you'll be able to use the Windows version with Cygwin. If you download the original 1.4a code, though, and the Crypt library for Cygwin, you'll only have to change one or two simple things to get it working properly.
Top

Posted by Greven   Canada  (835 posts)  Bio
Date Reply #12 on Sun 22 Feb 2004 06:26 AM (UTC)
Message
The win32 port SHOULD work in cygwin IF they did it properly and used defines, which I beleive they did. Best way is to try it.

Nobody ever expects the spanish inquisition!

darkwarriors.net:4848
http://darkwarriors.net
Top

Posted by Seifz   (24 posts)  Bio
Date Reply #13 on Sun 22 Feb 2004 09:34 AM (UTC)
Message
I downloaded the man package with Cygwin but there's no page on 'format'. Is there another keyword for it?

Anyways, WIN32 ifdefs don't work with Cygwin, from what I've seen. For example, to compile SMAUG 1.4a with Cygwin, you need to #define NOCRYPT -outside- of the WIN32 ifdef even though it's defined inside it.
Top

Posted by Nick Gammon   Australia  (23,165 posts)  Bio   Forum Administrator
Date Reply #14 on Sun 22 Feb 2004 11:55 PM (UTC)
Message
Try: man 3 printf

The Windows version should compile under Unix, the one I did had the appropriate defines in it.

The important thing with printf is you need to tell it *how* to print something and also *what* to print.

eg.


int myage = 5;

printf ("my age is %i", myage);


The %i tells print to print an integer and "myage" is the integer to print.

Now if you were going to add something (eg, myheight) then you need to add another %i *and* the variable containing the height, like this:



int myage = 5;
int myheight = 100;

printf ("my age is %i and my height is %i", myage, myheight);



Things like the %9d or %-9d are extra formatting. In this case the "9" means "make it 9 characters wide" and the "-" changes from left to right-justification (or the other way around, I can never remember which).


- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


55,333 views.

This is page 1, subject is 2 pages long: 1 2  [Next page]

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.