Tuesday, August 13, 2013

Bug-Checking a Program

Thought I might go ahead and post this, cuz why not. Work has somewhat slowed down as I begin writing this at 2:48 on a Tuesday afternoon (though I am tempting fate with that statement), and I've had enough free time to work on this so far...

The program is supposed to ask for the total amount of a loan, the interest rate the loan was taken at, and the monthly payment. Note that I am posting this despite the fact that I KNOW there is something up with my calculations -- otherwise, I wouldn't be having a problem!

The example in the book states:

Amount of Loan: 20000.00
Interest Rate: 6.0
Monthly Payment: 386.66

Balance remaining after first payment: $19713.34
Balance remaining after second payment: $19425.25
Balance remaining after third payment: $19135.71

Seeing as this is the easiest way to tell if my own calculations are correct, I'm using this as a constant. So, here's the code I've come up with, after tweaking it for a bit and adding some variables:

#include <stdio.h>
#define months 12

int main (void)
{
   float loan_total, interest, interest_rate;
   float monthly_pymt, balance;
   float balance_first, balance_second, balance_third;

   printf("Enter Loan Amount: ");
   scanf("%f", &loan_total);

   printf("Enter Interest Rate: ");
   scanf("%f", &interest);

   printf("Enter Monthly Payment: ");
   scanf("%f", &monthly_pymt);

   interest_rate = (interest/100)/months;
      /* 100 is used to turn the value given as the interest rate
      into a percentage */
   balance = loan_total - monthly_pymt;
   balance_first = balance + (balance * interest_rate);

   printf("Balance after first payment: %.2f\n", balance_first);

   balance = balance_first - monthly_pymt;
   balance_second = balance + (balance * interest_rate);

   printf("Balance after second payment: %.2f\n", balance_second);

   balance = balance_second - monthly_pymt;
   balance_third = balance + (balance * interest_rate);

   printf("Balance after third payment: %.2f\n", balance_third);

   return 0;

}

This was a test on my part, and I've already ruled out the possibility that balance is retaining its first value throughout the program. When entering the same credentials, here is what the above program returns:

Enter Loan Amount: 20000.00
Enter Interest Rate: 6.0
Enter Monthly Payment: 386.66

Balance after first payment: 19711.41
Balance after second payment: 19421.37
Balance after third payment: 19129.88

Pennies of a difference! Okay, maybe a few dollars. But still! Naturally, the next step is to check over the equations to make sure they are doing what they need to do...

And I think I found it. 

balance_first = balance + (balance * interest_rate);

The balance after the first payment is off by approximately 2.50 because the interest is being calculated against the updated balance here -- I think it needs to be calculated against the original loan amount.

balance_first = balance + (loan_amount * interest_rate);

This should even out the rest... Gonna run a quick test.

Enter Loan Amount: 20000.00
Enter Interest Rate: 6.0
Enter Monthly Payment: 386.66

Balance after first payment: 19713.34
Balance after second payment: 19423.31
Balance after third payment: 19131.84

Well, it fixed the first payment. But I see exactly what needs to change now!

balance_second = balance + (balance_first * interest_rate);

balance_third = balance + (balance_second * interest_rate);

Testing with this minor change...

Enter Loan Amount: 20000
Enter Interest Rate: 6.0
Enter Monthly Payment: 386.66

Balance after first payment: 19713.34
Balance after second payment: 19425.25
Balance after third payment: 19135.71

Hah! Yes! It is now returning the correct amounts!! I never did like accounting... It can be somewhat confusing. The problem essentially came from the interest being calculated with the newly initialized balance value, instead of the balance that had been reported for the previous month. Of course, interest isn't going to take into consideration that you are making a payment this month -- it's going to accrue based on the last month's balance. I swapped out those variables so the interest calculated correctly, and voila!

So there. A bug-checking process for you all! I am now off to take notes on Chapter 3!! See you all when its time for more programming exercises!!

Feeling Confident

I have this tendency. I will sit down and start writing a program, then get halfway through it and realize the entire logic of the thing is fucked.

I started on this exercise around 9:30 or 10 this morning (though it has taken so long partially due to the nature of being at work and actually having to... well... work). The exercise is to write a program that will take an original dollar amount, and split it into twenties, tens, fives, and ones.

Oh man. When I wrote it the first time? I thought I had too many variables to begin with, so I tried to make the variables I had do crazy things. I should have saved it. I can't remember exactly what I did, but it ended up with hilarious answers like:

$20 bills: 3
$10 bills: 0
$5 bills: -13
$1 bills: -137

I couldn't help but laugh and delete the whole thing, ahahaha...

After tweaking and pouring over my graphing calculator and a few paper scraps with notes on them, I did get it working though! As of 11:45, here is my working USD splitting program:


#include <stdio.h>
#define twenty 20
#define ten 10
#define five 5
#define one 1

int main (void)
{
   int original_amount;
   int twenty_bills, ten_bills, five_bills, one_bills;
   int orig_after_twen, orig_after_ten, orig_after_five;

   printf("Please enter the original dollar amount: ");
   scanf("%d", &original_amount);

   twenty_bills = original_amount/twenty;
   orig_after_twen = original_amount - (twenty_bills * twenty);

   printf("$20 bills: %d\n", twenty_bills);

   ten_bills = orig_after_twen/ten;
   orig_after_ten = orig_after_twen - (ten_bills * ten);

   printf("$10 bills: %d\n", ten_bills);

   five_bills = orig_after_ten/five;
   orig_after_five = orig_after_ten - (five_bills * five);

   printf("$5 bills: %d\n", five_bills);

   one_bills = orig_after_five/one;

   printf("$1 bills: %d\n", one_bills);

   return 0;
}

Valuable Lesson Learned

So, last night I was working some more on my programming projects. I got through one of them with no trouble at all, but the next one was giving me a fit. I had to write a program to ask for a value for x, then compute that value in a fifth degree polynomial.

My lesson came after I had corrected the errors and warnings that was keeping the program from compiling. I entered the value I chose for x, and the answer was -6. I entered another value for x... and the answer was still -6. It seemed way off to me.

Here's a look at the code I had written:

#include <stdio.h>

int main (void)
{
   float x, final_value;

   final_value = ((((3*x+2)*x-5)*x-1)*x+7)*x-6;  

       /* By the way, this is an example of Horner's Method, which allows
      for polynomials to be solved, despite C not having an exponential 
      function */

   printf("For the polynomial 3x^5 + 2x^4 - 5x^3 - x^2 + 7x - 6\n");
   printf("Please enter a value for x: ");
   scanf("%f", &x);
   
   printf("Final answer: %.1f\n", final_value);

   return 0;

}

Most people will probably find the issue immediately, but it was totally baffling me. It got to the point where I had to ask my fiance for help. He did some tests, such as changing the final integer of the polynomial to 4. When he ran that test, the answer the program gave was -4 instead of -6!! Fortunately, he knew what to do...

#include <stdio.h>

int main (void)
{
   float x, final_value;

   printf("For the polynomial 3x^5 + 2x^4 - 5x^3 - x^2 + 7x - 6\n");
   printf("Please enter a value for x: ");
   scanf("%f", &x);

   final_value = ((((3*x+2)*x-5)*x-1)*x+7)*x-6;

   printf("Final answer: %.1f\n", final_value);

   return 0;
}

Can we say DERP??? In the first example, x hadn't been initialized because the polynomial came first in the program. It assumed x must be 0, solved the polynomial, stored the final integer (because everything else had been multiplied by 0, because x was equal to 0) as the value of final_value, and returned that every time. It was working correctly! Just not the way I wanted it to!!

In the second example, x is initialized by scanf right off the bat. THEN the program enters it into the polynomial, returning final_value with x equivalent to the value initialized with scanf.

Ahhhhhhhhhhhhh....

Monday, August 12, 2013

Quietly Lurking, Quietly Working

Oh man, I've been pulled in so many different directions lately.

Over the past few weeks, I have:

  • Watched Last of Us from start to finish as my fiance played it (WOW, what an amazing game)
  • Resubbed to World of Warcraft (ugh, Mists is terrible)
  • Started playing Guild Wars 2 again
  • WRITTEN A LOT OF STUFF
  • Watched Minority Report, Tron, Tron: Legacy, The Fifth Element, Daybreakers, and kept up with Breaking Bad and Dexter
  • Messed around with C
  • Done some really fulfilling sketches for character designs
I've been really really busy. But the main reason I'm posting today is to say, "LOOK, LOOK!! I'm coding things on my own!!"

Take a gander! :)

These are exercises in my textbook -- which I have since decided that taking the notes down in my notebook is time-consuming enough... I don't think I'll be uploading them to this blog anymore. Instead, I'll be sharing the source that I write, when I feel like it. C: I'm stingy, I know.

So, the program I'm particularly fond of at this time is this exercise. I was prompted to find the volume of a sphere using a constant. So I did:

#include <stdio.h>
#define RADIUS 10.0f

int main(void)
{
   float volume;

   volume = (4.0f/3.0f * 3.14159 * (RADIUS * RADIUS * RADIUS));

   printf("Radius = %.1f\n", RADIUS);
   printf("Volume = %.3f\n", volume);

   return 0;

}

It was pretty nifty! Compiled and performed just fine out of Xcode (which is what I use on Mac because I haven't had time to investigate any others -- on the Zombie, I've just been using Mousepad to make changes so far). But I wondered if there was another way to do it. So I experimented...

#include <stdio.h>

int main(void)
{
   float radius, volume;

   radius = 10.0f
   volume = (4.0f/3.0f * 3.14159 * (radius * radius * radius));

   printf("Radius = %.1f\n", radius);
   printf("Volume = %.3f\n", volume);

   return 0;

}

Wouldn't you know! It compiled and worked just fine, too!! Gave the same answer I calculated manually on my calculator (which is 4188.787, rounded as the final decimal repeats). I'm so thrilled!

The second part of the exercise stated to alter the program so the user enters the radius before the calculation is made. Here goes:

#include <stdio.h>

int main(void)
{
   float radius, volume;

   printf("Enter radius of sphere: ");
   scanf("%f", &radius);

   volume = (4.0f/3.0f * 3.14159 * (radius * radius * radius));
   printf("Volume of sphere: %.3f\n", volume);

return 0;
}

Ahh, works perfectly. So I now have a fifteen line program that calculates the volume of a sphere... You know, just in case. ;D

Monday, July 8, 2013

So busy.

I have so little time now. I really do mean to come back to my coding work, but in the near foreseeable future, I will be very occupied with my position in the MUD.

I also wanted an excuse to post this photograph so I can link to it on Tumblr, haha.


[Editing only to add another photo]



I did get a break from work this past week, but again... Between my position on the MUD, all the writing I've had to do, and the things I've been using to take a break from that (including Guild Wars 2 and hanging with people outside of the internet *GASP I KNOW RIGHT? BLASPHEMY*), I just can't focus long enough on my textbooks to get anything worthwhile out of them.

And writing a ton of pseudo-code doesn't count, though I've been doing that.

Ugggg. I'll be back. I promise!

Friday, June 14, 2013

I've not forgotten anyone...

I promise I've not abandoned this blog. If anything, I am more enthusiastic to learn how to code than I was before.

I've been promoted to an immortal position in the MUD I currently play. I've been building there instead of in The Builder's Academy for the past week or so, and I can't overstate how surreal it feels to have a position like this in this particular MUD. I've logged over 70 hours since last Saturday night... out of a total of 168 hours I could have spent on there this week, that is rather considerable, I think. My fiance got a position as well, and he only has 30 hours logged...

Anyway, I'm gushing and probably talking about it too much. The point is, at least until my zone is complete and ready for launch, I will be on coding homework hiatus. Hopefully I don't forget too much... But I will also be working extensively with something called m/o/rprogs, and my notes on those may come here, much like my notes on DG Scripts.

I'll be around!

Thursday, June 6, 2013

More Chapter 2: King

Chapter 2 is huge. Huuuuuge. I had six pages written halfway through section 4...

While working on these notes earlier this week, I was listening to Chopin's Nocturne Op. 9-72. Andrei was merrily doing some creative writing pertaining to our story at the time, and despite the tribulations from the afternoon prior, I felt truly peaceful and content. It was a beautiful, fleeting feeling.

Driving to work, today, too... It was raining because we have a tropical depression hanging over us, and it was dark because it was still early... But I just had this feeling like... "I am so light and happy..." Just in general. Things are just really good.

Anyway, notes are below the break--


Tuesday, June 4, 2013

Slacker...

Oh man. These past few days have been so so SO so busy... Ahhhh...

First, I didn't study coding at all this past weekend because I was lazy on Friday night and Saturday. Shame... I can't help it though, I get home from work for the weekend and all I want to do is lounge like a lethargic kitten who just drank too much milk...

Sunday was a very exciting day because Andrei and I announced our engagement to a big group of our friends and family! I know a bunch of people took photos, but I've only seen a few so far... Not everyone has emailed them to me yet. But, one of my favorites...


Andrei wasn't expecting to have to give a speech, but he moved us all with his words, regardless. That's me getting all teary-eyed over what he's saying. Ahh, I love this man.


Anyway. I may end up bogging down some of my posts with messy pseudo-code. I'm going to be using my knowledge with C to design a text game (I've mentioned that before). I need to get some of the main functions down for features I want to offer, and in the process, I'll be trying to figure out if they're going to be possible.
Things like save-files that are password protected for characters... Garages or stables where they can store animals/vehicles for mounts or minions... A leveling/storage system for minions that allows them to gain experience and skills alongside their masters (it is SO Pokemon-y, but I hope that the end product won't feel like that at all)... Crafting that actually makes it feel like you have complete control over how a piece of armor looks, instead of making the same shirt/pants/boots over and over... Not to mention, items that give invisible flags, like comm-links that allow a character to talk into an IC channel that is only available to other characters with that comm-link item...

Idk, I just have so many ideas. I didn't ever ever EVER think I would get into game-design... but if I can get good with this coding bit, or find someone who likes the ideas I have enough to help me... Oh man. Ohhhh man. I just get all excited thinking about it.

I've got note-taking on my list of things to do today, if I can tear myself away from Facebook and Tumblr. I've got to keep my goals in sight. I know I can do this as long as I keep myself motivated!!

Saturday, June 1, 2013

Oh, Interesting Things I Find

So, late this morning, I was waking up slowly and checking over all of my social networking sites for updates, when I found a blog I follow shared something quite interesting back on May 29th. I missed it on that particular day, and only found it because I was investigating something else... But I found it relevant.

I have a particular appreciation for music, as it has always been in my life, just as I have a love of art and color. I used to love staring into the old iTunes visualizers for the amazing color combinations that I could see move together during my favorite music... But I was always slightly put off by how the visualizer really couldn't predict the music, and continued sporadic movements even when the music was no longer sporadic.

This is far from a visualizer of that sort, but I still find it fascinating to watch.


Just like visual/kinetic typography, the sounds you hear are visible. I find this so amazing.

This gentleman has dozens of compositions that he has designed with his overlapping talents in music and programming. I look at this, and I think to myself that anything can be possible.

Now, to find some more Saint-Saens to listen to...

Friday, May 31, 2013

"jif" or "gif"

After seeing a series of amusing Tumblr posts...






...it truly piqued my interest why so many people were posting about it all of a sudden.

Apparently, this happened.

(In case you were wondering, I have always pronounced it "giff", as in "graphics".)

So, yes, it is pronounced "jif", but it will take a long time for me to adjust... if ever. It just sounds so weird to meeeee.

Also, I laughed pretty hard when I Googled "define gif" and hit the speaker next to it. Google wants none of your shit.

Wednesday, May 29, 2013

Also, an interesting read

Andrei mentioned in passing earlier that some of the earliest coders back in the '40s were actually women.

The mathematicians of the time were too concerned with developing mathematical concepts, and most notably, John Backus realized that there were women who were just as brilliant who would be willing to work on groundbreaking projects like those he was planning.

He designed Fortran with the assistance of some great woman thinkers of their time.

I thoroughly enjoyed reading about Grace Hopper, who had quite a hand in early programming. She achieved the rank of US Navy Rear Admiral, and contributed to Backus's work with Fortran.

Anyway, just thought I'd mention. I hope I don't offend anyone with my blog title... Just commenting on the societal notion that girls aren't nerds and definitely don't exist on the internets.

Busy-ness!!

Man, this blog has been lingering in the back of my mind all weekend. o-o;

I feel so bad for not updating it aggh. But I seriously didn't want to do any work on my coding this weekend... I've been madly creative and inspired (and also kicking ass in pvp on ToR with Fiance...)

This morning hasn't been crazily busy by any means, so I took it upon myself to scribble down some more notes from K&R. Mom walked by my desk and made a comment about how fast I write, then became very interested in what I was writing about. I flipped the cover of K&R over to show her, and the following conversation ensued:

Mom: "Coding!?"
Me: *grins* "Include standard input/output dot H..."
Mom: "What the fuck, girls don't code!!"

It made me giggle. C:

Anyway, I'm getting into Character Input and Output, specifically with getchar and putchar. I really have to work at this one to figure out what they're talking about. I'm trying to paraphrase, but I keep finding myself writing their explanations word-for-word because I don't understand them enough to paraphrase. Baahh.

First, I need to transcribe my notes from 1.4. Then I'll move to 1.5, which is input/output for character info. Belowwww the break...


Thursday, May 23, 2013

BAH!

Working on coding and writing tonight, because my fiance has a few projects he's busy with. I took more notes from K&R, but man do I still have a long way to go. No better way to put your knowledge to the test with miniature tests, like using what you've learned so far to write a program from memory.

Looking back over that little chunk of text (I wrote it out in my notebook), I made 4 terrible mistakes that would've kept the whole thing from compiling... The worst one was leaving out the variable assignment!! Aggh!!

It's okay though. Deep breaths, and lots of note-taking. I've taken to slowly working through the descriptions of the statements, going step by step until I'm certain that I understand what they're talking about. If I can keep that up, I think I'll be okay.

Anyway, for more notes, click the break!



Wednesday, May 22, 2013

Update and Blabbering

I'm finding it pretty amusing that, after picking up K&R, I haven't been using King nearly as much. K&R is so concise that it teaches you a LOT in a small amount of time. King is much more expository in style. I think K&R is the best choice if you can keep up with them, but if you don't know what an operand is (or some other term that is used in K&R, I only used that as an example), you will probably cause yourself less grief if you go with a more detailed approach.

Now that I'm reading through, I'm finding that I can skip over huge sections of King. I think I may use King as an extra workbook, at this rate, but it is still good reading that doesn't assume that you already know what you're doing (example: declarations really do need to go before the statements every time. K&R assumes the reader knows this; King spells it out, just in case.).

I haven't posted here in a couple of days because I got into a creative rut, and because I got busy at work. The busy-ness at work comes and goes -- I'm thankful for the time I can spend on personal projects, but I do still have to pay attention to some things (and, occasionally, those things get overlooked because I'd rather be working on anything else coding... Heh...).

The creative rut is exciting, so I let it wrap me up for longer when I get stuck in it. These past couple of days have been filled with gaming, but also with writing. My fiance and I are putting ideas down on paper (at last!), and I'm excited to be weaving his thoughts and my thoughts together. We've been talking about this project for the better part of a month now, and it feels good to be making some solid progress on it. This is the same project that spurred my interest and dedication to learning to code in C.

Anyway, this is somewhat of a rambling post. I'm resisting the urge to monetize this blog, despite how popular it seems to be so far. I know how ads can kill something enjoyable... Of course, that's assuming my rambling is actually enjoyable to any of the people who stop by here haha.

Possibly going to do some exercises today! I'm going to make an effort, anyway! But a good friend is coming to visit, tonight, and there will be chinese buffet and Star Trek movie goodness. That may not leave much room for coding practice. XD

Monday, May 20, 2013

Xcode

Seeing as I do a fair bit of work on my Mac partition, I took the plunge and downloaded an IDE called Xcode.

I wanted to share some of the things I've discovered today while poking around with this powerful application:

  1. IDEs will require some sort of learning curve. Luckily, this one is very straight-forward, but I haven't investigated any for Windows or Linux systems yet. Yeah, go figure that after being so excited to get Linux on my zombiemac, I'm using Mac OSX more...
  2. There is a LOT of good information in the documentation for the IDEs, but chances are, you'll need to sift to get to what you're trying to figure out. The communities are pretty tight-lipped, it seems, and that's understandable. I think, perhaps, they want to protect the diminishing quality of really good coders who legitimately want to know what they're doing. But, that could be a brash opinion from a novice who doesn't really know the communities very well.
  3. For the kind of coding that is tackled in K&R and King, there really don't need to be any shiny bells and whistles. In Xcode, at least, just enter these programs into a "Command Line Tool". It uses C libraries automatically and opens up a Terminal window to produce the effects of the program. I have no idea if other IDEs will have settings like these, though.
  4. I just want to put this out there; Don't forget to compile the code after you've made a change. Seriously, you can make every change you want, but if you don't compile it after, it won't have any effect on your output. I found this out the hard way, despite this being a kind of common-sense thing (and I'm absolutely certain I've read it somewhere before and just forgot with the excitement of having things WORK in Xcode haha).
  5. Xcode can do a LOT of things. The other IDEs you might find are also designed to handle a TON of work. As with anything, take small steps and try not to get overwhelmed. If you don't need a feature (like a graphical interface), don't learn about how to code it right away!
Anyway, now that that's out of the way, here are a few things I was playing around with today. GO FIGURE that "hello, world!" was actually the program that fell victim to my lack of good knowledge with Xcode. After I got the F/C conversion table working, I didn't feel like I needed to go back and do it again, heh.


I'm hoping this can be read clearly enough... (Pro Tip: Open in New Tab, it will let you zoom reeeeal close)

The example to the far left is the original program. It takes the Fahrenheit values, in increments of 20, and calculates the Celsius value by using the algebraic formula.

The middle example converts the integers (int) of Fahrenheit and Celsius into floating-point numbers, so they can be converted with more accuracy. Floating-point numbers allow the usage of decimals.

The right-hand example shows an addition that was suggested by K&R as an exercise; a header to the table.

The next topic in K&R is the for statement. Yay for being excited to carry on with coding before delving into video games! I actually made my fiance go play ToR by himself after dinner so I could work on this stuff! Haha.

Friday, May 17, 2013

Chapter 2 at last!

Just to give you all a heads up, there are some sections of the textbook that I won't necessarily take notes on. It's a great book, and I want to leave some content out of my blog so I don't get hammered with licensing issues or anything. I've been feeling like this is possibly treading a thin line.

I have a lot of respect for this author for making such a great resource, and I want to urge anyone following along to pick up the book as well. Maybe it isn't quite so bad if I generate some publicity for the book, right? :D

That being said, I will stop promptly if this blog is found to be too close to original content.

Anyway, Chapter 2 notes below the break.


Thursday, May 16, 2013

GW2

Finding myself entranced again by the beauty of this game. Just wanted to share.



Of course, it's not nearly as pretty as it could be. My computer is rather dated. But it gets the point across. Meet Yvinne, my evil sylvari mesmer. She serves as the equal opposite of my favorite character, and causes trouble for the sake of storytelling. So nice to have an evil little plot device.
Yvinne's probably neutral evil, but borders on chaotic evil. Silvaria is true neutral, but can sometimes be neutral good, and other times, she's chaotic neutral.
I have some feels for the two of them. Silvaria, in all her incarnations, tends to be drawn to the darkness, and Yvinne is there to show her what the darkness is capable of. It's interesting... to me, anyway.
I might come back and post a pic of GW2!Silvaria, or I might come back and take more notes. Not sure presently...

Chapter 1: Strengths and Weaknesses

I'm having one of those days!! I told myself this morning that I would reward myself with note-taking today if I could finish all of my work. Well, that was peachy, except I haven't been able to find a definitive "end" to my work! Something new skids across my desk every time I finish something else and I didn't even turn my OWN computer on until after noon. Blaargh!

I really wanted to crack open the book and read more after I got home last night, but Guild Wars 2 ate up my free time. It'll be ToR tonight, because I'll want to keep my sicky honey company if he's up to playing. He's got a bad ear infection. :(

He admitted to me this morning that he may put forth a little more effort into learning code. That makes me happy! But it could have just been the meds talking. ;) Heeeehehe.

ANYWAY. You're not here for my BABBLING. Part two of Chapter 1 is beyond the break!


Wednesday, May 15, 2013

Chapter 1: History!

I like this textbook. As I've scanned over the contents, it seems very well-written and clear, with good information and explanations. It begins with the history of C, and how it came to be. The links are going to typically be Wikipedia links that I skim over for additional information and provide here for the convenience of anyone following along.

The textbook I'm using.


Tuesday, May 14, 2013

More Filing and Getting Ready to Take Some Notes

I'm procrastinating again... I really don't want to do this filing.

So I'll make a blog post instead.

Yesterday was odd. I don't know why I was hit with such icky feelings all of a sudden like that. I just know that I felt somewhat like I did back in College Algebra... "This should really make sense, and I feel like this should really work... but it doesn't." From what I understand, there's a lot of that in coding as a whole haha.

It makes me nervous, though, because if I don't have the mind to wrap around these things, my project with my fiance is up in smoke before we can even start on it. He has already determined that he's not a coder. If I can't learn this and get good at it, we'll be a couple of really creative people without the means to produce what we want. Puts on the pressure. :(

I'm also nervous because I'm afraid that these ideas we have aren't going to be interesting to other people. I'm scared that our scope is too big, and we're trying to do too much... Is all of this work going to pay off with a product that is thoroughly enjoyable by everyone, or will Andrei and I be the only ones enjoying it?

Anyway, I'm going to reward myself today. Once I'm done with this filing, I'm going to start taking notes from my textbook in between answering the phone and checking emails. I'm still working on the DG Scripts and triggers for my zone in TBA, I just have to step back from them and tackle something different for now.

Monday, May 13, 2013

Frustrated, Nervous...

Got hit with a double-whammy while I was working on something. Just kind of filled with this anxiety that has my chest all tight and my mind not willing to work.

That makes it exceedingly difficult to absorb and apply information.

I've decided that I'm probably going to take a step back on the scripting. The logic is still not making sense, and that means I rushed in too fast. Maybe it wouldn't be a bad idea to really tackle coding right now, and not wait until I have the scripting down. I thought knowing the scripting would make it easier to learn the coding.

Or maybe I just need to not make any decisions right now and wait until I'm not feeling anxious. :( Wanna go home, but it's not even 3.

Bleh!!

Bleh, I say!!!

Slow Work Day

That means I can work on other things at my desk, yay!

Throughout the day, I'm going to be working on finalizing the last two triggers for my zone in TBA. The first one, I referenced in this post I made the other day, about the rose in the rose bush. I still haven't bugchecked it, but I'm going to today. I also found this from my early posts on the TBA forums:




From Fizban,
The following was written in this post, not in trigedit, and as such is completely untested, but should work, or at the very least work with very minor changes.
Type: Random
Numeric Arg: 100
wait 300 s
if !%self.contents%
%load% mob <insert mob vnum>
else
set curr_item %self.contents%
while %curr_item%
if %curr_item.vnum% == 59320
halt
else
set %curr_item% %curr_item.next_in_list%
end
done
%load% mob <insert mob vnum>
end
...you'd just need to have the load script on her have a check for the vnum of the room she is currently in and then have her load a rose and put it in the container if she is in the appropriate room.




Comparing this to what I have, they are rather different. :/ Gotta work on fixing that.

The next trigger I'm going to work on is going to give a druid healer a few protective spells to cast on people present within the room. Ideally, I'd love for him to have a couple of spells he casts if someone stands in the room long enough, and then stops casting once the effects of those spells are present on the character(s), but that's going to be much more elaborate than a list of random spells he casts every 10 seconds haha.

We'll see what happens. I'm going to be updating the post referenced above with my changelog!! If anyone here is actually paying attention for my bug-checking methods, that's where to keep an eye out!

Sunday, May 12, 2013

Ho Hum

Quiet because of Mother's Day. Not too much happened in the coding area, though I did have a good time with my family today. Fiance and I went to Mom and Dad's for amazing italian take-out, but before the evening was over, Grandma lost her balance and fell. She's been complaining about vertigo, and I think that's what did it. She hit her head, but seemed okay after drinking some cold water.

Fiance and I came home and we've honestly been playing ToR all night. My 'Sin is almost 55, and we're enjoying being beastly together on our mains (he has a Sorc). I totally love playing our toons together, because we can sit and banter back and forth about RP things. I have this tendency of being knocked off of the edges of platforms by knockbacks, and so we were laughing earlier about how his character would be constantly scolding mine for falling all the time.

"Silvaria, we're going to be fighting on a Gravity Hook. DO NOT stand near the edges."
"Okay, okay! I got it!"
"Are you sure? You've almost plummeted to your death how many times? Ten, now?"
"...Eleven, after the last one in the mining shaft....."

We have a lot of fun with our characters, heehee.

Here's Silv with a kind of incomplete set... She's 54 right now and I'm not sure what her gear will look like when she hits 55, but I know I want to change it. We affectionately call this set "swamp beast" lol.



Anyway, not much is going to happen tonight. Just going to enjoy the evening with Fiance and be happy. :)

Saturday, May 11, 2013

Mapping out new triggers

I have two that I'm planning right now... One of them is based on one that Rumble wrote, and the other is one I'm going to tackle on my own.

The point of the first is to respawn a cosmetic item into a container. The item is trash and would have no use except to be used as a token of friendship or affection. It is a white rose that the player would have to "pluck" from a rose bush. Unfortunately, the triggers can't reload items directly to containers, so I need a mobile to do it for me. My nymph seemed the best choice. It will look like this, more or less:

Name: Reload Rose in Rosebush - Obj 59319
Vnum: 59305
Trigger Intended for: Mobiles
Trigger Type: Load
Numeric Arg: 100
Argument: None
Commands:
if %self.contents% < 0
eval %self.contents%
if %self.contents.vnum% == 59320
halt
break
if %self.contents.vnum% != 59320
%purge% %self.contents%
end
if %self.contents% > 1
set nymph mob 59309
set rose obj 59320
%load% %nymph%
%echo% A beautiful nymph steps out from a tree nearby and approaches the rose bush.
%load% %rose% %nymph.inv%
wait 2s
%echo% She examines the rose bush and tends to it gently. Where her hands pass, more roses bloom.
%force% %nymph% put %rose% in %self%
wait 2s
%echo% Satisfied, the nymph nods and seems to melt into the foliage, ignoring all around her.
end

I'm going to pause here for now, and map out the other trigger in a while. Perhaps going to game for a bit after I test my logic for this particular trigger. :)

Edit: Logic was faulty in a few different places... I'll map out what changes I make here, I just don't want to think about it right now so I don't get too frustrated. XD

Change 1:
Trigger Intended for: Objects
Trigger Type: Global Random
(It'll have a chance to fire every 13 seconds without anything actually happening this way.)

Change 2:
Commands:
if %self.contents% < 0
eval %self.contents%
if %self.contents.vnum% == 59320
halt
end
if %self.contents.vnum% != 59320
%purge% %self.contents%
end
Add line: end
if %self.contents% > 1
(Got an eval error after this change. This is where I took a break. I'm going to have to read up on eval.)

Some Off-Topic Things While I Wake Up

Today is going to be a good day.

Yesterday was good, too, but full of filing and rushing. It left me exhausted and unwilling to do anything but curl up with fiance after movie and sleep.

Speaking of movie! Iron Man 3 was pretty damn good! I won't spoil anything, but we both enjoyed it thoroughly more than #2. Anymore, I judge stories by how well they suspend my disbelief, and after seeing the mindfuck that was Dark City and being seriously messed up for a good two days after that, very few movies are capable of instilling that feeling anymore...

But the action was good, and the story was interesting, even if some parts were not explained very clearly in words. Sometimes it is good to leave things to the viewer's interpretations, but important plot points shouldn't be on that list of things, lol.

Anyway, today is going to be good because it is Saturday and we are being lazy kitties and only doing what we want to do. For me, that is scanning over my C textbook, testing and writing triggers in TBA, and possibly playing some ToR later on. Fiance seems to be pretty happy playing his Sith Sorcerer at the moment, but he told me earlier that we'd be able to write some today, too! Whether that means we RP or world-build, I'm not sure... But either would make me a happy camper!

Anyway, going to go finish my coffee and be lazy. If I take notes today, I will make another post. :D

Friday, May 10, 2013

It's filing day today at work. I can't pay any attention to the web. Sadface.

It's also bring your fiance to work day. The first of many, now that he doesn't have anything to do during the summer. Mwahahahaaa...

We're planning to see Iron Man 3 tonight, but there will be about 3 hours between work and movie that I might be able to work on some things. Still have not figured out the mfollow problem from the last trigger I posted, but finding out he was re-enlisting last night put a halt on any progress I might have been able to make. After talking about that for a few hours, and getting the zombie mac set up, we opted to kick asses on our Bounty Hunters in ToR.

Very unrelated to coding. My apologies. I really don't want to file this paperwork. Aggh.

Thursday, May 9, 2013

Sadhappy

My fiance is re-enlisting into the military. :( Makes me a sad code-girl.

But what makes me a marginally happier code-girl is... I have Ubuntu Server on my zombie-macbook now.

Seeeeeeeeeeeeeeeeeeeeeee?




Happpyyyyyyyyyyyyyyyy...........

Template 2

Also, expect the template to change while I fight it to look the way I want it to.

This is a nice look. :D
Distracted from scripting AND work today. Thinking about the scope of what will need to be done for the project that inspired this blog, and it is daunting, indeed.

I will probably mutter about snippets here, and they may not seem totally relevant to coding as a whole, but they will be relevant to my adventure into coding. Every program must have a purpose, yeah?

Haha, I Matrix'd without even realizing it. My fiance would be proud.

(I saw The Matrix for the first time only a few weeks ago. Bad nerd, I know.)

Anyway, every program must have a purpose, and each program I'll be writing must be carefully placed within this project so everything works together seamlessly. I have ideas for the aesthetics (which are incidental, sadly), but those will take a bit of work as well.

There is so much I'd love to do, but I can't start yet. I especially need to graduate from DG Scripts -- which are a great introduction into the logic processes I need to know -- and actually tackle some C, soon. I have a book that is highly recommended, by K. N. King. As I read through, this will most likely be where I take notes.

((I'm also very distracted by one Mads Mikkelsen. In his role as Dr. Hannibal Lector in NBC's Hannibal, he has the perfect face, demeanor, and accent for the new incarnation of my fiance's character. I could spazz about this character here, but I'll contain myself for the benefit of this blog... for now, anyway.))

Tearing Apart Triggers - DG Scripts 2

I'm going to take this entire thing apart, line by line, to see if I understand everything that's going on here. PC stands for Player Character throughout this. This trigger was provided by Rumble of tbaMUD, and more like it can be found at tbaMUD.com! :D

Also, I apologize for the mess. The line wraps make this kind of difficult to read. :(


Name: 'Horse Petshop - 203',  VNum: [  338], RNum: [  259]
Trigger Intended Assignment: Mobiles
Trigger Type: Command , Numeric Arg: 100, Arg list: *
(This is saying that the trigger affects a mobile, issues a command (or multiple) to that mobile, fires 100% of the time, and queries all commands sent (the * for Arg list).)
Commands:
if %cmd.mudcommand% == list
  *
  %send% %actor%
  %send% %actor%  ##   Pet                       Cost
  %send% %actor% ------------------------------------
  %send% %actor%   1)  a horse                   1500
  %send% %actor%   2)  a fine mare               1800
  %send% %actor%   3)  a stallion                3000
  (For this section, If the command entered into the MUD matches "list" exactly, send the PC these lines of text, designed to mimic a true shop.)
   *
elseif %cmd.mudcommand% == buy
(If the command is buy, instead of list...)
  if %actor.gold% < 1500
  (First, check if the PC has less than 1500 coins)
    tell %actor.name% You have no money, go beg somewhere else.
    halt
    (If they do have less than 1500 coins, send this line, and stop the trigger.)
  elseif %actor.follower% && !%follower.is_pc%
   (This line is meant to keep the PC from having more than 1 pet. If the PC has more than 1500 coins, has someone following them, and that follower is NOT a PC (exclamation point is negation.))
    tell %actor.name% You already have someone following you.
    halt
    (Send the PC this message and stop the trigger)
  end
  (Ends the If statement that determines if the PC is too poor to purchase a horse. If both of the above statements are true (the PC has over 1500 coins AND the PC does not have an NPC follower), the trigger is allowed to continue.)
  if horse /= %arg% || %arg% == 1
  (Here is where it gets fun. This checks if "horse"OR 1 are substrings of the argument/command. The argument has to begin with "buy" or the trigger won't execute this section.)
    set pet_name horse
    set pet_vnum 202
    set pet_cost 1500
    (If either of the above two are true (argument is "buy horse" or "buy 1"), set the following variables: pet_name = horse, pet_vnum = 202, pet_cost = 1500)
  elseif fine /= %arg% || mare /= %arg% || %arg% == 2
  (If the command does not include horse or 1: then check if "mare" is a substring of the argument/command OR if the argument/command is 2)
    set pet_name mare
    set pet_vnum 204
    set pet_cost 1800
    (If it is, set the following variables: pet_name = mare, pet_vnum = 204, pet_cost = 1800)
  elseif stallion /= %arg% || %arg% == 3
  (If the command does not include horse, mare, 1, or 2: then check if "stallion" is a substring of the argument/command OR if the argument/command is 3)
    set pet_name stallion
    set pet_vnum 205
    set pet_cost 3000
    (If it is set the following variables: pet_name = stallion, pet_vnum = 205, pet_cost = 3000)
  else
  (If the argument has anything in it other than those three things (horse, mare, stallion; 1, 2, 3))
    tell %actor.name% What? I don't have that.
    halt
    (Send this message and stop the trigger)
  end
  (End the if statement determining what item is being bought)
  *
  if %actor.gold% < %pet_cost%
  (Check if the PC's total amount of coins is less than the cost of the horse)
   tell %actor.name% You don't have enough gold for that.
   (If the PC has less coins than is needed to buy the horse, send this line of text)
  else
    %load% mob %pet_vnum%
    %force% %pet_name% mfollow %actor%
    dg_affect %pet_name% charm on 999
  (If the PC DOES have enough coins to buy the horse, the "transaction" begins by loading the proper horse's vnum (which is determined by the variables set a few lines ago), and then forcing the horse to follow the PC. Then, a charm effect is cast upon the horse, so that it will obey the PC's commands) (This is actually where I'm having trouble. The follow command doesn't seem to work... That's my project, today...)
    emote opens the stable door and returns leading your horse by its reins.
    (This makes it LOOK like the stablemaster is opening a door and leading the horse to you. This only fires after the mob is loaded.)
    tell %actor.name% Here you go. Treat'em well.
    nop %actor.gold(-%pet_cost%)%
    (Finalize the transaction by having the mob take the PC's coins. This is a simple expression of x-y, where x is how much gold the PC has total, and y is the cost of the pet, which tells the nop command what quantity of gold the PC has left)
  end
  (Finally ends the if statement that controls what to do if the command is "buy")
elseif %cmd.mudcommand% == sell
  tell %actor.name% Does it look like I buy things?
  (If the command is not "list" or "buy", send this line of text)
else
  return 0
  (If the command is none of these things, return 0, which allows any other command sent and not stopped by the trigger. It's kind of hard for me to explain.)
end
(End the entire trigger. Phew!)

Wednesday, May 8, 2013

Template

This template is kind of screwing with me. It has set solid black backgrounds in front of my image, and then reset all of my text colors, and now I can't get it to change them back.

But my background image is showing.

Rrgh.

DG Scripts 1

DG Scripts are my first project. I've already learned a lot about them, but I just had my first big success.

1) Name         : Iryli Loads Key - Obj [59322]
2) Intended for : Mobiles
3) Trigger types: Act 
4) Numeric Arg  : 100
5) Arguments    : *
6) Commands:
wait 2s
if %arg% /= whispers to you, 'May the Cycle balance all things.'
  %load% obj 59322
  %echo% Iryli inclines her head and speaks in a low voice. 'Of course. Here you are.'
  give key %actor.name%
  wait 2s
  %echo% Iryli resumes her position. 'Have a pleasant day.'
  wait 1s
else
end
W) Copy Trigger
Q) Quit
Enter Choice :
q
Do you wish to save your changes? :
y
Trigger saved to disk.

34H 100M 88V >
detach mob 59306 59303
Trigger removed.

34H 100M 88V >
attach mob 59303 59306
Trigger 59303 (Iryli Loads Key - Obj [59322]) attached to Iryli, the Keeper's Guard
[59306].

34H 100M 88V >
whisp Ir May the Cycle balance all things.
You whisper to Iryli, the Keeper's Guard, 'May the Cycle balance all things.'

34H 100M 88V >

Iryli inclines her head and speaks in a low voice. 'Of course. Here you are.'
Iryli, the Keeper's Guard gives you a brass key wreathed in vines.

34H 100M 88V >

Iryli resumes her position. 'Have a pleasant day.'

34H 100M 88V >
dance
You dance around happily.
-----------------------------------------------------

I had help, but I couldn't for the life of me figure out whyyy it was not working.

Pretty much all this is doing is this mob (Iryli) only makes an action if the argument that is sent (the * in the Arguments field at the top makes the trigger analyze ALL commands) matches the substring (/=) of "whispers to you, ' May the Cycle balance all things.'" So this won't activate if the phrase is said in any way but a whisper.
She then loads the key into her own inventory, makes a short action for show, gives the key to the %actor%, which is the PC that sent the whisper, and makes another short action for show.
I'm SO THRILLED THIS WORKS!!

Obligatory 1st Post

Gonna retire the other blog and use this as a place to document all of my discoveries while I teach myself how to design and write code.

I'll come up with a nice look for it eventually. Maybe. :D