Welcome Guest ( Log In | Register )


2 Pages V   1 2 >  
Reply to this topicStart new topic
> An introduction to programming, Client does not matter, it is all about the right mindset!

 
Mygale
post Oct 29 2007, 02:47 AM
Post #1


Teacher of the Rhythm *******
Group: Aetolians
Posts: 921
Joined: 23-November 04
Member No.: 163

This topic serves a simple purpose: to explain what programming is, and most of all, what programming is not. While I love helping people out, recently I've been getting pretty annoying with a number of requests (no, not you, person-whom-I-still-owe-a-bit-of-coding-that-I-can't-seem-to-get-around-to) of people who are struggling with a programming problem. But in all reality, most of these problems are nothing more than a lazy person who doesn't want to use google, or doesn't want to use their head. I know these people are actually pretty smart, and that's why catering to those questions makes me cringe. Anyhow, now that my annoyances have been adressed, let's get on with it.

Step one: THINK!

QUOTE
Programming is nothing more than breaking down a process into little chunks and identifying what is needed to do something else. Once you know the chunks, you know how to write it in the language you program in. If you don't know how to do something, you can search the net for your very specific action (e.g. popup a window, split a string by the commas in it, calculate the remainder of a division) and you'll find an example of that in no time. All it takes then is to adapt it to your situation.


That is what I wrote elsewhere on these forums. You do not need to code to do the first and most important step of programming: thinking. Split a lengthy process up in pieces before trying to type stuff out. For example, let's say you want an auto-sipper.

CODE
I want to sip when I get low.


... becomes ...

CODE
1) I want to sip health when below 2000 health.
2) I want to sip mana when below 1500 mana


But how? The information is all in my prompt!

CODE
1) Use the prompt to do the following:
1.1) I want to sip health when below 2000 health.
1.2) I want to sip mana when below 1500 mana.


But, wait wait wait. I get my prompt all the time. What if it gets spammy? I don't want to empty my health vial like crazy when I am low and I get a lot of other prompts. So when -should- I sip? Hrm... I can only sip when I have had the 'you can sip another health or mana elixir.' message.

CODE
1) Use the prompt to do the following:
1.1) See if I am allowed to sip.
1.1.1) I want to sip health when below 2000 health.
1.1.2) I want to sip mana when below 1500 mana.
1.1.3) If I did either of those, forbid myself from sipping again.

2) Use the 'sip again' message to:
2.1) Keep track of whether or not I can sip.


That's looking to shape up just fine. But think about it, are we missing something? Oh crap, yes we are. What if I am sleeping while trying to sip? What if I have stupidity? Amnesia? I won't be sipping, and worst of all, I'll never sip again. So what do I want to happen?
  • I want to retry sipping every 5 seconds when something doesn't go through, until it actually happens.
  • After it went through, I still need to wait until I am allowed to sip again.

CODE
1) Use the prompt to do the following:
1.1) See if I am allowed to sip and whether I should (re)try sipping.
1.1.1) I want to sip health when below 2000 health.
1.1.2) I want to sip mana when below 1500 mana.
1.1.3) If I did either of those, remember to sip again in 5 seconds if I haven't.

2) Use the drinking-from-a-vial message to:
2.1) Tell myself that I don't need to retry drinking again.
2.2) Forbid myself from sipping again.

3) Use the 'sip again' message to:
3.1) Keep track of whether or not I can sip.


Now, that looks just about perfect! Maybe we didn't reason all this far, and ended up coding at one of the previous steps, because we didn't foresee sipping not going through. That's not a problem, since programming is an iterative process that is about comparing the various steps with what you know, understand and expect to happen in turn. Likewise, the above example can be improved to take account for illusions: a crafty syssin or illusioner could make the sipper we 'thought up' lock up in a state of not sipping. How and why this happens is an exercise to the reader, as well as thinking of a way to solve this.

Step 2: HOW?

This brings the next issue, okay, how can we do what we want it to do? Well, due to the nature of the plan we wrote, we actually have the solution, but we do not know the way to make the client we use do what we want. And since I don't know what you use, I am not going to go into any specific language, be it Zmud, Python, VBScript or others, since the things of interest are pretty much the same.

Basically, everything you want to do depends on two things: remembering stuff and the ability to make choices based on that stuff.

Remembering stuff can be done through variables. Essentially, they're ways to refer to some information you can change to your liking. You decide what to put in it, and what you consider to be acceptable values. Often, you have a yes/no choice for something. An often made choice is to pick the number 1 to denote 'yes' and the number 0 to mean 'no'. How to use variables and what intricacies come with them in your client, is something you'll have to find out for yourself. The magic word is 'variables'.

Making choices is done through if-statements. They basically exist out of a condition, action(s) to perform when the condition checks out, and possible action(s) to perform if the condition does not check out. In other words, an if-statement is a simple yes-or-no kind of question. An example (in words, not code!) would be: if my target variable is 'kylan', THEN I want to lick him, OTHERWISE (else) I want to bash my targets brains in. How to do things like these in your language of choice, you'll have to find out for yourself. The magic words are 'if statement'.

Now, these two essential tools to programming simple logic also introduce you to the fact programming means you have to stick to the rules of the language. Something that may make sense to you, may sound like chinese to the computer and make it unable to understand what you mean. So if you get errors, DOUBLECHECK YOUR CODE. I can not stress this enough. For example, pretty much every language has a means of saying 'this is the end of the actions to be performed for this if-statement'. So don't leave it away because it is the end of the script, but just be nice and tell the computer the if-statement is done. To take it a step further, you can consider any command as a mold where you fill in the blanks. For example, 'IF <condition> THEN <action> END' could become 'IF target is kylan THEN lick kylan END'. You don't ever remove the parts of the mold. If you bother me with errors, and you're not sticking to the basic mold (also called syntax in programmers language) I'm killing you, understand?

Step 3: RINSE & REPEAT

Stuff can go wrong. Stuff will go wrong. There's no escaping it. Some things that might pop up are as follows.

You'll probably get (flashy) errors because you make mistakes in syntax. Figuring out where you go wrong should usually be simple to deduce if you compare your code with a working example of an if-statement, for example.

Or maybe you make a mistake in the logic. Essentially, you'll have to go back to the first step, and think it over. Where did it go wrong? How can I improve and adjust for that situation to not happen again? (Oh, by the way, find out how to turn your triggers off. You don't want to empty ten vials if you happen to forget your 'can I sip?' condititions with your prompt!)

In any case, it involves finding out what went wrong. And <insert-your-favorite-searchengine-here> will help you find what you need, as long as you state your questions simple. Not 'track health change zmud doesn't work' but rather the error message itself. You'll probably end up at a page explaining what you did wrong, and with a bit of adjustment, you can usually fix it in a matter of moments. That and you've learned yet another thing.

All together, programming is slow to start out. The more experience you get, the more you skip step 1, step 2 and step 3, and the more they all mingle together, especially for small projects like a sipper. Don't get discouraged if it takes you a few days to get your sipper working if you haven't programmed before, but keep working at it and try to find your own solutions, since that will make it oh so much more satisfying.

Step 4: PEOPLE READING THIS

If people want to ask questions here, fine. If you want to help them, even better. But try to stick to the general ideas suggested in this thread, since I do not want another 'best things in zmud' topic or a 'lua over vbscript' discussion here. Also, don't give clear-cut answers. If people ask here, they clearly want to learn, so show them where thought-processes go wrong. Thank you.

Oh, and people learning.. thanks for putting up with reading this far and I hope it will help you any in whatever you're going to produce.


--------------------
Mushclient related needs?
ExtendedSays, (FREE) - NoAutoSay (FREE) - Prompt Pack, (FREE)
Autobasher - Offensive - Movement Correction - InfoBoard - .. and more!
QUOTE
You are now wearing a white crow pendant.
One of your reflections has been destroyed! You have 17 left.
A white crow pendant rages, seeing its attack fall on your reflection.
Khepri ponders a white crow pendant's profile, deep in consideration.
Khepri, the Trickster says, "Sneaky, sneaky."

Bah. I hate signatures. And I still do. It's just that I feel all popular this way.
2007/11/05 21:12:16 - Laswell quit the city.
Go to the top of the page
 
+Quote Post

 
Oddity
post Oct 29 2007, 03:20 AM
Post #2


Mischief's Victim ***
Group: Aetolians
Posts: 50
Joined: 13-October 07
From: Moreton Island, Australia
Member No.: 10,858

QUOTE
Step one: THINK!


Best advice ever. I am a very low level learner when it comes to coding, but there have been several times when I went to make a topic to ask a question, and simply wording the problem so others could help me helped me to understand what I needed to do to fix the problem. Thus never had to actually create the topics. happy.gif
Go to the top of the page
 
+Quote Post

 
Sagla
post Oct 29 2007, 04:33 AM
Post #3


Teacher of the Rhythm *******
Group: Aetolians
Posts: 723
Joined: 10-January 06
From: New Zealand
Member No.: 2,264

Another 'best' advice: Google.

Might not apply to zMUD scripting as much, but in terms of programming, Google is a man's best friend.


--------------------

<3 Lucia
Go to the top of the page
 
+Quote Post

 
Mygale
post Oct 29 2007, 01:09 PM
Post #4


Teacher of the Rhythm *******
Group: Aetolians
Posts: 921
Joined: 23-November 04
Member No.: 163

I did refer to search engines, didn't I? And everyones favorite seachengine is Google, soo...


--------------------
Mushclient related needs?
ExtendedSays, (FREE) - NoAutoSay (FREE) - Prompt Pack, (FREE)
Autobasher - Offensive - Movement Correction - InfoBoard - .. and more!
QUOTE
You are now wearing a white crow pendant.
One of your reflections has been destroyed! You have 17 left.
A white crow pendant rages, seeing its attack fall on your reflection.
Khepri ponders a white crow pendant's profile, deep in consideration.
Khepri, the Trickster says, "Sneaky, sneaky."

Bah. I hate signatures. And I still do. It's just that I feel all popular this way.
2007/11/05 21:12:16 - Laswell quit the city.
Go to the top of the page
 
+Quote Post

 
Janus Anfini
post Oct 29 2007, 05:11 PM
Post #5


The Ample Soul Physician. **********
Group: Validating
Posts: 6,047
Joined: 2-February 05
From: Kelsys Residential Dome.
Member No.: 615

I wholeheartedly recommend newbie programmers actually write out their theoretical function just like Mygale did above. Saved my ass a lot early on.


--------------------
Go to the top of the page
 
+Quote Post

 
Acino
post Oct 29 2007, 05:15 PM
Post #6


Messiah of Death *********
Group: Aetolians
Posts: 3,598
Joined: 22-November 04
From: Slovakia
Member No.: 116

As Mygale pointed out, you have to break the operation into pieces. I mean, you have to code in step by step, the way you actually do that thing you want it to do for you. Like the sipper, when you see you are low you try to sip, when you can.

So you will code in first the point when it should sip, then you code in 'sip balance', then code in reset in case it does not get through, just like you would send it again if you did not see sipping health. Just follow your thought line and translate it into programming lanugage.


--------------------
I will either find or make the way. (Hannibal)
Simply, I have ignored the axiom. (A. Einstein)
I am not bound to be such as other expect me to be. It is their mistake not my failure. (R.P.Feynman)

Utansi tells you, "I asked who the best Combatant was yesterday too, Galleus said you're the best."

QUOTE (Kikon)
Unavoidable PvP? It's a game, you play to fight. This isn't some glorified chatroom, jesus christ. Go screw around on IRC if you want something like that.

QUOTE (Moirean)
War is not a 2-day affair. Unless it's a Holy war. Against Chak's Order.

QUOTE (Galleus)
It's not that I think it's wrong to do, I would metagame the hell out of a system like this.

QUOTE (15 mins before losing the war)
Captain Edhain says, "Today we have no hope."
Go to the top of the page
 
+Quote Post

 
Darliea
post Oct 29 2007, 06:31 PM
Post #7


I can break very nearly anything. *********
Group: Aetolians
Posts: 2,044
Joined: 29-January 07
From: Houston, Texas USA
Member No.: 5,225

QUOTE(Mygale @ Oct 29 2007, 08:09 AM) [snapback]314133[/snapback]
I did refer to search engines, didn't I? And everyones favorite seachengine is Google, soo...

Meh. I prefer MSN myself.

Thank you for explaining what the IF thing is for. Made a lot more sense than anything anyone else has told me.


--------------------
QUOTE
(The Black Arrow): Mazzion says, "God damn woman!"

(The Black Arrow): Mazzion says, "You like, bash too much."
QUOTE
Keroc pumps out at a gigantic mother icewyrm with a powerful side kick.
He connects!
Keroc has scored an ANNIHILATING CRITICAL hit!!!
The final blow proves too much for a gigantic mother icewyrm, who expires, pitifully.
A gigantic mother icewyrm has been slain by Keroc.
With a final, monstrous roar, a gigantic mother icewyrm collapses onto her side, revealing an entrance into deeper portions of the caverns.
An ear-splitting howl of rage tears through the hollow caverns.
A large pile of sovereigns spills from the corpse.

You mutter, "Showoff."
Go to the top of the page
 
+Quote Post

 
Mygale
post Oct 30 2007, 01:41 AM
Post #8


Teacher of the Rhythm *******
Group: Aetolians
Posts: 921
Joined: 23-November 04
Member No.: 163

QUOTE(Darliea @ Oct 29 2007, 07:31 PM) [snapback]314166[/snapback]
Thank you for explaining what the IF thing is for. Made a lot more sense than anything anyone else has told me.


I'm glad you found it useful. It is a really simple concept, and everyone expects you to know what it means. So I figured I'd add it in just in case. happy.gif


--------------------
Mushclient related needs?
ExtendedSays, (FREE) - NoAutoSay (FREE) - Prompt Pack, (FREE)
Autobasher - Offensive - Movement Correction - InfoBoard - .. and more!
QUOTE
You are now wearing a white crow pendant.
One of your reflections has been destroyed! You have 17 left.
A white crow pendant rages, seeing its attack fall on your reflection.
Khepri ponders a white crow pendant's profile, deep in consideration.
Khepri, the Trickster says, "Sneaky, sneaky."

Bah. I hate signatures. And I still do. It's just that I feel all popular this way.
2007/11/05 21:12:16 - Laswell quit the city.
Go to the top of the page
 
+Quote Post

 
Janus Anfini
post Oct 30 2007, 03:15 AM
Post #9


The Ample Soul Physician. **********
Group: Validating
Posts: 6,047
Joined: 2-February 05
From: Kelsys Residential Dome.
Member No.: 615

Protip: Master IF statements right now so you don't suck.


--------------------
Go to the top of the page
 
+Quote Post

 
Sagla
post Oct 30 2007, 12:02 PM
Post #10


Teacher of the Rhythm *******
Group: Aetolians
Posts: 723
Joined: 10-January 06
From: New Zealand
Member No.: 2,264

QUOTE(Mygale @ Oct 30 2007, 02:09 AM) [snapback]314133[/snapback]
I did refer to search engines, didn't I? And everyones favorite seachengine is Google, soo...


My bad, I just skimmed through it and missed it.


--------------------

<3 Lucia
Go to the top of the page
 
+Quote Post

 
Jurlgrann
post Dec 24 2007, 09:36 AM
Post #11


Pawn of Artifice **
Group: Aetolians
Posts: 30
Joined: 18-September 07
From: Bowling Green, Kentucky.
Member No.: 9,869

This helps a lot... you just have to remember that it really is a completely different language. I may actually start doing some coding on my own. Maybe. Thanks. smile.gif


--------------------
Go to the top of the page
 
+Quote Post

 
Xixity
post Mar 10 2008, 08:30 PM
Post #12


Lleisian Scholar ******
Group: Aetolians
Posts: 385
Joined: 8-March 08
Member No.: 18,039

I want to set up a writhe balances and healing for it as a first script for myself.

Is I want done is possible??? and if it makes sense:
if I have balance then Writhe if needed.
if I dont have balance then wait for it and start writhing
if I'm writhing then dont perform any other action.
once I'm done writhing I want both variables to be set to know not to writhe anymore

Writhe = 1 Then writhe
Writhe = 0 Dont
Writhing = 1 Dont perform any other action

All the messages that need to be writhed set Writhe to 1
All the messages that say I've started writhing set Writhing to 1
All the messages that say I'm free set Writhe to 0 and Writhing to 0

If I'm in the wrong part of the forum or am doing something wrong tell me please
Go to the top of the page
 
+Quote Post

 
Garok
post Mar 10 2008, 09:26 PM
Post #13


Lleisian Scholar ******
Group: Aetolians
Posts: 347
Joined: 17-December 07
From: Not home, mostly.
Member No.: 13,861

Your scheme looks good. Now get to the coding ^^

Mind you, unless you have a bigger system, Writhing = 1 won't do much, as you'll probably do everything yourself (manually). An Output message warning you could be good for starts.


You posted in the right part of the forum, and Mygale posted earlier you could ask questions if they were thread-related.. This being your first script, you're qualified, I'd say.


--------------------
GENERATION 22: The first time you see this, copy it into your sig on any forum and add 1 to the generation. Social experiment.
Go to the top of the page
 
+Quote Post

 
Xixity
post Mar 11 2008, 02:16 AM
Post #14


Lleisian Scholar ******
Group: Aetolians
Posts: 385
Joined: 8-March 08
Member No.: 18,039

Problem I dont know how to solve is if I dont have something, like balance, then I dont know how to make it recheck constantly until I do have it. (Nexus)
Go to the top of the page
 
+Quote Post

 
Khezar
post Mar 11 2008, 02:44 AM
Post #15


Definition of Valor *****
Group: Aetolians
Posts: 287
Joined: 5-January 07
Member No.: 4,662

I believe most people have a prompt trigger that runs a check for balance, any actions that need to be performed, etc. I know that's how I do things like healing and command queueing.


--------------------
"Men are equal; it is not birth but virtue that makes the difference." ~ Voltaire

Go to the top of the page
 
+Quote Post

 
Eled
post Mar 26 2008, 07:31 PM
Post #16


Definition of Valor *****
Group: Aetolians
Posts: 263
Joined: 6-February 07
Member No.: 5,374

Okay So I am going to try using this train of thought!

I want to outc and eat lung slice when I am paralyzed so

1. Check if I am paralyzed with Diagnose
1.1. IF paralyzed outc 1 lung slice
1.2 eat lung slice

2. Do not eat any herbs untill the Message says I can again


does that logic sound right?


--------------------
QUOTE
The body of Auresae, Goddess of Fire appears in a flash and Her soul descends to
fill it, causing the previously expressionless face to fill with emotion.
Go to the top of the page
 
+Quote Post

 
inasnum
post Mar 26 2008, 08:41 PM
Post #17


Teacher of the Rhythm *******
Group: Aetolians
Posts: 560
Joined: 4-May 06
From: Behind you!
Member No.: 2,597

Hopefully you'd know if you were paralyzed before diagnosing.

Be sure to keep track of your herb balance too. If you're off herb balance, no use downing a ton of lung slices.


--------------------
(Bloodloch): Rustic says, "Dude I friggin love Articuno, hes like the best pokemon there is."

QUOTE
Lleis, Goddess of Renewal has been slain by Dhar, the Underking.
Go to the top of the page
 
+Quote Post

 
Eled
post Mar 27 2008, 01:17 AM
Post #18


Definition of Valor *****
Group: Aetolians
Posts: 263
Joined: 6-February 07
Member No.: 5,374

QUOTE(inasnum @ Mar 26 2008, 08:41 PM) [snapback]332780[/snapback]
Hopefully you'd know if you were paralyzed before diagnosing.

Be sure to keep track of your herb balance too. If you're off herb balance, no use downing a ton of lung slices.



Right I just got the skill so was trying to stick it in there


--------------------
QUOTE
The body of Auresae, Goddess of Fire appears in a flash and Her soul descends to
fill it, causing the previously expressionless face to fill with emotion.
Go to the top of the page
 
+Quote Post

 
wardeworth
post Jan 21 2010, 06:38 AM
Post #19


Rellyw
Group: Aetolians
Posts: 1
Joined: 7-January 10
Member No.: 51,271

Hello Friends.
I am new here and I want to start new topic here. Please help me guys!!
How to get expertise in J2EE by learn on self support basis at home? I am currently working as PHP Developer and I want to go in J2EE but due to time problem I can not join any institute to learn J2EE but I have good knowledge of Core JAVA and C/C++ and PHP. Can anybody tell me that What is the best way to learn at home?

Please help me.


--------------------
Go to the top of the page
 
+Quote Post

 
Balzic
post Jan 21 2010, 08:27 AM
Post #20


Mischief's Victim ***
Group: Aetolians
Posts: 62
Joined: 12-October 09
Member No.: 50,884

Why do you want to use J2EE? I am figuring you are wanting a database back engine which I would just say to go with MYSQL. MYSQL and PHP are able to integrate quite nicely together.
Go to the top of the page
 
+Quote Post

2 Pages V   1 2 >
Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 

IPB developed by: eXtremepixels
Lo-Fi Version Time is now: 9th February 2010 - 04:09 AM