• Our software update is now concluded. You will need to reset your password to log in. In order to do this, you will have to click "Log in" in the top right corner and then "Forgot your password?".
  • Welcome to PokéCommunity! Register now and join one of the best fan communities on the 'net to talk Pokémon and more! We are not affiliated with The Pokémon Company or Nintendo.

[Eventing Question] script list for events

153
Posts
4
Years
  • Age 36
  • Seen Feb 4, 2020
Hey,

I was wondering where I could find an equivalent for ALL the functions directly implemented in event but in script. On the wiki there are some examples (pbWait(x),pbShake(power,speed,x),pbFlash(color,x),pbToneChangeAll(tone,duration),pbMoveRoute(event,commands)) and then a list of actions that seem to be inside "moveroute" and I don't understand how to use them.

I'm much interested on how to display a picture on the screen and how to move it.

Thank you in advance !
 
153
Posts
4
Years
  • Age 36
  • Seen Feb 4, 2020
I found
Code:
pbShowPicture(number,name,origin,x,y,zoomX=100,zoomY=100,opacity=255,blendType=0)
But I don't understand how to use it. Do I replace number by 1 and the name by "/Graphics/Pictures/myimage" ? I had a method error doing this
 
1,403
Posts
10
Years
  • Seen Apr 18, 2024
I don't have the code in front of me, but maybe you can Ctrl+Shift+F to search for uses of pbShowPicture to see what they pass?
 
153
Posts
4
Years
  • Age 36
  • Seen Feb 4, 2020
---------------------------
Pokemon Essentials
---------------------------
[Pokémon Essentials version 17.2]

Exception: NoMethodError

Message: undefined method `pbShowPicture' for nil:NilClass

PItem_ItemEffects:37

PItem_ItemEffects:36:in `call'

EventHandlers:150:in `trigger'

PItem_Items:206:in `triggerUseFromBag'

PItem_Items:653:in `pbUseItem'

PScreen_Bag:484:in `pbStartScreen'

PScreen_Bag:448:in `loop'

PScreen_Bag:557:in `pbStartScreen'

PScreen_PauseMenu:189:in `pbStartPokemonMenu'

PScreen_PauseMenu:186:in `pbFadeOutIn'



This exception was logged in

C:\Users\Gwen\Saved Games\Pokemon Essentials\errorlog.txt.

Press Ctrl+C to copy this message to the clipboard.
---------------------------
OK
---------------------------
Maybe I just have to paste the "def pbshowpicture..." in the item handler section? or where?
 
Last edited:
1,403
Posts
10
Years
  • Seen Apr 18, 2024
Your error looks like you've tried to do nil.pbShowPicture (although probably not literally nil on the lhs). Ideally you'd want to call the existing pbShowPicture on an object of the appropriate class (i.e. the class where pbShowPicture is defined). But maybe you could copy the function elsewhere, provided it doesn't depend on anything else from inside that class.
 
153
Posts
4
Years
  • Age 36
  • Seen Feb 4, 2020
mmh It is in a module called interpreterMixin so I wrote interpreterMixin.pbShowPicture and got this.

---------------------------
Pokemon Essentials
---------------------------
[Pokémon Essentials version 17.2]

Exception: NoMethodError

Message: undefined method `pbShowPicture' for InterpreterMixin:Module

PItem_ItemEffects:38

PItem_ItemEffects:36:in `call'

EventHandlers:150:in `trigger'

PItem_Items:207:in `triggerUseFromBag'

PItem_Items:654:in `pbUseItem'

PScreen_Bag:484:in `pbStartScreen'

PScreen_Bag:448:in `loop'

PScreen_Bag:557:in `pbStartScreen'

PScreen_PauseMenu:189:in `pbStartPokemonMenu'

PScreen_PauseMenu:186:in `pbFadeOutIn'



This exception was logged in

C:\Users\Gwen\Saved Games\Pokemon Essentials\errorlog.txt.

Press Ctrl+C to copy this message to the clipboard.
---------------------------
OK
---------------------------

note that when I added the definition of pbshowpicture in item, i had no more error message but still no picture showing.
note2 that when i do this the action always shows the message "can't use that here" in the end
 
1,680
Posts
8
Years
  • Age 24
  • Seen today
The Interpreter script section is a useful script section to reference in this case as its what actually runs the commands from the event. flippimg through that is a good place to start.
somw of those methods have be overridden in later script sections though, but I dont remember wich ones at the moment.
 
153
Posts
4
Years
  • Age 36
  • Seen Feb 4, 2020
Ok thanks i'll check. I had another idea, maybe the item can't be used from the bag? I should have defined it somewhere where i didn't that's why the sentence "can't use that here" shows?
 
153
Posts
4
Years
  • Age 36
  • Seen Feb 4, 2020
I found a solution!!!!

It actually needed no scripting, I just made my item a mail then you can open it and it shows the picture even if stored in another pocket.

Still I'm interested by the function who allow a script to display a picture
 

Ego13

hollow_ego
311
Posts
6
Years
Code:
pbShowPicture
is meant to be used in a script event command (basically in an event that you set up in the overworld map) and it will probably only work in that enviroment, judging by the code.

If you want to display an image in any other enviroment you will need at least four lines of code:
Code:
viewport   = Viewport.new(0,0,Graphics.width,Graphics.height)
viewport.z = 99999
image          = Sprite.new(viewport)
image.bitmap   = Bitmap.new("PATH TO YOUR IMAGE")

This will position your image at the top left corner. To reposition it you need the following code:
Code:
image.x=100
image.y=100

You also need to get rid of the image manually. You can do that with this line:
Code:
viewport.dispose
 
Last edited:
153
Posts
4
Years
  • Age 36
  • Seen Feb 4, 2020
Wow Thank You!

So I put my item back to key item and made an item effect like this:
Code:
ItemHandlers::UseFromBag.add(:PHOTO2,proc{|item|
    viewport   = Viewport.new(0,0,Graphics.width,Graphics.height)
    viewport.z = 99999
    image          = Sprite.new(viewport)
    image.bitmap   = Bitmap.new("Graphics/Pictures/luffy")
   next  2 
})
though when I use the item it says "can't use that here"

What am I doing wrong?

Edit:
I looked for a possible reason for this message to be displayed as the sentence is not defined in my item effect and I found this
Code:
elsif $ItemData[item][ITEMUSE]==2 # Item is usable from bag
    intret=ItemHandlers.triggerUseFromBag(item)
    case intret
    when 0; return 0
    when 1; return 1 # Item used
    when 2; return 2 # Item used, end screen
    when 3; bag.pbDeleteItem(item); return 1 # Item used, consume item
    when 4; bag.pbDeleteItem(item); return 2 # Item used, end screen and consume item
    else; Kernel.pbMessage(_INTL("Can't use that here.")); return 0
    end
  else
    Kernel.pbMessage(_INTL("Can't use that here."))
    return 0
  end
Is there a place other than the pbs where I have to say my item is usable from bag?
Edit2:
I actually wrote it badly in the pbs and now replaced the 0 by 2 in the three last numbers which are now 2,0,6
It made a difference because now the window is closing but after the message "can't use that here" shows again I guess the triggerUseFromBag gives 2 because it's ending the screen but then the message shows and no picture is displayed

thanks in advance

Edit 3:
SOLVED!!! I didn't define a itemhandlers.UseInField it now works perfectly.

The only little problem is I used the line
Code:
viewport.dispose
only in the UseFromBag, when used in both the picture was not showing at all. Now that it's only in UseFromBag the picture vanishes after what looks like a random time. To solve it I made it display a message after. It now wait the message to be passed by the player then the picture vanishes.

Thank you a whole lot to all of you especially Ego who literally solved it <3
 
Last edited:

Ego13

hollow_ego
311
Posts
6
Years
As far as I can see your item setup seems to be correct, however I believe you are using the wrong handler.

I looked at how the town map works and it uses the following code:

Code:
ItemHandlers::UseInField.add(:TOWNMAP,proc{|item|
   pbShowMap(-1,false)
   next 1
})

So you also need an UseInField handler and a return value of 1.

Besides that: To show the image as long as the player want it to be shown you need to add a loop to your code. Otherwise the image will disappear "whenever it feels like it". I was about to make a video tutorial on how all this works, but didn't do it yet due to bad recording quality.

Your code for your image item should look somewhat like this:

Code:
viewport      = Viewport.new(0,0,Graphics.width,Graphics.height)
  viewport.z    = 99999
  
  image         = Sprite.new(viewport)
  image.bitmap  = Bitmap.new(YOUR GRAPHIC FILE PATH)
  image.x		    = 100
  image.y		    = 100
  loop do
    Input.update
    Graphics.update
    if Input.trigger?(Input::C) # image will be closed and properly disposed when the player presses c / enter
      image.dispose
      viewport.dispose
      break
    end
  end
  pbWait(20)# wait a bit to prevent double input
 
Last edited:
153
Posts
4
Years
  • Age 36
  • Seen Feb 4, 2020
damn didn't see your answer but I found it myself :D Though your solution of doing a loop is even better.

Thank you man
 
Last edited:
153
Posts
4
Years
  • Age 36
  • Seen Feb 4, 2020
now if i want this to apply to other objects I can just add the line in both useinfield and usefrombag:
Code:
ItemHandlers::UseInField.copy(:PHOTO2,:PHOTO3,:PHOTO4,:PHOTO5,:PHOTO6,:PHOTO7,:PHOTO8)
but then all these items will display the same picture. is there a way to copy but modify one line (in this case the link to the picture)?
 

Ego13

hollow_ego
311
Posts
6
Years
There is. Right now the image that will be shown is hard coded. I recommend naming your file exactly as the item and change the code as follows:
Code:
image.bitmap   = Bitmap.new("Graphics/Pictures/"+PBItems.getName(item))
 
153
Posts
4
Years
  • Age 36
  • Seen Feb 4, 2020
Oh waw cool, is is possible to use the internal name instead of the displayed name? I guess it is I'll try
 
Back
Top