5E Character Create Playlist
Page 1 of 2 12 Last
  1. #1

    OnDesktopInit() question

    I'd like to set the lighting for clients when they connect, rather than waiting for all to connect then set the lighting.

    I figured I could use the OnDesktopInit() event, but now I'm unsure of when this event is triggered or if I'm going to be able to do this.

    Code:
    function onInit()
        Interface.onDesktopInit = onDesktopInit;
    end
    function OnDesktopInit()
        Interface.setLighting('FFFFFF', '701919', 'FFFFFF', 'FFFFFF');
    end
    Possibly, if that is not able to be done, execute the setLighting method when a user connects to the host.

  2. #2
    Mortar's Avatar
    Join Date
    May 2014
    Location
    New Brunswick, Canada
    Posts
    1,127
    Blog Entries
    18
    Isn't easier just to set the lighting before any of your players connect? That way its already set for them as it essentially is your desktop settings that are being transferred to the player clients
    Ultimate License Holder

  3. #3
    It doesn't work like that. It only sets the lighting for connected clients. So if the GM sets lighting then someone else joins he has to reset. This would be more of an ease of use thing.

  4. #4
    Trenloe's Avatar
    Join Date
    May 2011
    Location
    Colorado, USA
    Posts
    33,411
    Quote Originally Posted by Ezio View Post
    Code:
    function onInit()
        Interface.onDesktopInit = onDesktopInit;
    end
    function OnDesktopInit()
        Interface.setLighting('FFFFFF', '701919', 'FFFFFF', 'FFFFFF');
    end
    Have you tried this? There may be timing issues, but it's worth giving it a go - it's not a huge amount of code to test.
    Private Messages: My inbox is forever filling up with PMs. Please don't send me PMs unless they are actually private/personal messages. General FG questions should be asked in the forums - don't be afraid, the FG community don't bite and you're giving everyone the chance to respond and learn!

  5. #5
    I have and it doesn't work or maybe the event triggers too soon or a part isn't actually initialized. I just don't quite know enough about how OnDesttopInit() works.

    I did try to replicate getting the character selection window to open and the setup window. Just to get a data point and see if the event is actually being triggered, but that wasn't working either.

  6. #6
    Only the GM can set the lighting, so it has to be initiated on the GM side. If you want to trigger on a user login, then you can do something like:

    Code:
    function onInit()
      if (User.isHost) 
        User.onLogin = onUserLogin;
      end
    end
    function onUserLogin()
      Interface.setLighting('FFFFFF', '701919', 'FFFFFF', 'FFFFFF');
    end
    JPG

  7. #7
    Quote Originally Posted by Moon Wizard View Post
    Only the GM can set the lighting, so it has to be initiated on the GM side. If you want to trigger on a user login, then you can do something like:

    Code:
    function onInit()
      if (User.isHost) then
        User.onLogin = onUserLogin;
      end
    end
    function onUserLogin()
      Interface.setLighting('FFFFFF', '701919', 'FFFFFF', 'FFFFFF');
    end
    JPG
    I assumed I would have to use something like this as the GM can only set the lighting, but wasn't sure if that was application level lock or deeper.

    I've tried the code you've suggested above Moon, but still no dice. I've even tried just getting a message pumped to chat window when the event fires, but it's not doing that either so I don't know if I'm just not initializing the script in the extension.xml file correctly or what. I'll attach the .ext if you want to take a look at it.
    Attached Files Attached Files

  8. #8

  9. #9
    Trenloe's Avatar
    Join Date
    May 2011
    Location
    Colorado, USA
    Posts
    33,411
    Quote Originally Posted by damned View Post
    Have a look at Trenloes Message of the Day extension. I think it uses the same trigger.
    Indeed it does.

    But, Ezio is basically using the right code.

    @Ezio - the issue is that the calling of your startup script is not valid. You need a "name" with the <script> tag. Change your code extension.xml to:

    <script name="MyStartup" file="script\startup.lua" />

    Info on the <script> syntax here: https://www.fantasygrounds.com/refdoc/script.xcp
    Private Messages: My inbox is forever filling up with PMs. Please don't send me PMs unless they are actually private/personal messages. General FG questions should be asked in the forums - don't be afraid, the FG community don't bite and you're giving everyone the chance to respond and learn!

  10. #10
    Quote Originally Posted by Ezio View Post
    I've tried the code you've suggested above Moon, but still no dice. I've even tried just getting a message pumped to chat window when the event fires, but it's not doing that either so I don't know if I'm just not initializing the script in the extension.xml file correctly or what. I'll attach the .ext if you want to take a look at it.
    Your logic simply isn't executing then. If it's global at <base></base> then it should execute, if it's within an xml, then that xml needs to be active. IE: a window's script attached xml will only execute after the window is opened/launched etc...

    A side note for xml element dependent scripts is that that element needs to be active/open for the host, as the script will only be valid for the host. May as well wrap it up in a if User.isHost().
    Last edited by Ken L; April 26th, 2018 at 19:04.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
STAR TREK 2d20

Log in

Log in