Please can someone explain what is wrong with the following code
BTW it was working until yesterday!
object oSafeArea = GetObjectByTag("char_stage", 0);
if (IsObjectValid(oSafeArea)) {
DisplayFloatyMessage(GetHero(), "So far so good", FLOATY_MESSAGE, 16777215, 10.0);
} else {
DisplayFloatyMessage(GetHero(), "Problems", FLOATY_MESSAGE, 16777215, 10.0);
}
NN
char_stage - Does it exist? or is it totally random
Débuté par
nn125
, déc. 23 2009 01:10
#1
Posté 23 décembre 2009 - 01:10
#2
Posté 23 décembre 2009 - 02:15
It looks fine.
It is reporting "Problems", I take it? Where is the hero and what event is the above code in?
It is reporting "Problems", I take it? Where is the hero and what event is the above code in?
#3
Posté 23 décembre 2009 - 03:16
Every area (Noticed first in Ostagar), originally in Load_Module event, a callable script and a test script
This was working yesterday, I tweaked a bit of code. recompiled and its not working - Removed the tweak and its still not working,
This was working yesterday, I tweaked a bit of code. recompiled and its not working - Removed the tweak and its still not working,
#4
Posté 23 décembre 2009 - 07:17
The only thing I can think of is "char_stage" literal has been messed up with an undisplayable character. Try deleting the line and manually typing it again.
It probably won't work, but I can't think of any reason for it. I'll build a test function and try the same code.
It probably won't work, but I can't think of any reason for it. I'll build a test function and try the same code.
#5
Posté 23 décembre 2009 - 07:29
Just scraped it off the OP and put it into one of my test modules. It works fine for me. I'm at a loss for suggestions.
#6
Posté 23 décembre 2009 - 10:35
Thanks for trying - I retyped the offending name and it still doesn't work. I guess the game hates me. Only thing I can think, it might be a bloody dlc or a conflict in the override directory.- Guess I might try and clear it all and see what happens
#7
Posté 24 décembre 2009 - 08:02
Try and export the area only. Sometimes when you do F9 (to export everything with dependencies) the areas will not export. So select the area, right click -> export.
#8
Posté 24 décembre 2009 - 10:47
How do I export char_stage - Isn't it part of the game
NN
NN
#9
Posté 24 décembre 2009 - 01:01
I found the thing under global and tries the export route and it worked
I am now not sure if I am happy or worried - Isn't this surpossed to be always there - Will this mess up any other part of the game.
Bioware def not make things easy
NN
I am now not sure if I am happy or worried - Isn't this surpossed to be always there - Will this mess up any other part of the game.
Bioware def not make things easy
NN
#10
Posté 24 décembre 2009 - 03:41
Thanks to all that helped. Finally got the code working that will create an inventory that can be attached to any placable or item as required (more than 1 if wanted) - Anyway heres the code. As pointed out char_stage needs to be exported to ensure working (weird as I thought it was a game resource!
Also it works without Local Variables (another flakey part of Toolkit).
THE GENERAL FUNCTIONS
const string PUPS_SAFE_AREA = "char_stage";
object SafeArea ()
{
return GetObjectByTag(PUPS_SAFE_AREA, 0);
}
location GetSafeLoc (object oArea)
{
return GetSafeLocation(Location(oArea, Vector(0.0, 0.0, 0.0), 0.0));
}
object GetSafe (object oPC, string sName)
{
return GetObjectByTag(sName, 0);
}
object SafeSetup(object oPC, string sName)
{
object oSafe = GetSafe (oPC, sName);
if (!IsObjectValid(oSafe)) {
object oSafe = CreateObject(OBJECT_TYPE_PLACEABLE, R"pups_safe_pla_store.utp",GetSafeLoc(GetArea(oPC)));
SetTag( oSafe, sName );
SetObjectActive( oSafe, 1 );
SetLocation( oSafe, GetSafeLoc(SafeArea()));
}
return oSafe;
}
object OpenSafe (object oPC, string sName)
{
object oSafe = GetObjectByTag(sName, 0);
OpenInventory(oSafe, oPC, TRUE);
return oSafe;
}
object SetupSafeForSave (object oPC, string sName)
{
object oSafe = GetSafe(oPC,sName);
if (IsObjectValid(oSafe)) {
SetLocation( oSafe, GetSafeLoc(GetArea(oPC)));
DelayEvent( 0.01, oSafe, Event( EVENT_TYPE_PLACEABLE_ONCLICK ));
}
return oSafe;
}
object CaptureSafeFromSave (object oPC, string sName)
{
object oSafe = GetSafe(oPC,sName);
if (IsObjectValid(oSafe)) {
SetLocation( oSafe, GetSafeLoc(SafeArea()));
} else {
oSafe = SafeSetup(oPC, sName);
}
return oSafe;
}
SCRIPT HANDLER FOR PLACEABLE
void main()
{
event ev = GetCurrentEvent();
int bEventHandled = FALSE;
int nEventType = GetEventType(ev);
switch (nEventType)
{
case EVENT_TYPE_PLACEABLE_ONCLICK:
SetLocation( OBJECT_SELF, GetSafeLoc(SafeArea()));
bEventHandled = TRUE;
break;
}
if (!bEventHandled) HandleEvent(ev, RESOURCE_SCRIPT_PLACEABLE_CORE);
}
MODULE HANDLER
void main()
{
object oPC=GetHero();
event ev = GetCurrentEvent();
int iEv = GetEventType(ev);
switch ( iEv )
{
case EVENT_TYPE_MODULE_LOAD:
CaptureSafeFromSave (oPC, "TEST_CHEST_01");
CaptureSafeFromSave (oPC, "TEST_CHEST_02");
break;
case EVENT_TYPE_MODULE_PRESAVE:
SetupSafeForSave (oPC, "TEST_CHEST_01");
SetupSafeForSave (oPC, "TEST_CHEST_02");
break;
}
}
To access the chest use
object oTest = OpenSafe (GetHero(), "TEST_CHEST_1") ;
Just to get the object
object oTest = GetSafe (GetHero(), "TEST_CHEST_1") ;
Best regards for the Holidays
NN
Also it works without Local Variables (another flakey part of Toolkit).
THE GENERAL FUNCTIONS
const string PUPS_SAFE_AREA = "char_stage";
object SafeArea ()
{
return GetObjectByTag(PUPS_SAFE_AREA, 0);
}
location GetSafeLoc (object oArea)
{
return GetSafeLocation(Location(oArea, Vector(0.0, 0.0, 0.0), 0.0));
}
object GetSafe (object oPC, string sName)
{
return GetObjectByTag(sName, 0);
}
object SafeSetup(object oPC, string sName)
{
object oSafe = GetSafe (oPC, sName);
if (!IsObjectValid(oSafe)) {
object oSafe = CreateObject(OBJECT_TYPE_PLACEABLE, R"pups_safe_pla_store.utp",GetSafeLoc(GetArea(oPC)));
SetTag( oSafe, sName );
SetObjectActive( oSafe, 1 );
SetLocation( oSafe, GetSafeLoc(SafeArea()));
}
return oSafe;
}
object OpenSafe (object oPC, string sName)
{
object oSafe = GetObjectByTag(sName, 0);
OpenInventory(oSafe, oPC, TRUE);
return oSafe;
}
object SetupSafeForSave (object oPC, string sName)
{
object oSafe = GetSafe(oPC,sName);
if (IsObjectValid(oSafe)) {
SetLocation( oSafe, GetSafeLoc(GetArea(oPC)));
DelayEvent( 0.01, oSafe, Event( EVENT_TYPE_PLACEABLE_ONCLICK ));
}
return oSafe;
}
object CaptureSafeFromSave (object oPC, string sName)
{
object oSafe = GetSafe(oPC,sName);
if (IsObjectValid(oSafe)) {
SetLocation( oSafe, GetSafeLoc(SafeArea()));
} else {
oSafe = SafeSetup(oPC, sName);
}
return oSafe;
}
SCRIPT HANDLER FOR PLACEABLE
void main()
{
event ev = GetCurrentEvent();
int bEventHandled = FALSE;
int nEventType = GetEventType(ev);
switch (nEventType)
{
case EVENT_TYPE_PLACEABLE_ONCLICK:
SetLocation( OBJECT_SELF, GetSafeLoc(SafeArea()));
bEventHandled = TRUE;
break;
}
if (!bEventHandled) HandleEvent(ev, RESOURCE_SCRIPT_PLACEABLE_CORE);
}
MODULE HANDLER
void main()
{
object oPC=GetHero();
event ev = GetCurrentEvent();
int iEv = GetEventType(ev);
switch ( iEv )
{
case EVENT_TYPE_MODULE_LOAD:
CaptureSafeFromSave (oPC, "TEST_CHEST_01");
CaptureSafeFromSave (oPC, "TEST_CHEST_02");
break;
case EVENT_TYPE_MODULE_PRESAVE:
SetupSafeForSave (oPC, "TEST_CHEST_01");
SetupSafeForSave (oPC, "TEST_CHEST_02");
break;
}
}
To access the chest use
object oTest = OpenSafe (GetHero(), "TEST_CHEST_1") ;
Just to get the object
object oTest = GetSafe (GetHero(), "TEST_CHEST_1") ;
Best regards for the Holidays
NN





Retour en haut







