I wanna add Tutorial's score function in CptnRuby which is in examples,
but it says score is undefined when running,
and display text :
CptnRuby.rb:238: syntax error, unexpected $end, expecting keyword_end
It means you have forgotten one
end somewhere. (It found the "$end" of the file, but expected
but now it says
draw': undefined method score' for nil:NilClass (NoMethodError)
I just combine score counting in Tutorial and CptnRuby
Could you perhaps upload your code somewhere?
You can attach files to your postings in this forum (but only after posting).
Wow. Twice in a row someone beats me to posting :P
Or for code, you could use a gist, or pastebin. That would be more convenient than one of those filesharing websites.
Awesome, looking for a problem. Also, you know you can attach files directly to your post after you post it. ;)
Like the others said, you can attach your file directly. I'm no Ruby wizard, but I'll tell you one thing already: I'd use proper indention. It makes reading scripts so much easier and you won't have those bugs you are experiencing right now.
Huh, didn't find anything. I'll try looking at it through IntelliJ
As for the first problem, I figured out that the problem code is in line 226. It happens because you never set
@CptnRuby to anything, so it is
nil by default. And, you never even define a
score method anywhere, so it says that you never defined it for
nil. Perhaps you meant to type
I'll try this in a second and see what I get.
Tried this and it didn't exit with any errors. When I played it, the collisions were WAY off... Do you want me to attach the fixed file?
thanks for helping and i would like to see the fixed one,could you please attach it.
I thought class CptnRuby contain score,then CptnRuby.score will work.
Now i knew that the forum can attach,and I am wondering what other software can run Ruby I'm still using CMD.
Also, when referencing to classes, don't prefix it with
@. This means it's an instance variable, like your
score. But using
CptnRuby.score won't work until you define that method. It isn't defined right now. Fixing this right now for you; I'll attach it when done. Should take longer than a minute total. :)
Well I assume you want to be able to run it by double-clicking on the file like you would an executable. If so and you're on a Windows computer, you should already be able to do just that. If not, then try writing a shell script for it. Need an example?
I can see the score now, and i will try to fix collisions by myself.
thanks again for helping!!
No problem! ;)
Sorry it took so long to reply though; I've been busy
I would like to turn the file into .exe, hence I searched for it and found exerb.
But it doesn't work. I think it doesn't create .bat in the folder bin.
Do you know the solutions or other ways to turn to executable?
I gonna change the icon.but it can not work..
C:\Ruby191\123>ocra --icon <DISTLSTL.ico> CptnRuby.rb
parseargs': undefined method exist?' for nil:NilClass (NoMethodError)
It should work without the <> (unless you named the file that way, which would be dangerous as those are reserved characters).
thanks a lot!
Powered by mwForum 2.29.7 © 1999-2015 Markus Wichitill