Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5

See through a Gm's eyes!
#13

I congrats galens for his effort. he wanted to help the server.

but the only thing i tried to said him is just if he is going to learn something that learns c# so he can help more the server Wink

go ahead galens u can do it.
#14

Oh don't misunderstand me. I have NO intention of scripting for ANY shard.

I don't want to learn C yet. Python is a very good demonstration and program to learn with. Its claimed to be easier than C, Java, etc.

Something like sqeak, perl, etc.

I know Run UO uses C.

C is my last project. I still have the other, diverse programs, out there to play with. I give it a year, maybe a slight bit more before I move on from Python, maybe.
#15

galen doesnt play anymore =/
#16

KYO1 Wrote:galen doesnt play anymore =/

I do TOOO!!!! I'm just... MIA, YEAH THATS IT! MISSING IN ACTION!

I'm transmitting this message as we speak from a bamboo cage out in a swamp in Vietnam!!! Honest! I don't even know how I am messaging you, maybe its my lub for all you players!

:icon_twisted::icon_twisted:
#17

I tested your program and not sure if it's the way you want but when I type: "buy" when it says "I have a 'sword' and a 'shield' for sale! Which would you like to 'buy' some sir?" it prints "Care to buy anything else?". Shouldn't that be only after the purchase?

Nice start for only having learned for 6 hours. Keep it up Smile

I'm not expert programmer or anything just used to try out some stuff for fun like you are doing now. Anyway, If you are still improving it to learn here's some food for the thought.

1) Remove some of the unneeded variables. Your while loops use boolean variables to break out of them. You can clean it up a bit by just making it endless loop and breaking out using break statement whenever needed. No change in functionality. Just easier for the reader of your code.
Code:
while 1:
    if selection == 1:
        # do stuff here
        break
    elif selection == 2:
        # do some other stuff here
        break

2) Error checking for user input. What if user decides to type for example "plaa" to a question that accepts integer variables (for example the first question)? Program goes nuts. Exceptions are easy way to handle those situations more gracefully and have your program deal with the situation:
Code:
try:
        selection = int(raw_input("Please choose a reward 1 or 2.\n"))
    except:
        print "Only numerical values accepted!"
Never trust users of your program to do the intended thing Big Grin

More on topic: Nasir said code like this would take max 15mins to write. I'm sure any of the devs that are working/worked on INX can do that. Can't really compare between what more experienced devs like Maka, Nasir or Rob do and code that galens wrote. Difference in amount of experience is huge.
#18

Canaris Wrote:I tested your program and not sure if it's the way you want but when I type: "buy" when it says "I have a 'sword' and a 'shield' for sale! Which would you like to 'buy' some sir?" it prints "Care to buy anything else?". Shouldn't that be only after the purchase?

Nice start for only having learned for 6 hours. Keep it up Smile

I'm not expert programmer or anything just used to try out some stuff for fun like you are doing now. Anyway, If you are still improving it to learn here's some food for the thought.

1) Remove some of the unneeded variables. Your while loops use boolean variables to break out of them. You can clean it up a bit by just making it endless loop and breaking out using break statement whenever needed. No change in functionality. Just easier for the reader of your code.
Code:
while 1:
    if selection == 1:
        # do stuff here
        break
    elif selection == 2:
        # do some other stuff here
        break

2) Error checking for user input. What if user decides to type for example "plaa" to a question that accepts integer variables (for example the first question)? Program goes nuts. Exceptions are easy way to handle those situations more gracefully and have your program deal with the situation:
Code:
try:
        selection = int(raw_input("Please choose a reward 1 or 2.\n"))
    except:
        print "Only numerical values accepted!"
Never trust users of your program to do the intended thing Big Grin

More on topic: Nasir said code like this would take max 15mins to write. I'm sure any of the devs that are working/worked on INX can do that. Can't really compare between what more experienced devs like Maka, Nasir or Rob do and code that galens wrote. Difference in amount of experience is huge.

Ya know, I was reading on try and except later in the morning, then I passed out from lack of sleep. I didn't quite grasp it. Now I get it, instead of it printing any error and exiting the program, its more or less another if statement, except, if raw_input = null, non int or non str, it prints a repetative message. I could squeeze you till your eyeballs poop out. ^_^

I'm going to try and fix, plus add a ton more features with narration.

I appreciate it.
#19

MIA!

visual basic = <3

[Image: ginzodium.jpg]
holding hands <3
#20

good effort Galens, even if its in the wrong language for inx hehe Smile it looks like a cross between QBASIC (due to the format on the print statement and the structure of your loops and else statements) and C (because of the boolean equations for your statements).

this is where my studies have/are taking me with my programming progress:

year 1:
1/2 year spent going a little into QBASIC

year 2:
basic and more advanced concepts of ASM and integrating it with hardware.

we also covered a little bit of C, which was very easy after studying ASM. i found there was a lot more structure to C, smoother flow to it.

year 3:
more advanced asm entirely dependant on hardware (custom built 8-bit microprocessor system) and more.

and we are going to be going into some more intermediate or advanced C programing.

because of ASM i got everyone here beat with my scripting abilities, even maka muhahaha! ASM is a real *****, after spending the amount of time i have with it, id say almost any language is easy (provided you have the time) after that.

difficulty note on asm, or maybe just how nuts my teacher is: out of 7 people, only me and 1 other person finished the final lab this semester because it was so hard.
#21

Eighty Swords Wrote:good effort Galens, even if its in the wrong language for inx hehe Smile it looks like a cross between QBASIC (due to the format on the print statement and the structure of your loops and else statements) and C (because of the boolean equations for your statements).

this is where my studies have/are taking me with my programming progress:

year 1:
1/2 year spent going a little into QBASIC

year 2:
basic and more advanced concepts of ASM and integrating it with hardware.

we also covered a little bit of C, which was very easy after studying ASM. i found there was a lot more structure to C, smoother flow to it.

year 3:
more advanced asm entirely dependant on hardware (custom built 8-bit microprocessor system) and more.

and we are going to be going into some more intermediate or advanced C programing.

because of ASM i got everyone here beat with my scripting abilities, even maka muhahaha! ASM is a real *****, after spending the amount of time i have with it, id say almost any language is easy (provided you have the time) after that.

difficulty note on asm, or maybe just how nuts my teacher is: out of 7 people, only me and 1 other person finished the final lab this semester because it was so hard.

TOMORROW NIGHT, STAFF PARTY AT THA CINEMA BABY!! WE GETTING KRUNK?? YEEEEEE HAHAHA!!!

Bow Down To The ScareKing! jeje

[Image: scarecrowinxkd2.gif]
#22

Code:
import sys

gold = True
Prize1 = 2
Prize2 = 1
Selection1 = raw_input
buy = raw_input
store = raw_input
shop = raw_input
Pr1 = True

sword =  250
shield = 250




while True:
    try:
        Selection1 = int(raw_input("Please choose from 1 or 2.\n"))
    except:
        print "**Numbers only!**\n"
        
    if Selection1 < 1 or Selection1 > 2:
        print"Sorry, I don't understand you!\n"
        
    elif Selection1 == 1:
        gold = 0
        print "You receive nothing!!!! Try again.\n"
        
    elif Selection1 == 2:
        gold = gold + 500
        print "You receive 500 gold!\n"
        True = False
    if gold < 0:
        print "I am sorry, but you do not have any gold to visit the store!\n"
else:
    shop = str(raw_input("To use the store, say 'store'.\n"))
    
    if shop == 'store':
        True = False

        store  = str(raw_input("Welcome to my store. Would you like to 'buy' something sir?\n"))
        
    if shop != "store":
        print "I don't understand."

    if store == 'buy':
        True = False
        buy = str(raw_input("I only have these items for sale, business has been \
rather slow lately. '*You notice him point to a 'sword' and 'shield' collection on the \
shelves*\n"))
    elif store != 'buy':
        print "bla"

    if buy == 'shield' and gold >= shield:
        print "Let me get that real quick...\n"
        print "*You have received a shield!*\n"
        gold = (gold - shield)
        print "You now have ", gold, "gold left!\n"
    elif buy == 'sword' and gold >= sword:
        print "Let me get that real quick...\n"
        print "*You have received a sword!*\n"
        gold = (gold - sword)
        print "You now have ", gold, "gold left!\n"

    if gold == 0:
        print "I am sorry, but you have ", gold, "gold left. It is not enough to buy any item here! Come back when you have money sir!\n"
        Pr1 = False

anyone give me a hand please? I have spent 2 hours editing one area. Someone tell me how I can get

Code:
if shop == 'store':
        True = False

        store  = str(raw_input("Welcome to my store. Would you like to 'buy' something sir?\n"))
        
    if shop != "store":
        print "I don't understand."

    if store == 'buy':
        True = False
        buy = str(raw_input("I only have these items for sale, business has been \
rather slow lately. '*You notice him point to a 'sword' and 'shield' collection on the \
shelves*\n"))
    elif store != 'buy':
        print "bla"


to stop saying:

Quote:Please choose from 1 or 2.
1
You receive nothing!!!! Try again.

Please choose from 1 or 2.
2
You receive 500 gold!

To use the store, say 'store'.
1
I don't understand.
bla
>>> 1
1
>>>
#23

Code:
shop != "store"
and
Code:
store != 'buy'
both evaluate to true. Therefore both "I don't understand." and "bla" are printed. You could for example make whole buying part a loop of it's own and control using continue and break statements what gets executed and what doesn't.
#24

Well, damnit... it was a bit confusing so I made my own version of the thing. Commented it a bit so hope you see what I meant.

Code:
# Shop

import sys

#--- Variables ---
Gold = 0
Choise = ""
#--- End of vars ---

# Loop for the gold thing
while True:
    Choise = 0
    # User input without cast to int. Could still add the exception but I'm not sure
    # can you still screw up the input like this or not.
    Choise = raw_input("Please choose from 1 or 2.\n")
    if Choise == "1":
        print "No, try the other option.\n"
        continue # Jumps back to the start of loop without going through the rest
    elif Choise == "2":
        print "You receive 500 gold."
        Gold += 500
        print "Now you have", Gold, "gold total.\n"
        break # Breaks off the while loop
    else:
        print "That's not a valid option!\n"
        continue

# Shop loop
while True:
    Choise = 0
    Choise = raw_input("Welcome to my store. Would you like to 'buy' something sir? If not then 'gtfo'\n")
    if Choise == "buy":
        while 1:
            Choise == 0
            Choise = raw_input("I only have these items for sale, business has been rather slow lately.\n*You notice him point to a 'sword' and 'shield' collection on the shelves*\n")
            if Choise == "shield":
                if Gold >= 150: # When you have enough money
                    Gold -= 150
                    print "You bought a shield for 150 gold! You have", Gold, "gold left now.\n"
                    break
                else: # ...and when you don't
                    print "You only have", Gold,"gold! You can't afford that!\n"
                    break
            elif Choise == "sword":
                if Gold >= 250:
                    Gold -= 250
                    print "You bought a sword for 250 gold! You have", Gold, "gold left now.\n"
                    break
                else:
                    print "You only have", Gold,"gold! You can't afford that!\n"
                    break
            else:
                print "That's not a valid option!\n"
                continue
    elif Choise == "gtfo":
        print "Bye then!\n"
        break
    else:
        print "That's not a valid option!\n"
        continue

That's around how I think you meant for it to be but not sure.


Forum Jump:


Users browsing this thread: 10 Guest(s)