Computer Science Canada Help with Ruby (Final Word) |
Author: | StarGateSG-1 [ Sun Mar 13, 2005 8:39 am ] | ||
Post subject: | Help with Ruby (Final Word) | ||
I am trying out on of those RPG malers for fun. And i am having a problem with the script, (mainly becasue comments are in chinese, lol) but i need to rewrite some parts. and i am not sure how?
This is the problem piece if you wnat to know more go download it at http://archives.rpginfinity.com/makers/rpg_maker_xp AN overview of the problem is when you choose to attack it will come up with an error about 'Game_BattleAction' 62 (line i think) No Method Error 'scope' nil:NilClass It be really great if you could help me O ya does anyone know of a site that can chnage chinese to english??? |
Author: | Martin [ Sun Mar 13, 2005 11:42 am ] |
Post subject: | |
Try http://www.altavista.com/tr |
Author: | wtd [ Sun Mar 13, 2005 11:47 am ] | ||||||||
Post subject: | |||||||||
It's actually Japanese. You can tell because of the use of Hiragana as well as Kanji characters. As for your problem...
Causes problems because
Is nil, and nil is an object of the NilClass class, which doesn't have a method 'scope'.
But it can be more simply written as:
|
Author: | wtd [ Sun Mar 13, 2005 2:20 pm ] | ||||||
Post subject: | |||||||
Further explanation:
Is an Array or Hash. You get nil from:
Because
Isn't a valid index of the array or hash. |
Author: | StarGateSG-1 [ Sun Mar 13, 2005 6:15 pm ] | ||
Post subject: | |||
Well thanks for the help, it didn;t work though maybe you could take a deeper lok at all the code. I will post all of the Game_BattleAction. I will also tranlate this time.'
Here it is! ouch that took like 15 - 20 mins to translate i hate to have to translate the whole program good thing there is a good debuger. The error agins is ??????'Game_BattleAction'?62???No Method Error??????? undefined method 'scope' for nil:NilClass |
Author: | StarGateSG-1 [ Sun Mar 13, 2005 6:16 pm ] |
Post subject: | |
O ya one last thing if you find the error isn't here download it at the above site, this is a major problem and needs to be dealt with the company, so if we can report it thats good. |
Author: | wtd [ Mon Mar 14, 2005 1:11 am ] | ||
Post subject: | |||
There's one problem. The $ in
Indicates that this is a global variable. I'd have to see how this is setup to really be able to help. While I appreciate the use of Ruby, this unfortunately doesn't look like very good code. |
Author: | StarGateSG-1 [ Mon Mar 14, 2005 11:15 am ] |
Post subject: | |
Like i said go download the program at the site in my first post here. I didn't right this code nor do i really know ruby, and there are well over 50 sections and i can't put them all on here. O ya soemtimes it works know soemimes not. |
Author: | StarGateSG-1 [ Mon Mar 14, 2005 11:18 am ] | ||
Post subject: | |||
This is the second piece that has problems, if someone could fix this it would be good I am pretty sure. |
Author: | wtd [ Thu Mar 17, 2005 2:10 am ] | ||||||||||||||
Post subject: | |||||||||||||||
As you've noted, the problem is with this line:
And more specifically this:
Even more specifically:
When you get a NoMethodError it means you're trying to call a method that the object doesn't have.
Is an array. It's also a global variable, meaning it's visible to everything in the program (the $ gives this away).
Is the index for that array. Now, what happens when skill_id is too large, and doesn't represent a skill in the $data_skills array? Well, I get "nil". The "nil" value is Ruby's equivalent to nothing, and it has very few methods. http://rubycentral.com/ref/ref_c_nilclass.html Now, I can check for this. If $data_skills[@skill_id] is nil, it will evaluate to false in a conditional. Otherwise it will evaluate to true. I'll assign it to a temporary variable to save myself some typing.
Since Ruby's conditionals (if/elsif/else) short-circuit, I know that if any of these conditions is false, the rest won't even be evaluated. If:
Is nil, then Ruby will never try to call the scope method, and the error won't occur. |
Author: | wtd [ Thu Mar 17, 2005 11:46 am ] | ||||
Post subject: | |||||
Poses the same problem, so the solution is the same.
|
Author: | StarGateSG-1 [ Thu Mar 17, 2005 4:56 pm ] |
Post subject: | |
Thank you very much, I hope this is the last problem I find. |
Author: | StarGateSG-1 [ Thu Mar 17, 2005 5:11 pm ] | ||
Post subject: | |||
Well I found more problems, maybe you should take alot look at the whole program (RPG Maker XP) cuase there oculd be alot more erros I am not finding yet, but it take forever to debug when i don't know ruby But here is the next problem.
* this is the error line This time I know what happens though, you use the skill , but you don't have enough mana, so it needs like an if statement, to check if you have enough mana, if not then can't use skill |
Author: | StarGateSG-1 [ Fri Mar 18, 2005 11:05 am ] | ||
Post subject: | |||
** another problem, no clue about this one, but this hgappend when there is more than one monster being fought at the same time. |
Author: | StarGateSG-1 [ Mon Mar 21, 2005 4:46 pm ] | ||
Post subject: | |||
This is ruby right? anyways I don't think the problem is with having egough mana. More coming ... minutes later I was right and wrong the basic attack is calling apon mana even though it costs nothing! ... mintues later The problem is it is treating the attack as a skill if you refer to the GameAction_Battler
There is a problem with the way it uses basic attacks. |
Author: | StarGateSG-1 [ Wed Mar 30, 2005 8:28 am ] |
Post subject: | |
The Ruby I was using was RGSS so therefore no one here uses it, unless you happen to use rmxp. So I am ending this. |