RMRK is retiring.
Registration is disabled. The site will remain online, but eventually become a read-only archive. More information.

RMRK.net has nothing to do with Blockchains, Cryptocurrency or NFTs. We have been around since the early 2000s, but there is a new group using the RMRK name that deals with those things. We have nothing to do with them.
NFTs are a scam, and if somebody is trying to persuade you to buy or invest in crypto/blockchain/NFT content, please turn them down and save your money. See this video for more information.
string problem

0 Members and 1 Guest are viewing this topic.

**
Rep: +0/-0Level 88
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:
Code: [Select]
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:
Code: [Select]
....
@message_window = Window_Message.new 
@window_rune = Window_BattleRune.new
...
 
Scene_Battle 1, under the "dispose of windows" comment:
Code: [Select]
....
@message_window.dispose
@window_rune.dispose
...
Scene_Battle 2, in the update_phase1 method:
Code: [Select]

...
# Start party command phase
 @window_rune.visible=true
  start_phase2
....
Scene_Battle 4, in the update_phase4_step6 method:
Code: [Select]
...
 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).
« Last Edit: December 30, 2006, 08:53:03 PM by Lord »
"Oh, mirror, how do i pity you!
Because when the men look at you, they see only themselves, not the mirror, who you really are..."
- Zelbess, Chrono Cross

***
Rep:
Level 88
Random-Idiot
after self.visible=false add

Code: [Select]
refresh

And if still nothing pops-up use :

Code: [Select]
self.z = 5000
refresh

Dident test a thing, what does not work?
ALL HAIL ME™

**
Rep: +0/-0Level 88
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...
"Oh, mirror, how do i pity you!
Because when the men look at you, they see only themselves, not the mirror, who you really are..."
- Zelbess, Chrono Cross

***
Rep:
Level 88
Random-Idiot
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) )
ALL HAIL ME™

*
Full Metal Mod - He will pillage your women!
Rep:
Level 93
The RGSS Dude
And if that fails just add ".to_s" (minus the quotes) after $game_variables[1]
"The wonderful thing about Tiggers
Is Tiggers are wonderful things
Their tops are made out of rubber
Their bottoms are made out of springs

They’re bouncy, trouncy, flouncy, pouncy
Fun, fun, fun, fun, fun!
But the most wonderful thing about Tiggers
Is I’m the only one, I’m the only one."

**
Rep: +0/-0Level 88
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.
"Oh, mirror, how do i pity you!
Because when the men look at you, they see only themselves, not the mirror, who you really are..."
- Zelbess, Chrono Cross

***
Rep:
Level 88
Random-Idiot
If it really was a string, you should not even have to use to_s
ALL HAIL ME™

**
Rep: +0/-0Level 88
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:
Code: [Select]
#-----------------------------------------------------------------------------------------
#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, mirror, how do i pity you!
Because when the men look at you, they see only themselves, not the mirror, who you really are..."
- Zelbess, Chrono Cross

***
Rep:
Level 88
Hell... What did I mess up now... I'm Back!
oh gosh...  :tpg:  so much reading i gave up...  ;9

you sure did torture me... -_-
----Current Games working on----
--Rage O' Delusion - Overall Percentage Finished : 4% -- Expected release... Unknown
--The Other Dimension - Overall Percentage done : 1 - Expected Release : No time soon...
v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^
Feildmaster Productions
Made By One Man Run by the Same...
Making Games for Everyone...
Oh yeah, and everything else web based
For a charge... Of course...

*
Full Metal Mod - He will pillage your women!
Rep:
Level 93
The RGSS Dude
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.
"The wonderful thing about Tiggers
Is Tiggers are wonderful things
Their tops are made out of rubber
Their bottoms are made out of springs

They’re bouncy, trouncy, flouncy, pouncy
Fun, fun, fun, fun, fun!
But the most wonderful thing about Tiggers
Is I’m the only one, I’m the only one."

**
Rep: +0/-0Level 88
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".
« Last Edit: January 03, 2007, 12:07:49 PM by Lord »
"Oh, mirror, how do i pity you!
Because when the men look at you, they see only themselves, not the mirror, who you really are..."
- Zelbess, Chrono Cross

*
Full Metal Mod - He will pillage your women!
Rep:
Level 93
The RGSS Dude
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.
"The wonderful thing about Tiggers
Is Tiggers are wonderful things
Their tops are made out of rubber
Their bottoms are made out of springs

They’re bouncy, trouncy, flouncy, pouncy
Fun, fun, fun, fun, fun!
But the most wonderful thing about Tiggers
Is I’m the only one, I’m the only one."

**
Rep: +0/-0Level 88
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... )))
"Oh, mirror, how do i pity you!
Because when the men look at you, they see only themselves, not the mirror, who you really are..."
- Zelbess, Chrono Cross