PDA

View Full Version : Scripting woe


TriggerGod
08-22-2009, 05:08 PM
Just a minor scripting issue that I am having. And by minor, I mean something that any good (or average :p) scripter could probably figure out.

I am trying to spawn a custom item into the Exile's footlocker on the Harbinger. I made a script and had VP revise it quickly for me. Here is my current script:

void main (){
CreateItemOnObject( "item_tag", GetObjectByTag("g_tresmillow007"));
}

item tag is my... item's tag. (of course... >.>)

Star Admiral
08-22-2009, 05:12 PM
If I'm not mistaken, the tag for the PC's footlocker is "MilLowFootLker".

- Star Admiral

TriggerGod
08-22-2009, 05:25 PM
If I'm not mistaken, the tag for the PC's footlocker is "MilLowFootLker".

- Star Admiral

I was under the impression that it was the resref I would put in the script.


But it didn't matter. For some reason, the script didn't fire correctly even with MilLowFootLker as the placeable tag.

I could try to use the tag in my old script, before VP revised it.

EDIT: Still nothing. :(

Old script:
void main ()
{
object oItem=CreateItemOnObject( "item_tag", GetObjectByTag("MilLowFootLker"));
}

Nirran
08-22-2009, 05:39 PM
CreateItemOnObject("item_tag", GetObjectByTag("MilLowFootLker"),1);



the 1 is saying create 1 of those items,what is triggering the script?that maybe why

Nirran

TriggerGod
08-22-2009, 06:11 PM
CreateItemOnObject("item_tag", GetObjectByTag("MilLowFootLker"),1);



the 1 is saying create 1 of those items,

I didn't have to put a 1 in an older script that spawned my inheritor model in a custom footlocker, so I don't see why I would have to put one in this one. Besides, my problem is that it isn't spawning in the placeable at all.

what is triggering the script?
the first line that kreia says right after you notice your room. "Are you alright?" or something like that. Thats when I have my script go off.

zbyl2
08-22-2009, 06:26 PM
There are few placeable objects with the same tag in this module. It probably spawns an item, but in another footlocker.
Not sure if it would do anything, but you might try replacing GetObjectByTag() with GetNearestObjectByTag(), so it'll spawn item in the nearest footlocker instead of some random one.
If it won't work, it might be necessary to edit .utp file of "player's footlocker" to have unique tag.

DarthStoney
08-22-2009, 06:47 PM
I made some custom items, for personal use, to spawn in the Exile's locker. It was actually easier to use the TSL patcher and install the item(more or less) directly into that footlocker.

TriggerGod
08-22-2009, 06:48 PM
There are few placeable objects with the same tag in this module. It probably spawns an item, but in another footlocker.
Not sure if it would do anything, but you might try replacing GetObjectByTag() with GetNearestObjectByTag(), so it'll spawn item in the nearest footlocker instead of some random one.
If it won't work, it might be necessary to edit .utp file of "player's footlocker" to have unique tag.

It didn't work.

And I would like to keep mod compatibility issues down, so I can't just edit the placeable's name, because the game won't recognize the new placeable unless I edit the module itself.

Of course, if I had a script that would let me get rid of/destroy the current placeable, than replace it with a new one...

Star Admiral
08-22-2009, 07:27 PM
Try adding SendMessageToPC( GetFirstPC(), "I ran." ); to the script just to see if it fires at all. If it did, the message should appear in the player's journal.

- Star Admiral

VarsityPuppet
08-22-2009, 07:34 PM
It didn't work.

And I would like to keep mod compatibility issues down, so I can't just edit the placeable's name, because the game won't recognize the new placeable unless I edit the module itself.

Of course, if I had a script that would let me get rid of/destroy the current placeable, than replace it with a new one...

No need. I got your script. However, zbyl is partially right: the PC locker has the same tag as another empty footlocker. You might want to give the PC locker a unique tag first though...

Anyways, since the script for some reason was just not firing, I decided to simply add it to the a_openpcdoor script, since obviously that one was working.

void main() {

object oPCDoor = GetObjectByTag("PCDoor", 0);
AssignCommand(GetFirstPC(), ActionOpenDoor(oPCDoor));

object oPCbox = GetObjectByTag("container_tag", 0);
CreateItemOnObject("item_tag", oPCbox, 1, 0);

}

save it as "a_openpcdoor" and compile it. It worked for me.

If you want to get more complex and use dialog embedded script parameters and whatnot then that'll be a bit more compatible...

TriggerGod
08-22-2009, 07:37 PM
Try adding SendMessageToPC( GetFirstPC(), "I ran." ); to the script just to see if it fires at all. If it did, the message should appear in the player's journal.

- Star Admiral

Curious. I put that into my script, and it ran perfectly. I had a thought about scripting, so I opened up the footlocker. It was there. I decided to test my thoughts out, and I removed the SendMessageToPC line from the script, and compiled. Apparently, if you have a singular function on its own in a script, it won't run. But if its longer than the one function, such as with the SendMessage line, it run perfectly.

Anyways, thanks for the help, everyone. :)

R2-X2
08-23-2009, 04:00 PM
You could use a space for the message sent to the Pc, so you'll get your item, but there's no message.