It seems that you're using an outdated browser. Some things may not work as they should (or don't work at all).
We suggest you upgrade newer and better browser like: Chrome, Firefox, Internet Explorer or Opera

×
I wrote a script that allows you to activate a bundle of firewood and spawn a campfire if you have a piece of flint in your inventory. Without the flint you just get a message saying that you need flint to start a campfire. Well, the activate function in the firewood's properties is set to single use. So, even if you don't have flint you still lose your bundle of firewood. So, I added a line to add a bundle of firewood back to your inventory if you don't have flint. But now when I activate the firewood in the game without flint it fills my entire inventory up with bundles of firewood. Here's the script. Can someone please tell me what I did wrong. Thanks!!

#include "x2_inc_switches"
void main()
{
object oSpawn;

// Get the creature who triggered this event.
object oPC = GetItemActivator();

// Abort if the PC does not have the item Flint.
if ( GetItemPossessedBy(oPC, "jw_flint") == OBJECT_INVALID )
{
CreateItemOnObject("jw_firewood", oPC, 1);
SendMessageToPC(oPC, "You need a piece of flint to start the fire.");

return;
}

// Spawn Campfire.
oSpawn = CreateObject(OBJECT_TYPE_PLACEABLE, "jw_campfire", GetLocation(oPC));
}
No posts in this topic were marked as the solution yet. If you can help, add your reply
It seems to me that you need to set an integer to tell the script that the item has been placed. As it is, the script has no way of knowing, so every time it runs it places another bundle.

Off the top of my head, and untested:

#include "x2_inc_switches"
void main()
{
object oSpawn;
int iBundle = 0;

// Get the creature who triggered this event.
object oPC = GetItemActivator();

// Abort if the PC does not have the item Flint.
if ( iBundle != 1 )
{
if ( GetItemPossessedBy(oPC, "jw_flint") == OBJECT_INVALID )
{
CreateItemOnObject("jw_firewood", oPC, 1);
SendMessageToPC(oPC, "You need a piece of flint to start the fire.");
iBundle = 1;
return;
}
}

// Spawn Campfire.

oSpawn = CreateObject(OBJECT_TYPE_PLACEABLE, "jw_campfire", GetLocation(oPC));
iBundle = 0;
}
Post edited September 02, 2014 by Hickory
Just reading that I thought you had it figured out, but unfortunately I got the exact same result. This is weird cause I've done very similar scripts before and have never had this to happen. Thank You for trying!!! If you have any other suggestions I would appreciate the help.
avatar
jerrus147: Just reading that I thought you had it figured out, but unfortunately I got the exact same result. This is weird cause I've done very similar scripts before and have never had this to happen. Thank You for trying!!! If you have any other suggestions I would appreciate the help.
Ok, again off the top of my head and not tested, maybe it's as simple as an 'else' clause? Like so:

#include "x2_inc_switches"

void main()
{

object oSpawn;

// Get the creature who triggered this event.
object oPC = GetItemActivator();

// PC has flint...
if ( GetItemPossessedBy(oPC, "jw_flint") != OBJECT_INVALID )

{
// ...spawn Campfire.
oSpawn = CreateObject(OBJECT_TYPE_PLACEABLE, "jw_campfire", GetLocation(oPC));
}
else
{
// ... else inform PC
CreateItemOnObject("jw_firewood", oPC, 1);
SendMessageToPC(oPC, "You need a piece of flint to start the fire.");
}

}
You'll get far more help if you post on the actual forums here.
Nope, exact same result. I've gone over and over it and I don't get it.
avatar
jerrus147: Nope, exact same result. I've gone over and over it and I don't get it.
Both of you are missing a fundamental property of how this kind of script works. Please take my suggestion and post on the actual NWN forum, that's where you'll find the good scripters who are willing to help on a lot of things. None of them usually come here -- the fact I happened to swing by and notice this thread was unusual.

Yes, I'm being a bit of a jerk by not simply telling you the answer here, but I'm trying to encourage you to go over there and get used to posting over there. This forum is dead compared to the official one and you'll be far better off spending your time over there. It'll lead to a lot less frustration on your part.
avatar
jerrus147: Nope, exact same result. I've gone over and over it and I don't get it.
avatar
MagicalMaster: Both of you are missing a fundamental property of how this kind of script works. Please take my suggestion and post on the actual NWN forum, that's where you'll find the good scripters who are willing to help on a lot of things. None of them usually come here -- the fact I happened to swing by and notice this thread was unusual.

Yes, I'm being a bit of a jerk by not simply telling you the answer here, but I'm trying to encourage you to go over there and get used to posting over there. This forum is dead compared to the official one and you'll be far better off spending your time over there. It'll lead to a lot less frustration on your part.
Yeah, I find the fact the you claim to know the answer and yet deliberately withhold it is very much the mark of a jerk. People have their preferred forums, and most people here are eager to learn from one another, so If you don't have anything helpful to say, why bother saying anything at all? And your previous reason given doesn't cut it with me.
Besides I tried registering an account there and it wouldn't let me for some reason. That's why I came here.
avatar
MagicalMaster: Both of you are missing a fundamental property of how this kind of script works. Please take my suggestion and post on the actual NWN forum, that's where you'll find the good scripters who are willing to help on a lot of things. None of them usually come here -- the fact I happened to swing by and notice this thread was unusual.

Yes, I'm being a bit of a jerk by not simply telling you the answer here, but I'm trying to encourage you to go over there and get used to posting over there. This forum is dead compared to the official one and you'll be far better off spending your time over there. It'll lead to a lot less frustration on your part.
avatar
Hickory: Yeah, I find the fact the you claim to know the answer and yet deliberately withhold it is very much the mark of a jerk. People have their preferred forums, and most people here are eager to learn from one another, so If you don't have anything helpful to say, why bother saying anything at all? And your previous reason given doesn't cut it with me.
Don't be an ass. MM has spent COUNTLESS hours helping noobs like me. He's not a jerk. He's trying to direct the OP to someplace where he can get some actual help.

I may very well be the best scripter here and I am at best a cut-n-paste script moocher. I have actually created a script just like this and it worked brilliantly (the campfire would even go out and decay on a timer), but I have no idea what I did with it and I don't have time to scrounge around for it. Nor can I help you fix yours. I fix scripts by trial and error, guys like MM can look at a script and know what's wrong with it. I don't even have time to get MY scripts working. I certainly don't have time to pour over yours'. You need guys like MM and they don't hang around here.

Go to the official forums and post there. That's where I go when I need help and I've never been disappointed. You can log in using an EA Origins account.
Post edited September 03, 2014 by urknighterrant
Thanks urknighterrant, I finally got registered with that forum.

I have done a script just like this before too, but it was a really long time ago and I can't remember how I did it. The weird thing about this one is that I even tried to use the Lilac Soul's Script Generator and the script it gave me was pretty much the same thing I have here, and it had the exact same problem.
avatar
Hickory: Yeah, I find the fact the you claim to know the answer and yet deliberately withhold it is very much the mark of a jerk. People have their preferred forums, and most people here are eager to learn from one another, so If you don't have anything helpful to say, why bother saying anything at all? And your previous reason given doesn't cut it with me.
avatar
urknighterrant: Don't be an ass. MM has spent COUNTLESS hours helping noobs like me. He's not a jerk. He's trying to direct the OP to someplace where he can get some actual help.
The person who knows the answer and purposefully withholds it is the ass. And he called himself a jerk. Jerk.
YVW Jerrus. I think you'll find the community there VERY helpful and welcoming.

Hickory, grow up.
avatar
urknighterrant: Hickory, grow up.
Did it hurt?
avatar
Hickory: People have their preferred forums, and most people here are eager to learn from one another, so If you don't have anything helpful to say, why bother saying anything at all?
I am being helpful -- but more in the manner of "Give a man a fish vs teach a man to fish." Let's say I give him the answer to this script right now. Perfect. Great. Then few days later he needs help with a different one -- I might not even visit this forum for a week after his post. So he gets stuck and gets no help. That's not a good situation.

OR he can post on that other forum that at least a dozen people who understand scripting read every single day.

Which do you think is better for him long term?

avatar
urknighterrant: You need guys like MM and they don't hang around here.
I doubt they even know this place exists -- I didn't until a few months ago. I've tried to make it a point to visit this forum to help people who don't know about the main forum but the actual scripters (and I'm certainly not even close to being the best among them) basically never visit here.

avatar
jerrus147: Thanks urknighterrant, I finally got registered with that forum.
Glad to hear it, and I'll echo what urknighterrant said about the community being very helpful and welcoming.
Post edited September 03, 2014 by MagicalMaster