HAVING A SYNTAX ERROR PROBLEM

Posts

Pages: 1
I created a very simple stealing code for my game I'm working on and it keeps giving me a syntax error on line 19. When I have a end on that line. Here is the code I'm using:
#Skill for theif to steal item
class Steal_Skill < Game_Enemy
  
  def intialize
    stealIteam
  end
  
  def stealItem #steals enemy treasure item
    @item_steal = $data_enemies[enemy_id].treasure
    @tresure_probiblity = $data_enimies[enemy_id].treasure_prob
    numRand = srand([100])
    if numRand <= @treasure_probiblity
      $scene.refresh_status_window if $scene.is_a?(Scene_Battle)
      $game_temp.message_text = "Stole Item"
    else
      $scene.refresh_status_window if $scene.is_a?(Scene_Battle)
      $game_temp.message_text = "No item to steal"
    end
  end 
  
end
I'm not use to using ruby scripting language. Is there anything in my code that is causing the problem?
Well, line 9 says $data_enimies, instead of $data_enemies


That could be it.
I've fixed that line and another, but now it's giving me an error on the 'enemy_id' that is part of the $data_enemies.treasure line.

EDIT: I've realized that the enemy_id is missing from what I've typed in because I put it inside brackets when I should not have don that. So in other words the $data_enemies.treasure is $data_enemies(enemy_id).treasure .
I'm now getting a nil error on line 9 of my code.
First off, why are you making a new class for this instead of adding to the Game_Enemy class? There's actual work to be done in the initialize method too in the Game_Enemy which is important that your code cuts out as it won't call it. enemy_id is null because it's set to be a local variable. You want to use the instant variable enemy_id which is denoted by putting a @ in front of it (@enemy_id). And yes, you should use the square brackets when you want to pull data from $data_enemies. It's an array and you access elements of that array by specifying the index contained in square parameters.
I was trying to make it so when my thief uses the skill called Steal that when it's used it runs the script to where it takes the item that the enemy is holding and I didn't know if I could do it using the common events to call the script and run it from there.
I've denoted enemy_id with the @ symbol and it still gives me the same error as i was getting before. When you mean " There's actual work to be done in the initialize method too in the Game_Enemy which is important that your code cuts out as it won't call it." is that telling me I need to make it be called in the Game_Enemy too?
Pages: 1