View Full Version : Help for a beginner
Holdway
May 12th, 2006, 07:47 AM
Hi
I'd like to firstly apologise for my extreme ignorance. I am not by any means a programmer. I have attempted to teach myself some of the most basic parts of ruby, by reading the Chris Pines tutorial.
In an attempt to get some experience in programming, and to basically just practice, I have been attempting to make a RPG. It's been a huge amount of fun and has been going very well.
I am very much aware however that I'm probably using very basic code to get things done, when I should be doing things in ways that require less repetition. I either don't know these methods, or haven't worked out how to use what I do know to do what is needed.
Despite this I'm very happy with what I have, and how it works (It is just a bit long winded). I would like to have a way of enabling various friends to test this game. At present it's saved as a .rb and for someone to run the program they need Ruby.
Like I mentioned earlier, I really know nothing about programming. I have no idea if what i need is very simple, or complex. Ideally I would like a way of running the game in a Web browser at some stage, but again I am full of ignorance on how hard this would be, and want to take it one step at a time. So first any help in getting my program to not need ruby to run first, would be very appriecated.
Thanks in advance for any help.
steve_d555
May 12th, 2006, 12:53 PM
I would love to test it.
You should check out rubyscript2exe (http://www.erikveen.dds.nl/rubyscript2exe/index.html) which can generate both Linux executables and Window .exe's.
I am pretty sure there is a way to embed a ruby program inside a Web page using CGI, though I have never tried it.
Holdway
May 12th, 2006, 02:18 PM
Thanks for that Steve.
I went to that site and copied and pasted the script that was here:-
http://www.erikveen.dds.nl/rubyscript2exe/download/rubyscript2exe.rb
As I said earlier I really have no understanding of programming and this is all way over my head and have no idea whatsoever how to get the thing to actually work. I tried a few things but none seemed to work. Any advice on how to proceed with it would be very helpful :)
If you would like a version of the game leave your Email and i can mail it to you.
steve_d555
May 12th, 2006, 02:50 PM
Sure, my email is steviedizzle@gmail.com
If your game is just one .rb file you can use rubyscript2exe by running it from the command line by doing
ruby rubyscript2exe.rb app.rbThere then should be an executable with the same name in the same directory.
If your program is more than one file (a directory or something) you can use tar2rubyscript (http://www.erikveen.dds.nl/tar2rubyscript/index.html) for the directory then create an exe out of the .rb file that is produced.
Holdway
May 12th, 2006, 05:06 PM
ok thanks, however I got an error. I assume this is to do with compatability?
rubyscriptexe.rb:119:in 'next_entry' : undefined method 'length'
(NoMethodError)
from rubyscriptexe.rb:111:in 'each'
from rubyscriptexe.rb:97:in 'extract'
from rubyscriptexe.rb:337:in 'extract'
from rubyscriptexe.rb:337:in 'extract'
from rubyscriptexe.rb:433:in 'newlocation'
from rubyscriptexe.rb:332:in 'extract'
from rubyscriptexe.rb:559
And mail sent with the latest version of the game. (sorry about my bad coding)
steve_d555
May 12th, 2006, 11:22 PM
I haven't look through your whole code, but the first thing that comes to mind that would easily suit your game is metaclasses. I think a great guide to learn about metaprogramming is Why's Guide (http://poignantguide.net/ruby/). Metaprogramming starts in chapter Six, but I recommend you at least look through the other chapters a little if you want to learn more about Ruby. Metaclasses can replace all the ugly arrays at the top of the page.
Other than that it looks okay, though it could use some indentation and maybe file-splitting (2000 lines is pushing it.)
Hope it helps.
Holdway
May 13th, 2006, 02:09 AM
yes thanks. I read about classes in Chris Pines tutorial but couldn't quite seem to work out how they would fit for me. I'll have a read about these meta classes hopefully they will help. I made some effort to read why's guide a few days ago, and found it quite useful but also very tiring, all the various side tracks and tangents it took. It helped me understand things I had a basic grasp of better, but I felt if I didn't already have an idea about it, then I would have been lost, not sure if that makes sense.
It was there and another beginner guide I read; that i worked out that I didn't have the right format on indentation. But my view was as I got more experienced I'd want to replace large parts of the code anyway. As you said 2000 lines of code if alot to go though to tidy up if your not even sure how much of it is going to be kept.
As for the splitting again, I don't know how. The way I work on it, I have a seperate file for each of the definitons, and then copy and paste from mini programs to the main one. If there was a way of splitting I would very much like to simply put the various definitions in other files. It is very difficult even finding the right definition to replace now in the main file.
Anyway thanks for that, I'll go check out these metaclasses. The arrays I use for equipment I would very much like to get rid of, since I hate the way it works, It feels to me as if it's taking 20 lines of code per task when i could be taking 1. The array for the monsters to me seems to work quite well (maybe the equipment arrays are so bad anything else seems good in comparison), but again I still felt there must be a better way of doing it.
Thanks again. I tried messing about with the scipt I got from:-
http://www.erikveen.dds.nl/rubyscrip...yscript2exe.rb
and after trying a few different ways of doing what you said, noticed i got the same error when simply trying to run that script. I guess there is a compatibility issue, any advice on what to do there?
vBulletin® v3.7.3, Copyright ©2000-2008, Jelsoft Enterprises Ltd.