Aller au contenu

Photo

[SOLVED] Using SetPlaceableState?


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

#1
Cyansomnia

Cyansomnia
  • Members
  • 2 026 messages
I've adapted a script that allows me to spawn a chest in an OC area.  It's working great, except for some reason the initial state (closed_locked) doesn't carry over.  I want it to be locked, but everytime it spawns it is unlocked.

Will SetPlaceableState work to lock it?  Where would it fit into this script?  Thanks for your time.


#include "utility_h"
#include "plt_arlathan_bldmster_plot"
#include "placeable_h"
#include "wrappers_h"

void main()
{

object oPlayer = GetMainControlled();
DisplayFloatyMessage(oPlayer, "spawn_chest", FLOATY_MESSAGE, 16777215, 20.0);
object oChest = UT_GetNearestObjectByTag(oPlayer, "ancient_elven_chest");

if (!IsObjectValid(oChest) && ( WR_GetPlotFlag( PLT_ARLATHAN_BLDMSTER_PLOT,   JOURNAL_QUEST_ACCEPTED ) == TRUE ) )
{
object oArea = GetObjectByTag("ntb330ar_lair_of_the_undead");

location lChestLocation = Location(oArea, Vector(-26.1509, 294.53, -5.01709), 179.018395);

CreateObject(OBJECT_TYPE_PLACEABLE, R"ancient_elven_chest.utp", lChestLocation);
}
}

Modifié par Aislinn Trista, 30 avril 2010 - 12:54 .


#2
Craig Graff

Craig Graff
  • Members
  • 608 messages
Why are you creating the chest only if the chest already exists?



At a guess the reason that the locked state isn't carrying over is that the chest is there already and already unlocked.

#3
TimelordDC

TimelordDC
  • Members
  • 923 messages

Craig Graff wrote...

Why are you creating the chest only if the chest already exists?

At a guess the reason that the locked state isn't carrying over is that the chest is there already and already unlocked.


Doesn't (!IsObjectValid) return TRUE if the object doesn't exists?

You would use SetPlaceableState like this after creating the object: SetPlaceableState (oChest, 1) assuming you are using a placeable that has the StateController set to StateCnt_Container
Check the placeables.xls for more details.

#4
Craig Graff

Craig Graff
  • Members
  • 608 messages
Heh. I read it as (IsObjectValid instead of (!IsObjectValid.



This is why I'm seeing an optometrist today.

#5
Magic

Magic
  • Members
  • 187 messages
Yup, your code runs fine. The chest spawns unlocked regardless of the template. Timelord's suggestion works. Just don't forget to assign the new chest.



oChest = CreateObject(OBJECT_TYPE_PLACEABLE, R"ancient_elven_chest.utp", lChestLocation);

SetPlaceableState (oChest, 1);

#6
RecklezzRogue

RecklezzRogue
  • Members
  • 193 messages

Craig Graff wrote...

Heh. I read it as (IsObjectValid instead of (!IsObjectValid.

This is why I'm seeing an optometrist today.



lol

#7
Cyansomnia

Cyansomnia
  • Members
  • 2 026 messages

TimelordDC wrote...

Craig Graff wrote...

Why are you creating the chest only if the chest already exists?

At a guess the reason that the locked state isn't carrying over is that the chest is there already and already unlocked.


Doesn't (!IsObjectValid) return TRUE if the object doesn't exists?

You would use SetPlaceableState like this after creating the object: SetPlaceableState (oChest, 1) assuming you are using a placeable that has the StateController set to StateCnt_Container
Check the placeables.xls for more details.



Yeah, (!IsObjectValid) is to check and see if the item is already there.  It does return TRUE if the item doesn't exist.

All right, I did what TimeLord suggested, but I'm still finding my chest unlocked.  I checked the StateController and I'm using an appropriate placeable.  I even made sure my export was clean..  not really sure why this isn't working.

#8
Cyansomnia

Cyansomnia
  • Members
  • 2 026 messages

Magic wrote...

Yup, your code runs fine. The chest spawns unlocked regardless of the template. Timelord's suggestion works. Just don't forget to assign the new chest.

oChest = CreateObject(OBJECT_TYPE_PLACEABLE, R"ancient_elven_chest.utp", lChestLocation);
SetPlaceableState (oChest, 1);


AH!  That's what I probably messed up.  I'll test it out as soon as I get home from work.

Thanks so much for your help, guys.

Modifié par Aislinn Trista, 29 avril 2010 - 06:06 .


#9
Cyansomnia

Cyansomnia
  • Members
  • 2 026 messages

Craig Graff wrote...

Heh. I read it as (IsObjectValid instead of (!IsObjectValid.

This is why I'm seeing an optometrist today.


No problem Craig, I still think you rule.  :)


EDIT:

Fixed the script in line with the suggestions you guys made.  Works like a charm!  Much thanks.  :happy:

Modifié par Aislinn Trista, 30 avril 2010 - 12:54 .