Jump to content
RealModScene
stevewen89

Looking for Utility Scripting Info

Recommended Posts

I'm looking for a way to get the state of the disc drive (reading, empty, initialized, (maybe 360 vs classic vs dvd), etc.). I looking for additional information on "DvdMediaType" and the "DiscTitle flag" that was mentioned in the release notes from 0.7b. "DvdTrayState" is in the github readme, and I was able to implement that function (Aurora.GetDVDTrayState()), but DvdMediaType isn't in the readme, and doesn't appear to be accessible by calling Aurora.GetDVDMediaType(). Maybe there's an even better function to invoke, I'm open to suggestions.

Aurora 0.7b Released! NOVA Included...
Utility Scripts engine improvements

There have been some requests on the forums to add functionality to the Utility Scripts engine. The following items from the changelog reflect some of the changes:

  • (Added) DvdTrayState and DvdMediaType enums to enums.lua
  • (Added) DiscTitle flag to available ContentFlags in enums.lua

Share this post


Link to post
Share on other sites

I'm not sure of the best way to get the Title Name at the moment, but I can try to help with the other questions.

For the tray state, you can use either Aurora.GetDVDTrayState() which returns the following (this does not match the DvdTrayState in Enums.lua):
0 if tray is Open
1 ??? (possibly if tray is Error)
2 if tray is Closed
3 if tray is Opening
4 if tray is Closing

Or you can use Dvd.GetTrayState() which returns the following (this matches the DvdTrayState in Enums.lua):
1 if tray is Closing
2 if tray is Open
3 if tray is Opening
4 if tray is Closed
5 if tray is Error

For the media type, you can use Dvd.GetMediaType() whose return value matches the DvdMediaType in Enums.lua

  • Like 1
  • Thanks 1

Share this post


Link to post
Share on other sites

Thank jrobiche, that worked perfectly. I found the Enums.lua file in the Aurora/Media/Scripts/Content directory to reference. The only issue I'm having is waiting for the disc to initialize. Right now I'm using a hardcoded wait of 16 seconds to give the drive enough time. Dvd.GetMediaType() returns a 0 (none) until the disc is initialized. The system definitely knows when the disc is ready because there's a notification that pops up. I haven't had any luck finding the function to call to check the status of a disc initialization, any ideas?

Where did you find how to use those functions? I couldn't find them documented anywhere.

Share this post


Link to post
Share on other sites
Quote

I haven't had any luck finding the function to call to check the status of a disc initialization, any ideas? 

The best thing that I could find is that Dvd.GetMediaType() returns a 254 whenever my drive is initializing. Unfortunately is the value 254 is not defined in the DvdMediaType enum, so it has to be hard coded. I wrote a script that demonstrates waiting for the DVD to initialize or timeout if it takes too long. If you try it out, let me know if there are any issues.

scriptTitle = "DVD Timeout Example"
scriptAuthor = "jrobiche"
scriptVersion = 1 
scriptDescription = "DVD Timeout Example"
scriptIcon = ""

-- must have filesystem permission to access Dvd functions
scriptPermissions = { "filesystem" }

-- import enums (if there is a better way to do this, please let me know)
package.path = 'Game:\\Media\\Scripts\\Content\\Enums.lua;' .. package.path
require("Enums")

function main()
  local exitScript = false
  repeat
    -- ask user to open or close dvd drive
    local options = {}
    options[1] = "Open DVD Drive"
    options[2] = "Close DVD Drive"
    local ret = Script.ShowPopupList(
      "Options",
      "No options available",
      options
    )   
    if ret.Canceled then
      -- user canceled popup list
      exitScript = true
    elseif ret.Selected.Key == 1 then
      -- user selected to "Open DVD Drive"
      Aurora.OpenDVDTray()
    elseif ret.Selected.Key == 2 then
      -- user selected to "Close DVD Drive"
      Aurora.CloseDVDTray()
      WaitForDvd()
      DisplayDvdStatus()
      Script.SetStatus("Executing Script...")
    end 
  until(exitScript)
end

function DisplayDvdStatus()
  local trayState = Dvd.GetTrayState()
  local mediaType = Dvd.GetMediaType()
  local isDvdInitialized = ( 
    trayState == DvdTrayState.Closed
    and mediaType ~= DvdMediaType.None
    and mediaType ~= 254 
  )
  local infoText = string.format(
    "DVD Initialized: %s\nTray State: %i\nMedia Type: %i",
    tostring(isDvdInitialized),
    Dvd.GetTrayState(),
    Dvd.GetMediaType()
  )
  Script.ShowMessageBox(
    "DVD Information",
    infoText,
    "Close"
  )
end

-- wait for dvd to finish initializing or timeout
-- the media type is 254 when the dvd is loading, but
-- this value is not set in the DvdMediaType enum
function WaitForDvd(timeout)
  timeout = timeout or 60000 -- 60 seconds
  pollInterval = 100 -- 0.1 seconds
  local statusText = ""
  repeat
    local trayState = Dvd.GetTrayState()
    local mediaType = Dvd.GetMediaType()
    statusText = string.format(
      "Timeout: %.1f, Tray: %d, Media: %d",
      timeout / 1000,
      trayState,
      mediaType
    )
    Script.SetStatus(statusText)
    wait(pollInterval)
    timeout = timeout - pollInterval
  until(timeout <= 0 or (trayState == DvdTrayState.Closed and mediaType ~= 254))
end

 

9 hours ago, stevewen89 said:

Where did you find how to use those functions? I couldn't find them documented anywhere.

Lua allows you to print all of the available functions. Select the globals option on https://www.lua.org/cgi-bin/demo for an example of a script that dumps all of the available functions.

Here is the list of undocumented functions:

  • Content.IsScanning
  • Content.StartScan
  • Dvd.CloseTray
  • Dvd.GetMediaType
  • Dvd.GetTrayState
  • Dvd.OpenTray
  • FileSystem.GetPartitionFreeSpace
  • FileSystem.GetPartitionSize
  • FileSystem.GetPartitionUsedSpace
  • FileSystem.InstallTitleFromDisc
  • Http.GetEx
  • Http.PostEx
  • Profile.EnumerateProfiles
  • Profile.GetProfilePicture
  • Profile.Login
  • Profile.Logout
  • Script.IsCancelEnabled
  • Script.SetCancelEnable
  • Script.ShowPasscodeEx
  • Settings.AddRSSFeed
  • Settings.DeleteRSSFeed
  • Settings.GetRSSFeedByID
  • Settings.GetRSSFeeds
  • Settings.UpdateRSSFeed

I do not know how to get the parameters that the functions expect though, may have to reach out to a developer for more information on these functions

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...