PSMD Scripting

From ProjectPokemon Wiki
Revision as of 00:04, 3 February 2017 by UniqueGeek (talk | contribs)
Jump to navigation Jump to search

PSMD Scripting

This page lists snippets of LUA code that can be used to achieve various tasks.

In examples below, the placeholder "[string]" can be replaced with an integer equal to the ID of the desired string resource or with a short inline string. When using an inline string, only certain characters will be displayed in game (meaning no spaces separating words). Because of this, it is recommended to use string resources when possible.

Harmony Scarf Evolution

 CHARA:PreLoadHeroPartnerFinalEvlolution()
 CUT:Load(SymCut("m15_120_06"))
 SOUND:PlayBgm(SymSnd("BGM_EVE_HENSHIN"), Volume(256))
 SOUND:FadeInEnv(SymSnd("SE_EVT_FINAL_EV_BACK_LP"), TimeSec(0.5), Volume(128))
 CUT:Play()
 CUT:Wait()
 CUT:Destroy()
 CAMERA:SetSisaAzimuthDifferenceVolume(Volume(1.5))
 CAMERA:SetSisaRateVolume(Volume(1))
 TASK:Sleep(TimeSec(0.5))
 CAMERA:SetEye(SymCam("CAMERA_00"))
 CAMERA:SetTgt(SymCam("CAMERA_00"))
 CAMERA:SetFovy(SymCam("CAMERA_00"))
 SCREEN_A:WhiteIn(TimeSec(0.5), false)

Select Chain

 WINDOW:SelectStart()
 -- The values in each WINDOW:SelectChain are customizable.
 -- If so many are added that they do not all fit on the screen, pressing up and down will wrap around what's visible, and left and right will swap pages
 WINDOW:SelectChain([string], 0)
 WINDOW:SelectChain([string], 1)
 WINDOW:SelectChain([string], 2)
 WINDOW:DefaultCursor(0) -- Can be set to any value already set; in this case, 0, 1, or 2
 local id = WINDOW:SelectEnd(MENU_SELECT_MODE.DISABLE_CANCEL)
 -- TODO: Add your own logic to respond to `id`
 WINDOW:CloseMessage()

Basic Player/Partner Species Change

Written by psy_commando. Mis-spelt variables are references to variables from seikakushindan.lua (the starting sequence script).

 repeat
    WINDOW:CloseMessage()
    WINDOW:SysMsg("Select _ Pokemons ?(Menu#2)")
    WINDOW:SelectStart()
    WINDOW:SelectChain("Done", 0)
    WINDOW:SelectChain("Set Hero pkid", 1)
    WINDOW:SelectChain("Set Partner pkid", 2)
    WINDOW:DefaultCursor(0)
    local id = WINDOW:SelectEnd(MENU_SELECT_MODE.DISABLE_CANCEL)
 
    if id == 1 then
      WINDOW:SysMsg( "--- Changing _ Hero _ pokemon _ id ---" )
      local oldpokemonid = SymAct("HERO"):GetIndex()
      local menu      = MENU:CreateNumericMenuWindow(ScreenType.A)
      menu:SetLayoutRect(Rectangle(96, 80, 132, 84))
      menu:SetPlace(3)
      menu:SetDigit(3)
      menu:SetStartNum(initval)
      menu:SetType(NUM_MENU_TYPE.TYPE_DIGIT_ON)
      menu:SetTextOffset(24, 40)
      function menu:decideAction()
        charname = self:GetSettingData()
        GROUND:SetHero(charname, 0)
        CHARA:ReloadHeroPartner()
        self:Close()
      end
      function menu:cancelAction()
        charname = oldpokemonid
        GROUND:SetHero(charname, 0)
        CHARA:ReloadHeroPartner()
        self:Close()
      end
      menu:Open()
      menu:SetCaption("Pokemon ID")
      MENU:SetFocus(menu)
      MENU:WaitClose(menu)
    elseif id == 2 then
      WINDOW:SysMsg( "--- Changing _ Partner _ pokemon _ id ---" )
      local oldpokemonid = SymAct("HERO"):GetIndex()
      local menu      = MENU:CreateNumericMenuWindow(ScreenType.A)
      menu:SetLayoutRect(Rectangle(96, 80, 132, 84))
      menu:SetPlace(3)
      menu:SetDigit(3)
      menu:SetStartNum(initval)
      menu:SetType(NUM_MENU_TYPE.TYPE_DIGIT_ON)
      menu:SetTextOffset(24, 40)
      function menu:decideAction()
        pertnername = self:GetSettingData()
        GROUND:SetPartner(pertnername, 0)
        CHARA:ReloadHeroPartner()
        self:Close()
      end
      function menu:cancelAction()
        pertnername = oldpokemonid
        GROUND:SetPartner(pertnername, 0)
        CHARA:ReloadHeroPartner()
        self:Close()
      end
      menu:Open()
      menu:SetCaption("Pokemon ID")
      MENU:SetFocus(menu)
      MENU:WaitClose(menu)
    end
  until id == 0

Credits

psy_commando for writing several samples and for pioneering PSMD script editing. evandixon for further research.