new to ruby...need For loop advice

● ARCHIVED · READ-ONLY
Started by iNBee317 8 posts View original ↗
  1. I am trying to create a system in game similar to pathfinders skill checks (perception, acrobatics, climb). I am using PK'8s data suite to store the ranks players add to these skills and have the system add their corresponding parameter(atk,def,etc.), skill rank, and the result of a d20 dice roll.

    As of right now I have been doing this the long way with a common event containing conditional branches that determine if the actor is in the party or not, then calculates their score and compares it to the DC of the event which flips a switch that tell the event (say a trap) whether the actor succeeded or failed.. This is a lot of redundant work. So I am trying to figure out the way to create a 'For' loop where it replaces a placeholder in my script with a number N where N is the actor value. each time the loop run N changes to the actor value for the actor next in my party. That way I don't have to copy, paste, and edit fields for each specific actor and end up with countless conditional branches. 

    I could post my current event and common event though I don't think it will help much since I am going for a complete overhaul.
  2. here is a simple for loop for Ruby

    Code:
    for i in 1..5   puts "Value of local variable is #{i}"end
  3. z=$game_variablesfor i in 0..z[37] x=$game_party.members[#{i}].id z[9]=$game_actors[x].mdf z[9]+= actor_self_variable(x,"acr") z[9]+=z[14]end

    Anyone know what I am doing wrong here? It says unexpected tIDENTIFIER, expecting ']'
  4. I did not resolve the 'for' loop issue though found another way to go about it. 
  5. iNBee317, please avoid double posting, as it is against the forum rules. You can review our forum rules here. Thank you.


    Does it tell you which line is causing the issue?


    Try putting some spaces in there - in most cases it'll make it more readable - but sometimes it solves errors.


    Also, you don't need [#{i}] - just do
  6. Incidentally, the reason the above didn't work (assuming the position it was used in was correct) was that the unnecessary # commented out the rest of the line, including the right closing bracket, which is exactly what the error was saying.
  7. Thanks everyone this was very helpful!
  8. This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.