• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Do You Use Ruby For Warcraft 3, too?

Status
Not open for further replies.
Level 6
Joined
Apr 16, 2007
Messages
177
Once I used python, but since my mom showed me ruby I do all the stuff in ruby. Things like Tooltip Creators that just take name, cooldown, description and level description are so easy to code using ruby's eval method <3

When I still had the old weapon system, I had all my combining, doubling, upgrading, cost and weight functions with python just like the weapon descriptions and tooltips : D

Just two lines and I did have another 10 lines of code in my map^^

Are you also using scripting languages in general and ruby in special for increasing your coding effency and getting a better consistency?
 
Level 6
Joined
Apr 16, 2007
Messages
177
Ok. I, however, just use it as a scripting language, I never built a real app with it.

Using it mainly for things like

Code:
def print_skill_text( name, cooldown, learn_tip, level_tip )
  puts "#{name} - [ %d / 6 ]"
  if cooldown then
    puts "[cooldown: #{cooldown} seconds]"
  else
    puts "[passive]"
  end
  1.upto(6){ |level|
     help_string = eval '"' + level_tip + '"'   #dunno why it doesn't work with calling eval directly, need to use this helper variable
     puts "Level #{ level } - #{ help_string }" 
  }
end

print_skill_text( "Shados-Hull", nil, "Increases the armor of the hero", '#{ level + 1 } additional armor' )
 
Level 27
Joined
May 30, 2007
Messages
2,872
That above code should use a block:
Code:
def print_skill_text( name, cooldown, learn_tip)
  puts "#{name} - [ %d / 6 ]"
  if cooldown then
    puts "[cooldown: #{cooldown} seconds]"
  else
    puts "[passive]"
  end
  1.upto(6){ |level|
     help_string = yield level
     puts "Level #{ level } - #{ help_string }" 
  }
end

print_skill_text( "Shados-Hull", nil, "Increases the armor of the hero" ){ |level|
  "#{ level + 1 } additional armor"
}
 
Status
Not open for further replies.
Top