some scripting questions

Started by M3T41 AG3, May 07, 2010, 02:51:25 pm

Previous topic - Next topic

Jragyn

I uhh...didn't see if anyone answered this last bit, so erm, the general method to calling to an actor's experience till the next level is this:
Quote@actor.next_rest_exp_s


like in use of this manner:
    self.contents.draw_text(480, 64, 84, 32, @actor.next_rest_exp_s, 2)



So...yup.
next_rest_exp_s.
The string form of the experience remaining to the next level!
A bright light can either illuminate or blind, but how will you know which until you open your eyes?

M3T41 AG3

June 06, 2010, 03:03:54 pm #21 Last Edit: June 28, 2010, 12:03:00 pm by M3T41 AG3
question 8: im working with this code
class ICON < Window_Selectable
 
 def initialize
   super (1,100,20,20)
 end
 
def update (i)
  if Input.trigger?(Input::A)
    print i
  end
end

 
end

i have this set with multiple icons on screen they do the same thing but on diffrent characters however whenever the "a" button is pressed all of the icons trigger not just the specific one that was clicked? what can i do to fix this

M3T41 AG3


M3T41 AG3


ForeverZer0

Quote from: M3T41 AG3 on June 10, 2010, 12:34:12 am
bump/
is this not possible??


You need to be a little more specific on what you are doing, or trying to do. I personally have no idea what you are asking. From the sounds of it, you need to be a little more specific on what happens when the A button is pressed. Maybe an example of the code your working with would help...  :P
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

M3T41 AG3

June 19, 2010, 07:10:19 pm #25 Last Edit: June 19, 2010, 07:12:35 pm by M3T41 AG3
Spoiler: ShowHide
class MYTH_MAIN
 
def initialize(menu_index=0)
  $menu_index = menu_index
end

def main
  $battlebackground = Sprite.new
  $battlebackground.bitmap = Bitmap.new("Graphics/Battlebacks/#{$game_map.battleback_name}")
  $battlebackground.x = 0
  $battlebackground.y = 0
  $battlebackground.z = 101
  $battler = []
  @icon = []
  $enemy = []
  for i in 0...$game_party.actors.size
   $battler[i] = Sprite.new
   $battler[i].bitmap = Bitmap.new("Graphics/Battlers/#{$game_party.actors[i].battler_name}")
    if i == 0 then
      $battler[i].x = 10
    else
      $battler[i].x = $battler[i - 1].x + 150
    end
    $battler [i].y = 100
    $battler [i].z = 101
    @icon[i] = ICON.new
    @icon[i].x = $battler[i].x + 10
    @icon[i].z = 102
  end
     
  Graphics.transition
 loop do
  Graphics.update
  Input.update
  #update
  for i in 0...$game_party.actors.size
    @icon[i].update(i)
    end
  if $scene != self
   break
  end
 end
 Graphics.freeze
end  

end


class ICON < Window_Selectable
 
 def initialize
   super (1,100,20,20)
 end
 
def update (i)
  if Input.trigger?(Input::A)
    print i
  end
end

 
end

im trying to get the icons to display the action menu (not yet coded) that has all of the actions/commands you can use in battle and form there im just going to let the default battle system take over.

ForeverZer0

Quote from: M3T41 AG3 on June 19, 2010, 07:10:19 pm
Spoiler: ShowHide
class MYTH_MAIN
 
def initialize(menu_index=0)
  $menu_index = menu_index
end

def main
  $battlebackground = Sprite.new
  $battlebackground.bitmap = Bitmap.new("Graphics/Battlebacks/#{$game_map.battleback_name}")
  $battlebackground.x = 0
  $battlebackground.y = 0
  $battlebackground.z = 101
  $battler = []
  @icon = []
  $enemy = []
  for i in 0...$game_party.actors.size
   $battler[i] = Sprite.new
   $battler[i].bitmap = Bitmap.new("Graphics/Battlers/#{$game_party.actors[i].battler_name}")
    if i == 0 then
      $battler[i].x = 10
    else
      $battler[i].x = $battler[i - 1].x + 150
    end
    $battler [i].y = 100
    $battler [i].z = 101
    @icon[i] = ICON.new
    @icon[i].x = $battler[i].x + 10
    @icon[i].z = 102
  end
     
  Graphics.transition
 loop do
  Graphics.update
  Input.update
  #update
  for i in 0...$game_party.actors.size
    @icon[i].update(i)
    end
  if $scene != self
   break
  end
 end
 Graphics.freeze
end  

end


class ICON < Window_Selectable
 
 def initialize
   super (1,100,20,20)
 end
 
def update (i)
  if Input.trigger?(Input::A)
    print i
  end
end

 
end

im trying to get the icons to display the action menu (not yet coded) that has all of the actions/commands you can use in battle and form there im just going to let the default battle system take over.


I'll take a look here. At a glance, though, why do you have all the global variables? It would be better to make them public instance variables and create attr_accessors if you need to access them outside the class.

You also do need not set the x and y. Each is 0 already unless it is otherwise defined.
Also, it is not good to have much more than Graphics, Input, and the normal update in the main loop. I see you have the update commented out and have other stuff in there. Just put the other stuff in the update method, and write it like this:

@icons.each {|icon| icon.update}

Check the help menu chapter Enumerable to learn more about that. Once you properly learn how to use iterators, it will open up a lot of different things that you can do. I'll look at this a little more in a little bit and get back to you.
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

M3T41 AG3

thanks for looking but i just recenly sovled it myself. thanks again though