Mythruna

General Category => General Discussion => Topic started by: Michael on October 16, 2012, 07:56:40 PM



Title: Am I getting somewhere?
Post by: Michael on October 16, 2012, 07:56:40 PM
I found this site (citytechinic.com (http://www.citytechinc.com/us/en/blog/2009/05/a_text_adventuredsl.html)) and its gives a nice tutorial on how to make a text adventure with groovy.

I pretty much copied everything xD
ok but exactly, do you think I am making progress?
Code:
new GroovyShell().evaluate("game.with{${playerInput}}")

game.go 'north'
> You go North.
game.look()
> You see a dagger on the ground.
game.take 'dagger'
> You take the dagger.

class Game {
  void go(dir) {
   println "You go $dir"
 }

 void look() {
  println "You look around and see nothing."
 }

 void take(it) {
  println "You take the $it"
 }
 def methodMissing(String name, args) {
  def funcName = ThesaurusLookup.contains(name)
    if (funcName)  {
    }
  this.take(args[0])
  }
}
yes, I do know that i need to change some things. such as the defined words like "it" and much more. and I will also need to define them.

G'night!


Title: Re: Am I getting somewhere?
Post by: Michael on October 17, 2012, 02:00:27 PM
I'm up and running, I have made some changes to it:
Quote
// Directions
def n = 'north'
def s = 'south'
def e = 'east'
def w = 'west'
// Items
def w1 = 'axe'

// Where the player types the commands.
new GroovyShell().evaluate("game.with{${playerInput}}")

class Game {
// Directions
  game.go("north") { println "You traveled $n" }
  game.go("south") { println "You traveled $s" }
  game.go("east")  { println "You traveled $e" }
  game.go("west")  { println "You traveled $w" }

// Looking
  game.look() { println "You see something! What, an axe? I think that would be useful." }

// Taking
  game.take(axe) { println "You take the $axe" }
 
def methodMissing(String name, args) {
if (['grab', 'hold'].contains(axe))  { }
    this.take(args[0])
  }
}
I will come w/ more updates.


Title: Re: Am I getting somewhere?
Post by: Moonkey on October 17, 2012, 02:19:38 PM
Definitely a text adventure. Looks correct to me ;)


Title: Re: Am I getting somewhere?
Post by: Michael on October 17, 2012, 02:30:12 PM
i am still having a complication... i cannot compile my groovy files xD
I use my cmd with this command:
Quote
groovyc -sourcepath (path)
what I enter is:
Quote
groovyc -sourcepath C:\Users\...\Desktop\Games
"..." indicates my username.


Title: Re: Am I getting somewhere?
Post by: pspeed on October 17, 2012, 02:56:28 PM
Yeah, your script looks pretty messed up.  You are trying to be too fancy using complex groovy things.  Stick to the basics of straight methods and bodies.  (Note: it's impossible to diagnose compile errors unless we see the compile error.  <-- last time I will offer that advice)

For example, all of your game.go() stuff makes no sense where it is.  What is "game"?  What is "go"?  None of those things are defined but you might not get errors because you've implemented a methodMissing() method that will prevent errors from showing up. (ie: you are using a groovy trick to implement commands instead of just implementing them.)

I think it is a mistake to follow a groovy example of a text adventure.  You should maybe find a Java version and then adapt it.  They will use way fewer tricks that way and you can concentrate more on learning the coding and data structures and less on confusing groovy idioms.


Title: Re: Am I getting somewhere?
Post by: Michael on October 17, 2012, 06:33:32 PM
My problem is that I do not believe in limits. Yes, I know I am naive about that thought.

My strive is strong, but yet it is small.

The key to do, is to learn.

Thanks for the help Paul.  :-\


Title: Re: Am I getting somewhere?
Post by: Iggyjeckel on October 17, 2012, 06:53:35 PM
Of what ive seen paul has helped you alot, if you dont understand the advice, thats not his fault

Dont expect a spanish teacher to teach french to the japanese student


Title: Re: Am I getting somewhere?
Post by: Michael on October 17, 2012, 06:56:24 PM
Of what ive seen paul has helped you alot, if you dont understand the advice, thats not his fault

Dont expect a spanish teacher to teach french to the japanese student

xD what does that have to do w/ the price of tea in China?


Title: Re: Am I getting somewhere?
Post by: Iggyjeckel on October 17, 2012, 07:02:09 PM
Hmm nevermind you editted it out, befoe you had quotes around help, just seemed sarcastic, must have taken it wrong way


Title: Re: Am I getting somewhere?
Post by: Michael on October 17, 2012, 07:55:44 PM
Hmm nevermind you editted it out, befoe you had quotes around help, just seemed sarcastic, must have taken it wrong way
Eh.. life has been harsh lately. I read it w/ quotes a couple times and it just seemed so rude.
I know Paul is helping me as much as he can w/out too much time consumption.

I remember a time when I used to be mature...


Title: Re: Am I getting somewhere?
Post by: Moonkey on October 17, 2012, 07:56:42 PM
Of what ive seen paul has helped you alot, if you dont understand the advice, thats not his fault

Dont expect a spanish teacher to teach french to the japanese student

xD what does that have to do w/ the price of tea in China?
What does that have to do w/ what Iggy just said? xD

Edit: Mature? Nobody is ever Mature. It's just manners that make people seem mature. Curiosity may be what killed the cat. But you aren't a cat xD


Title: Re: Am I getting somewhere?
Post by: Michael on October 17, 2012, 08:03:34 PM
*cough* correction, if you watch Spongebob, it is "Curiosity is what salted the snail." not "Curiosity may be what killed the cat."
I also found a nice site that teaches you how to make a text-based adventure game in java. Paul said to find a java version and adapt to it. so the site is..
that is a link =>... (http://www.javacoffeebreak.com/text-adventure/index.html)<= knil a si taht


Title: Re: Am I getting somewhere?
Post by: BenKenobiWan on October 17, 2012, 08:05:33 PM
Of what ive seen paul has helped you alot, if you dont understand the advice, thats not his fault

Dont expect a spanish teacher to teach french to the japanese student

xD what does that have to do w/ the price of tea in China?
What does that have to do w/ what Iggy just said? xD

Edit: Mature? Nobody is ever Mature. It's just manners that make people seem mature. Curiosity may be what killed the cat. But you aren't a cat xD
Nobody is perfectly mature, sure. But there are different levels of maturity.
Maturity is a lot more than manners, but I don't know if this is the thread for that.


Title: Re: Am I getting somewhere?
Post by: Moonkey on October 17, 2012, 10:59:16 PM
Of what ive seen paul has helped you alot, if you dont understand the advice, thats not his fault

Dont expect a spanish teacher to teach french to the japanese student

xD what does that have to do w/ the price of tea in China?
What does that have to do w/ what Iggy just said? xD

Edit: Mature? Nobody is ever Mature. It's just manners that make people seem mature. Curiosity may be what killed the cat. But you aren't a cat xD
Nobody is perfectly mature, sure. But there are different levels of maturity.
Maturity is a lot more than manners, but I don't know if this is the thread for that.
Maturity is like a cat... No it isn't... Maturity is like... Aww I'm bored. Random post for postiness.