Load picture based on actor ID

Hi guys, I'm running into a problem..
I want my skillmenu to load a picture based on actor ID. Now I found this topic which seems to have some results:
http://www.rpgmakercentral.com/topic/33527-solved-drawing-pictures-in-scripts/

However, for the life of me I can't get it fixed. It's giving me errors all over the place. What's wrong with the code I added?



Code:
class Window_SkillStatus < Window_Base
   # x: x coordinate
   # y: y coordinate
   # path: Path/Folder and name of the image "Graphics/Pictures/picture.png" for example
    def draw_image(bitmap, width, height)
    x = (bitmap.width - width) * 0.5
    y = (bitmap.height - height) * 0.5
  case actor.id
when 1
      bitmap = Bitmap.new("Graphics/Pictures/picture.png")
      self.contents.blt(x,y,bitmap,Rect.new(0,0,bitmap.width,bitmap.height))
   end

when 2
    def draw_image(bitmap, width, height)
    x = (bitmap.width - width) * 0.5
    y = (bitmap.height - height) * 0.5
      bitmap = Bitmap.new("Graphics/Pictures/picture.png")
      self.contents.blt(x,y,bitmap,Rect.new(0,0,bitmap.width,bitmap.height))
end
end

It's giving me errors on the "when 2". Can anyone help out, please?
Remove the "end" xE

class Window_SkillStatus < Window_Base
# x: x coordinate
# y: y coordinate
# path: Path/Folder and name of the image "Graphics/Pictures/picture.png" for example
def draw_image(bitmap, width, height)
x = (bitmap.width - width) * 0.5
y = (bitmap.height - height) * 0.5
case actor.id
when 1
bitmap = Bitmap.new("Graphics/Pictures/picture.png")
self.contents.blt(x,y,bitmap,Rect.new(0,0,bitmap.width,bitmap.height))
end

when 2
def draw_image(bitmap, width, height)
x = (bitmap.width - width) * 0.5
y = (bitmap.height - height) * 0.5
bitmap = Bitmap.new("Graphics/Pictures/picture.png")
self.contents.blt(x,y,bitmap,Rect.new(0,0,bitmap.width,bitmap.height))
end
end
It would really help if you give us a screenshot of which error message you got, because that tells half of what the error is...


That said, you definatley mixed up your structure - you can't define a function inside an executed command like that, the "def" should go away there. However, I can't tell you how to correctly write the commands there.
Remove the "end" xE

Then it's giving me an error on 19, unexpected $end, expecting keyword_end :<

It would really help if you give us a screenshot of which error message you got, because that tells half of what the error is...

That said, you definatley mixed up your structure - you can't define a function inside an executed command like that, the "def" should go away there. However, I can't tell you how to correctly write the commands there.

Well as said, I got the code from the topic I linked. I legit have no clue what I'm doing, my knowledge of RGSS3 is basic at best.

And current error..
f7ae3952830302121be5475cb1deabe1.png
@BCj The end is reported as missing because you started a def, which in itself is also wrong - see my post above.
Your're basically redefining the function in itself, that can't work ever
So, what can I do about it to make it work? It's said in the topic above like that and it seemed to work for the other person.. No clue how, though..
Oh, I only looked for the "case" structure which goes like this:
case a
when 1..5
"It's between 1 and 5"
when 6
"It's 6"
when String
"You passed a string"
else
"I have no idea what to do with this."
end

But yeah, the rest of the code might give you errors anyway, like Andar mentioned. No clue about that.
Maybe someone could help me out by checking the solution posted in http://www.rpgmakercentral.com/topic/33527-solved-drawing-pictures-in-scripts/ and then comparing to my script, to see what I'm doing wrong? Maybe that'd fix it.
I sorted your code a bit. Maybe it works now?

Code:
class Window_SkillStatus < Window_Base
# x: x coordinate, y: y coordinate
# path: Path/Folder and name of the image "Graphics/Pictures/picture.png" for example
    def draw_image(bitmap, width, height)
        x = (bitmap.width - width) * 0.5
        y = (bitmap.height - height) * 0.5
        case @actor.id
        when 1
            bitmap = Bitmap.new("Graphics/Pictures/Actor1.png")
        when 2
            bitmap = Bitmap.new("Graphics/Pictures/Actor2.png")
        else
            bitmap = Bitmap.new("Graphics/Pictures/ActorNil.png")
        end
        self.contents.blt(x,y,bitmap,Rect.new(0,0,bitmap.width,bitmap.height))
    end
end

I'm guessing every actor uses different picture you have to specify in the "whens" (ids).
no, the solution of that other topic has nothing similiar to what you tried above, there is no second def inside that solution at all.

This is completely untested, but the structure needs to be something like this

Code:
class Window_SkillStatus < Window_Base
   # x: x coordinate
   # y: y coordinate
   # path: Path/Folder and name of the image "Graphics/Pictures/picture.png" for example
   def draw_image(bitmap, width, height)
   x = (bitmap.width - width) * 0.5
   y = (bitmap.height - height) * 0.5
  case actor.id
    when 1
        bitmap = Bitmap.new("Graphics/Pictures/picture.png")
        self.contents.blt(x,y,bitmap,Rect.new(0,0,bitmap.width,bitmap.height))
    end
   when 2
        bitmap = Bitmap.new("Graphics/Pictures/picture.png")
        self.contents.blt(x,y,bitmap,Rect.new(0,0,bitmap.width,bitmap.height))
    end
end
Where did you get the idea of copying the first few lines into the second case structure???

EDIT: Ninja'd
I thought I was supposed to put those lines into the case structures. I didn't know I had to put them before that.

@Kyuukon code isn't giving me any errors - but it's also not loading anything. 🙁
@Andar , yours gives me this:
d2771da9ce4ce398f62474096efef2ec.png

on line 13..
@Kyuukon code isn't giving me any errors - but it's also not loading anything. 🙁
I just changed it up a bit, try now xD! (the @actor.id line).

Also, remember to place pictures for each actor ("Actor1.png", "Actor2.png"...) or change their names!
Though I'm pretty sure there's a more clean way to do this. I don't have VXA base scripts with me now to help further 🙁 If I get some more free time at work, I might check the thread you linked more in details later 😛
@Kyuukon, I added some quick sample pictures, but it still doesn't load for some reason. Using it on a fresh project and the sceen stays the same, doesn't load under the windowskin either (in that case the windowskin would cover it - but even that's not happening). 🙁
Oka.. I checked the thread you linked. It's very out of context so of course it wouldn't work without calling the actual function to draw.

I dunno if this will work (I'm not much of a coder either) but here is the new code adapted:
Code:
class Window_Base
   def draw_image(x,y,path)
      bitmap = Bitmap.new(path)
      self.contents.blt(x,y,bitmap,Rect.new(0,0,bitmap.width,bitmap.height))
   end
end

class Window_SkillStatus < Window_Base
    def draw_actor
        x = 0
        y = 0
        case @actor.id
        when 1
            path = "Graphics/Pictures/Actor1.png"
        when 2
            path = "Graphics/Pictures/Actor2.png"
        else
            path = "Graphics/Pictures/ActorNil.png"
        end
        draw_image(x,y,path)
    end

   def refresh
       contents.clear
       return unless @actor
       draw_actor_face(@actor, 0, 0)
       draw_actor_simple_status(@actor, 108, line_height / 2)
       draw_actor
    end
end

You gotta call the function "draw_actor" somewhere in for it to draw (this time I've already included it). You can change the x, y above the "case @actor.id".

Keep in mind, you already have the function "draw_actor_face" but I'm guessing you will use different graphics than the normal faces for this section, right?
Yes, basically, I want an overlay picture that's above the background/faces etc. I'll test this one out 🙂

Edit: syntax error 🙁
da02a90f043b93d7536c6916c480e228.png
Jeez... sorry. I forgot a word lol. Check now.
Well, that works, but now it only covers the actor part, while actually I want it to start at x = 0 y = 0 of the whole screen..

3ad32ad781468996c370b536ad28ca2d.png


It should be like
be6bc2621cd2cbd8d322e8649ee62831.png


(very quick example to show you what I mean)
Well, that works, but now it only covers the actor part, while actually I want it to start at x = 0 y = 0 of the whole screen..

3ad32ad781468996c370b536ad28ca2d.png


It should be like
be6bc2621cd2cbd8d322e8649ee62831.png


(very quick example to show you what I mean)
What you want exactly? You want it behind or above of everything? You want to do the picture like background window and don't draw the window skin? If you dispose that above everything you will cover it and don't see anything.
@kamekache Above of everything, it should be the toplayer.
I'm going to use it as a mostly blank image with some minor overlays here and there for my menu, so it won't cover the text.
Try this out 🙂 :
Code:
class Window_Base
  def draw_image(x,y,path)
    bitmap = Bitmap.new(path)
    self.contents.blt(x,y,bitmap,Rect.new(0,0,bitmap.width,bitmap.height))
  end
end
 
#==============================================================================
# ** Window_FancyLayer
#==============================================================================
class Window_FancyLayer < Window_Base
  def initialize(x, y)
    super(x, y, Graphics.width, Graphics.height)
    self.windowskin = nil
    @actor = nil
  end
 
  def standard_padding
    return 0
  end
 
  def actor=(actor)
    return if @actor == actor
    @actor = actor
  end
 
  def draw_actor_layer
      x = 0; y = 0
      case @actor.id
      when 1
          path = "Graphics/Pictures/Actor1_FLayer.png"
      when 2
          path = "Graphics/Pictures/Actor2_FLayer.png"
      else
          return
      end
      draw_image(x,y,path)
   end
end

class Scene_Skill < Scene_ItemBase
  def start
    super
    create_help_window
    create_command_window
    create_status_window
    create_item_window
    create_fancylayer_window
  end
  # * Create Fancy Layer Window
  def create_fancylayer_window
    @fancylayer_window = Window_FancyLayer.new(0, 0)
    @fancylayer_window.viewport = @viewport
    @fancylayer_window.actor = @actor
    @fancylayer_window.draw_actor_layer
  end
end

Be mindful I changed the names of the pictures. Check them first!
This script should be above every other custom to avoid compatibility issues since I coded it very lazy lol.

Original thread: https://forums.rpgmakerweb.com/threads/load-picture-based-on-actor-id.74855/