Good day, everyone!
Another day, another "noobish" question to answer:
After browsing the tutorials and scripts in the forum, i managed to add a new window to the battle-screen. The problem is, that I can't get it to show what it should (one of the game variables...).
The class itself:
class Window_BattleRune < Window_Base
def initialize
super(219, 64, 200, 54)
self.windowskin = RPG::Cache.windowskin('001-Blue01')
self.contents = Bitmap.new(width - 32, height - 32)
self.visible=false
end
def refresh
self.contents.clear
self.contents.draw_text(221, 70, 22, 10, $game_variables[1])
end
end
The additions made to the battle-script:
Scene_Battle 1, under the "# make other windows" comment:
....
@message_window = Window_Message.new
@window_rune = Window_BattleRune.new
...
Scene_Battle 1, under the "dispose of windows" comment:
....
@message_window.dispose
@window_rune.dispose
...
Scene_Battle 2, in the update_phase1 method:
...
# Start party command phase
@window_rune.visible=true
start_phase2
....
Scene_Battle 4, in the update_phase4_step6 method:
...
def update_phase4_step6
@window_rune.refresh
# Clear battler being forced into action
...
Personally, i think that i didn't catch the "self.contents.draw_text" method well...
Apart from that, if the current battle script won't update it properly, please tell me (the variable itself is modified when someone uses a skill).
after self.visible=false add
refresh
And if still nothing pops-up use :
self.z = 5000
refresh
Dident test a thing, what does not work?
I tried both.
The window itself does show up, as it should (right below the "party_command" window). It's only empty, no matter how long the battle is...
self.contents.draw_text(221, 70, 22, 10, $game_variables[1])
change to
self.contents.draw_text(0, 0, 200-32, 54-32, $game_variables[1])
(reference: self.contents.draw_text(x, y, width, height, text, align=0) )
And if that fails just add ".to_s" (minus the quotes) after $game_variables[1]
Yeah, that was it... i didn't even think that i should convert it into string, because the variable itself was already a string (to be more accurate: $game_variables[1]= "Lon"). Strange... Thanks, both of you.
If it really was a string, you should not even have to use to_s
I figured, that if i'm going to torture you with more of my little problems, I shouldn't open a new topic for it everytime...
Here is today's problem. Again lots of hard work, and again, i failed at a minor-extra-noobish thing.
Here's the class:
#-----------------------------------------------------------------------------------------
#this is a simple class describing the runewords-database, and handles the
#runes during every aspect of the game
#-----------------------------------------------------------------------------------------
class Game_RuneWords
attr_reader :runehelpdata
attr_reader :runeknown
attr_reader :castunknown
attr_reader :current5
#making the original database
#-----------------------------------------------------------------------------------------
def initialize
$runehelpdata= {"BaBiLon"=> "A mighty runeword,making the flows of magic unreadable."}
$skillrunes= { "Heal"=> "Ba" , "Warrior" => "Lon", "Decompose" => "Bi" }
$runeknown= { "BaBiLon"=>false }
$castunknown= { "BaBiLon"=>true }
$current5=[]
$current5[6]= " "
$current5[5]=$current5[6]
$current5[4]=$current5[5]
$current5[3]=$current5[4]
$current5[2]=$current5[3]
$current5[1]=$current5[2]
$babilonian = false
end
#learning a rune
#-----------------------------------------------------------------------------------------
def runelearn(name)
$runeknown[name]= true
end
#starting the runes at the beginning of the battles
#-----------------------------------------------------------------------------------------
def runestart
$current5[5]= " "
$current5[4]=$current5[5]
$current5[3]=$current5[4]
$current5[2]=$current5[3]
$current5[1]=$current5[2]
end
#The "What does a certain runeword?" database.
#-----------------------------------------------------------------------------------------
def runeaction(name)
if name == "BaBiLon"
$babilonian= true
end
end
#casting a runeword
#-----------------------------------------------------------------------------------------
def runecast
#3 elements
$current5[6] = $current5[3] + $current5[4] + $current5[5]
if $runeknown[$current5[6]] == false
if $castunknown[$current5[6]] == true
$data_rune.runelearn($current5[6])
runeaction($current5[6])
else
end
else
runeaction($current5[6])
end
end
#when using a skill with a runeword
#-----------------------------------------------------------------------------------------
def runicskill(skillname)
$current5[4]=$current5[5]
$current5[3]=$current5[4]
$current5[2]=$current5[3]
$current5[1]=$current5[2]
$current5[5]=$skillrunes[skillname]
print $current5[5]
runecast
end
end
A minor description of "what the whole thing does?":
In the game I'm tying to make, every skill has a little syllable attached to it. If you use a skill in battle, a chain of syllables will evolve, everytime adding the current skills syllable to it ( if you had BiBa so far, and use "Heal", you will have BiBaBa). These are called "runes"
The script remembers the last five rune only. So if you had BiBaBiBaBi and use "heal" you will have BaBiBaBiBa.
There are certain "runewords". If you build one, you trigger the effect. So far i have only one, you know, I'm just trying the have the whole thing work...
So, if you use Heal-Decompose-Warrior in chain, you will have "BaBiLon", and uhm...that's good. ::)
Well, life is not so easy. As you guessed already, it doesn't work...
After initializing the whole thing with "$data_rune = Game_RuneWords.new" (working fine), and clearing the five runes (running "$data_rune.runestart" - fine as well ), it should go like:
skill->common event->runicskill method->runecast method->runeaction method
After printing some variables, I found out, that every "$current[]" is "nil". The common event that should give the skills name to the runicskill method, gives nill.
I tried this:
"@>Script: $data_rune.runicskill(@skill)"
because in the battle scene processing the @skill variable holds the currently used skill... but after printing it, i got some horrible hexadecimal value... so it's not what i need.
Okay, after all this useless babbling of mine:
Question: How could I give my method the name of that skill, which called it through a common event?
And i'm not sure about the hash-usage either... :-[
oh gosh... :tpg: so much reading i gave up... ;9
you sure did torture me... -_-
NUMBER ONE PROBLEM :
Too complicated.
Seriously, you're making this way too complicated on yourself.
What you need to do is the following.
First off, get rid of that script, completely.
Second, take about a week off for break.
When you're done with that, plan it out, keeping it simple, build the basics and make sure they work FIRST.
Then add on to it, testing each feature as you go along.
to Tsunokiette:
Well, i don't think it's complicated. It did exactly what i wanted it to do, if i gave the word manually to the first method. The only problem was the question I highlighted.
I write "was", because after new year's eve, with a fresh mind (khmm... party and all, you know... ::) ), I fixed it.
The problem was really the event. If anyone cares, the sollution was:
"@>Script: $data_rune.runicskill(@skill)"
The @skill is not the skills name. It's an instance of the class "skill", and therefore it's a whole bunch of data. That hexadecimal I got was a memory adress, i think. A skills name is @skill.name. Now, that's a string.
So, now:
"@>Script: $data_rune.runicskill(@skill.name)"
Okay, but still "nill". Because in ruby, @variables are "instance variables". That means, that you can't acces them from outside.. from a common event. So I opened "Scene Battle 4" in the script editor and inserted
"$data_rune.runicskill(@skill.name)"
in the "update_phase4_step5" method, right after the damage display, before it switches to phase six.
And magic, it works. Without any common events. That's the way i like it. :-)
About the testing, you are right. I do it. But sometimes i get carried away. And i installed RGPMakerXp last Wednesday. It won't get any faster than that. :-)
By the way, i like your signature. About grammar and "chat-speech".
See, told you a break would do ya good. ^_^
Also, when I say something is too complicated I mean the following -
"I can't tell what it is without you explaining it."
Just simplify things next time. (and get into the habbit of commenting everthing, not just blocks.)
But congratz on figuring it out.
Sir, yes, sir! I will have more break. ;)
(((If it wasn't for the upcoming quantummechanics-exam... geez... why do I learn such things?- Okay, i stopped chating... )))