Jump to content

Home

Scripting woe


TriggerGod

Recommended Posts

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( "[color="DeepSkyBlue"]item_tag[/color]", GetObjectByTag("g_tresmillow007"));
}

 

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

Link to comment
Share on other sites

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"));
}

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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...

Link to comment
Share on other sites

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("[color="DarkOrange"]container_tag[/color]", 0);
CreateItemOnObject("[color="DarkOrange"]item_tag[/color]", 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...

Link to comment
Share on other sites

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. :)

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...