Advertiser Content

Eventing Question script list for events

Started by Tsuina September 13th, 2019 12:23 AM
  • 1459 views
  • 19 replies
Male
Seen 4 Days Ago
Posted October 17th, 2019
153 posts
206 Days
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 !
Male
Seen 4 Days Ago
Posted October 17th, 2019
153 posts
206 Days
---------------------------
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?

mgriffin

Seen 1 Hour Ago
Posted 4 Hours Ago
797 posts
5.6 Years
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.
Male
Seen 4 Days Ago
Posted October 17th, 2019
153 posts
206 Days
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

Vendily

Female
Online now
Posted 1 Day Ago
987 posts
4.3 Years
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.

Ego13

hollow_ego

Male
Larua Region
Seen 14 Hours Ago
Posted 1 Week Ago
305 posts
2.4 Years
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:
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:
image.x=100
image.y=100
You also need to get rid of the image manually. You can do that with this line:
viewport.dispose
Looking for spriters to help with

Pokemon Hollow on pokecommunity.com
Male
Seen 4 Days Ago
Posted October 17th, 2019
153 posts
206 Days
Wow Thank You!

So I put my item back to key item and made an item effect like this:
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
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
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

Ego13

hollow_ego

Male
Larua Region
Seen 14 Hours Ago
Posted 1 Week Ago
305 posts
2.4 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:

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:

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
Looking for spriters to help with

Pokemon Hollow on pokecommunity.com
Male
Seen 4 Days Ago
Posted October 17th, 2019
153 posts
206 Days
now if i want this to apply to other objects I can just add the line in both useinfield and usefrombag:
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

Male
Larua Region
Seen 14 Hours Ago
Posted 1 Week Ago
305 posts
2.4 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:
image.bitmap   = Bitmap.new("Graphics/Pictures/"+PBItems.getName(item))
Looking for spriters to help with

Pokemon Hollow on pokecommunity.com
Advertiser Content