Thread: OnDesktopInit() question
-
April 25th, 2018, 23:14 #1
- Join Date
- Jul 2017
- Location
- VA, USA
- Posts
- 56
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
-
April 26th, 2018, 00:40 #2
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
-
April 26th, 2018, 00:57 #3
- Join Date
- Jul 2017
- Location
- VA, USA
- Posts
- 56
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.
-
April 26th, 2018, 01:19 #4Private 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!
-
April 26th, 2018, 01:59 #5
- Join Date
- Jul 2017
- Location
- VA, USA
- Posts
- 56
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.
-
April 26th, 2018, 02:13 #6
Supreme Deity
- Join Date
- Mar 2007
- Posts
- 20,561
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
-
April 26th, 2018, 12:11 #7
- Join Date
- Jul 2017
- Location
- VA, USA
- Posts
- 56
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.
-
April 26th, 2018, 13:29 #8
Have a look at Trenloes Message of the Day extension. I think it uses the same trigger.
-
April 26th, 2018, 13:59 #9
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.xcpPrivate 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!
-
April 26th, 2018, 19:00 #10
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