I have no idea why my OnPCLoaded script isn't opening a GUI element for PCs. Can anyone spot what I did wrong? I have the XML in my override. Thanks in advance!
#include "mod_events_i"
// Private function; handles assignment of a wand to each incoming DM.
void _GrantWand(object oDM);
//Private function; handles opening of TB ready GUI.
void _LBToggle(object oPC);
void main()
{
ModuleOnPCLoaded();
object oEntrant = GetEnteringObject();
if (GetIsDM(oEntrant)) {
DelayCommand(5.0, _GrantWand(oEntrant));
}
else {
DelayCommand(5.0, _LBToggle(oEntrant));
}
}
void _GrantWand(object oDM)
{
//The grant wand function is here.
}
void _LBToggle(object oPC) {
if (!GetIsDM(oPC) && !GetIsDMPossessed(oPC)) {
DisplayGuiScreen(oPC, "LBTOGGLE_BUTTON", FALSE, "LBToggle.xml");
}
}
Mod OnPCLoaded help
Débuté par
Mad.Hatter
, mai 28 2012 01:37
#1
Posté 28 mai 2012 - 01:37
#2
Posté 28 mai 2012 - 06:18
Unlike nwscript, GUI XML scripts will simply not run if there is an error anywhere in them. This unfortunately makes them difficult to debug.
You could try a super-simple GUI or one that you know for a fact works. If you're using Lance B's then I guess it would fall under the second category.
You could try a super-simple GUI or one that you know for a fact works. If you're using Lance B's then I guess it would fall under the second category.
#3
Posté 28 mai 2012 - 07:24
Lance actually wrote the xml for me, so I know it is a problem with my script.
#4
Posté 28 mai 2012 - 11:51
Hi MH,
In case you read this before my email to you, I replied with this about your script:
"As for your script, I do not know what your ModuleOnPCLoaded(); function does, which I assume is a function from the mod_events_i include. Besides that, you should not require any delays to make this work."
EDIT: Make sure you are testing with my original XML file, which we know works. (I know you were considering editing it slightly for size differences, which, as MC points out, may have also introduced an error that now prevents it from showing.)
EDIT: I have found that GUIs sometimes do not work when there are delays involved in calling them, especially if you are testing for an object 5 seconds later that was part of the original call. You are better off moving the conditional check for the DM before making the GUI call. However, if you can avoid the delay altogether, then even better.
Cheers!
Lance.
EDIT:
#include "mod_events_i"
// Private function; handles assignment of a wand to each incoming DM.
void _GrantWand(object oDM);
//Private function; handles opening of TB ready GUI.
void _LBToggle(object oPC);
void main()
{
ModuleOnPCLoaded();
object oEntrant = GetEnteringObject();
if (GetIsDM(oEntrant)) {
DelayCommand(5.0, _GrantWand(oEntrant));
}
else if (!GetIsDM(oEntrant) && !GetIsDMPossessed(oEntrant)){
DelayCommand(5.0, _LBToggle(oEntrant)); // REMOVE DELAY FROM HERE IF IT OFTEN FAILS
}
}
void _GrantWand(object oDM)
{
//The grant wand function is here.
}
void _LBToggle(object oPC)
{
DisplayGuiScreen(oPC, "LBTOGGLE_BUTTON", FALSE, "LBToggle.xml");
}
In case you read this before my email to you, I replied with this about your script:
"As for your script, I do not know what your ModuleOnPCLoaded(); function does, which I assume is a function from the mod_events_i include. Besides that, you should not require any delays to make this work."
EDIT: Make sure you are testing with my original XML file, which we know works. (I know you were considering editing it slightly for size differences, which, as MC points out, may have also introduced an error that now prevents it from showing.)
EDIT: I have found that GUIs sometimes do not work when there are delays involved in calling them, especially if you are testing for an object 5 seconds later that was part of the original call. You are better off moving the conditional check for the DM before making the GUI call. However, if you can avoid the delay altogether, then even better.
Cheers!
Lance.
EDIT:
#include "mod_events_i"
// Private function; handles assignment of a wand to each incoming DM.
void _GrantWand(object oDM);
//Private function; handles opening of TB ready GUI.
void _LBToggle(object oPC);
void main()
{
ModuleOnPCLoaded();
object oEntrant = GetEnteringObject();
if (GetIsDM(oEntrant)) {
DelayCommand(5.0, _GrantWand(oEntrant));
}
else if (!GetIsDM(oEntrant) && !GetIsDMPossessed(oEntrant)){
DelayCommand(5.0, _LBToggle(oEntrant)); // REMOVE DELAY FROM HERE IF IT OFTEN FAILS
}
}
void _GrantWand(object oDM)
{
//The grant wand function is here.
}
void _LBToggle(object oPC)
{
DisplayGuiScreen(oPC, "LBTOGGLE_BUTTON", FALSE, "LBToggle.xml");
}
Modifié par Lance Botelle, 28 mai 2012 - 12:19 .





Retour en haut






