Aller au contenu

Photo

char_stage - Does it exist? or is it totally random


  • Veuillez vous connecter pour répondre
9 réponses à ce sujet

#1
nn125

nn125
  • Members
  • 42 messages
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

#2
sillyrobot

sillyrobot
  • Members
  • 171 messages
It looks fine.



It is reporting "Problems", I take it? Where is the hero and what event is the above code in?




#3
nn125

nn125
  • Members
  • 42 messages
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,

#4
sillyrobot

sillyrobot
  • Members
  • 171 messages
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.




#5
sillyrobot

sillyrobot
  • Members
  • 171 messages
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
nn125

nn125
  • Members
  • 42 messages
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
DLAN_Immortality

DLAN_Immortality
  • Members
  • 481 messages
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
nn125

nn125
  • Members
  • 42 messages
How do I export char_stage - Isn't it part of the game



NN


#9
nn125

nn125
  • Members
  • 42 messages
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

#10
nn125

nn125
  • Members
  • 42 messages
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