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

See through a Gm's eyes!
#1

Everyone says Dev's/Gm's are lazy, don't do nuttin, etc. Well I am here to prove you wrong. I spent 6 hours with a half as hard programming system then what the gm's use, just to finally perfect this simple script with no bugs.

I seriously spent 6 hours on this. Code has to be perfect. I drank 4 cups of coffee, ate 5 burritos, and smoked a pack of cigarettes.......

Code:
#Practicing Variables, If structures, while structures, Import structures

#Author: Lucas John Hoage
#Version 1.0 Open Beta
#Copyright: None/Open Source
#Time spent: 6 Hours
#Time Start: 11:30 P.M. Eastern Time Zone
#Time Finish: 5:23 A.M. Eastern Time Zone

####################################Instructions#####################################

#In order to use/view/edit this code, you must have Python 2.5.1 installed on your computer. This is for windows users. If -
#the installation asks you to update anything, press ignore, its a retard. Once installed go to Python, Python IDLE (GUI), then -
#when it loads, go to file, New window, in the new window, copy and paste this text into it. save as anything, BUT make sure it -
#ends with .py Example: Practice.py, then save as python file py, pyw, txt. After that, go back to the IDLE (GUI) and -
#hit file, open, and open the file you saved. Now, have fun and enjoy. Do not feel hesitant about editing the script, its a -
#good way to learn. Trust me, this shit took 6 ****ing hours. This is merely the beginning of Python programming. Enjoy ^_^

#Note: All keywords close in " marks, are case sensitive and are coded to continue the program.
#Questions? Comments? email them to [email][email protected][/email]


import sys


Prize1 = 1
Prize2 = 2
Selection1 = raw_input
Pr1 = True
shop = True
shieldM = True
sword =  250
shield = 250
storeM = True
store = raw_input
buy = True
checkoutS = True
checkoutSW = True

while Pr1:
    Selection1 = int(raw_input("Please choose a reward 1 or 2.\n"))
    

    if Selection1 == 1:
        gold = 500
        print "You receive 500 gold!\n"
        Pr1 = False

    elif Selection1 == 2:
        print "I am sorry, but you do not have any gold to visit the 'store'!\n"
        gold = '0'
        print "You receive nothing!!!! Try again.\n"

    elif Selection1 != Prize1 and Prize2:
        print "That is not an option, try again.\n"

while storeM:
    shop = str(raw_input("Do you wish to use the 'store'.\n"))
    

    if shop == 'store':
        print "Welcome to my store, please take a look around.\n"
        storeM = False

    else:
        print "I don't understand what you want.\n"

while shieldM:
    store = str(raw_input("I have a 'sword' and \
a 'shield' for sale! Which would you like to 'buy' some sir?\n"))

    if store == 'buy':
        shieldM = False

    else:
        print "I do not understand what you want.\n"

while checkoutS:
    if gold > 0 or 'shield' or 'sword':
         buy = str(raw_input("Care to buy anything else?\n"))
        
    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"
        
    if 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"
    elif gold == 0:
        checkoutS = False
            

while checkoutSW:
    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"
        checkoutSW = False
        SystemExit

This was my first attempt at programming a basic program, with Python, ever. I've only been studying Python for.. 3 days now? Its fairly easy to learn, but a damn cranky ***** if you're not careful.

I hope this program will inspire the other community members to delve into programming.
#2

huh!

whats that lol.

As i have been reading... RunUO can be coded by C#

from "runuo . com" forums i read:

"If you understand C# you won't need a RunUO scripting guide since, its C# and there is no difference between the two."

regards
#3

galen if you know what youre doing. that is nothing...
#4

I understand Run UO is C script.

For studying on and off in Python for 3 days, and doing 1 major attempt, accomplishing it all in 6 hours, is pretty damn good.

If its nothing to you, I really hope you participate with the scripting of the shard. It would be nice to have more developers.
#5

RunUO is C# or Visual Basic, and that code would have taken like 15 minutes ;/

Yankovic - "... Oh Nasir, sorry, you are teh greatest. I'm a fool, you were right all the time. please forgive me. ..." (possibly out of context)
#6

Nasir Wrote:and that code would have taken like 15 minutes ;/


Hahah! I knew it!

[Image: sigpicc123.png]
#7

Heh Let the man be proud. I remember when I wrote my fist PHP script.. I was so proud.. Ofcause it was just a simple script like the one Calens posted hehe

Need Logs? PM Me.
Support Your Local Log-Dealer!
-> Mark Forums Read <-
#8

It's good for his first attempt, give him some credit.

Good work Galens, keep on programming! :]

Regards,
Hate
#9

Yea good job on teaching yourself how to do it.
#10

Seriously bro, good job. Keep it up, I would have never been able to make that up, i just started learning advanced injection scripting, hopefully i get to learn some cool stuff :icon_twisted:.

Regards,

Scarecrow [Prototype].

Bow Down To The ScareKing! jeje

[Image: scarecrowinxkd2.gif]
#11

I got access to the scripts over break, I must say I agree with Galen. Having little experience and trying to learn it is a bit overwhelming, I've already made a few minor changes and will continue to work on it, but its a vast difference between me looking at the scripts with little experience and nasir looking at them with a lot of experience.

Unfortunately my minor changes aren't going to help development much.
#12

Visual Basic?? OMG Worst shit ever invented. Not even portable.


For a really really good introduction to Python programming, go to google and search for:

A Byte of Python


This is a very useful tutorial, extremely easy to understand.


What I found the most interesting, is that, that specific way I wanted to run that, I couldn't figure it out for the longest time. I edited that script so many freakin times to see what worked and what didn't. It was more experimental and learning, than for show. Now that I look at it, I was like, omfg, I cannot believe I didn't think of that before.

A lot of it that was added, was purely experimental to find the way I can push those structures and functions. That is what took me so long. I didn't want to make a few inputs, that would have been the VERy easy part. I wanted to see if I could give all of it some.. intelligence, rather than what I had previously scripted. It worked out.

The hardest part of the entire program, was getting it to recognize, that a player can buy more than 1 of the same item, until the gold runs out. I plan to modify it even further calling defines to make the script even shorter, using some other functions aswell. That shouldn't take long at all though. I also plan to modify it for a value over 0 gold after you buy what you want, and tell python I want it to either have more items to buy, or an option to leave the store. That is kind of tricky using the basics though. We'll see.


Forum Jump:


Users browsing this thread: 2 Guest(s)