Help planning and building lightweight forge

My scripting knowledge is not the greatest but I’ve been catching on as I do more.
I’d like some help and information on creating a forge that is completely operated on 1 script and uses as few resources as possible.

End result would be a forge that can create items that are not pre generated on the character.
Ability to adjust cost, as well as a method of controlling the power of the item created.

Any help is appreciated. I have no basics to show atm as I’m not even sure where to begin but I’m plugging away at it anyways.

Can anyone lend a hand with the GetFirstItemInInventory().

I’m looking for a method to have the forge look in it’s own inventory and identify if it does or does not have an item in it.
Do I need to loop this for it to check more then once?

Once it locates an item I need it stored as a useable int.

Any help is appreciated. I tried using
if ((GetFirstItemInInventory(oForge)) == OBJECT_INVALID)

but I may have it set up all wrong.

Try GetIsObjectValid(GetFirstItemInInventory(oForge)) instead. GetIsObjectValid is more reliable than comparing against OBJECT_INVALID

1 Like

See X2_inc_itemprop for all the functions you need in creating a forge. The pages for the individual functions have good examples on how to use them.

IPSafeAddItemProperty is the key function.


I managed to get it to compile with

If (GetFirstItemInInventory(OBJECT_SELF) != OBJECT_INVALID)

but I’ll try you’re method and see what happens.

Is there a way to have this happen on the fly?

As it stands in order for it to function correctly the player now needs to open the forge and it will state empty.
They put an item in but the state remains empty until they close it then reopen it. The it states full.

Thank you also for the itemprop info. I’ll get looking through that as well.

Appreciate the help

It depends on which event you use for what. If you’re using the OnOpen event, then the “Is there something in my inventory?”-check only happens when the forge placeable is being opened.

If you want the event to trigger whenever items get added/removed, use the OnDisturbed event instead.

void main()
    object oItem   = GetInventoryDisturbItem();
    int nEvent     = GetInventoryDisturbType();

    // An item has been added.

    // An item has been removed.
1 Like

Awesome! Thanks @TheBarbarian

I’ll give it a go tonight!

Really appreciate all the help guys.
Been learning a lot.

1 Like

So now when I convert object to string the result of GetInventoryDisturbItem it returns a number as opposed to the name of the actual item.

Is there something I should add to get the name?

As of right now if I put a shortsword in the forge the forge speaks “3”

Ok so originally converting object oForging
Which is the result of GetInventoryDisturbItem it game me an integer result? 3

I used
String sForging = GetName(oForging) and it now returns short sword.

What’s the difference between these two methods?

GetName returns the object’s name which is really what you want. ObjectToString gives you a hexadecimal string, which is probably based on the underlying pointer.

1 Like

Ah ok. Curious how that works.

I’m searching google and failing.
I’m trying to incorporate string sForging into speach.

ActionSpeakString(“You placed your (sForging) in the forge.”)

I’ve tried adding + and multiple " " in there but it either wont compile or speaks sForge as sForge.

Is there a particular way I have to put it in there for it to return shortsword in place of sForging?

I’ll keep trying.
As always thanks for the help.


ActionSpeakString("You placed your " + GetName(oForging) + " in the forge.");

1 Like

Worked like a charm.
Thanks again psythe!
Still have some learning to do.
Strange it doesnt allow you to somehow add a string in there? Like say if you had a custom predetermined one

You can for some things with Custom Tokens in conversations and journals.

Out of curiosity, is it possible to completely handle forging an item via script without creating a conversation or other resource?

I’d love to do this entirely in one script.

void main()
//Define Variables

//The Forge
object oForge = OBJECT_SELF;

// The Player using the Forge
object oPC = GetLastUsedBy();

//The item we are forging
object oForgeItem = GetInventoryDisturbItem();

//The Players Gold
int nGold = GetGold(oPC);

// Is the Forge empty or full
int nForgeStatus = GetInventoryDisturbType();

// Is the Forge Listening 1= Yes 0= No
int nForgeListening = 0
if (nForgeListening = 1)
ActionSpeakString("You placed your “+ GetName(oForgeItem) + " in the forge.”);
nForgeStatus = 1;
ActionSpeakString("You removed your “+ GetName(oForgeItem) + " from the forge.”);
nForgeStatus = 0;
nForgeListening = 0;
if (nForgeStatus == 1)
nForgeListening = 1;
ActionSpeakString("Do you wish to forge your "+ GetName(oForgeItem) + “.?”);

This is where I am so far.
If i want the forge to listen for yes or no and then do something, what’s the best way to go about it?

You can do it all in one script if the properties you’re modifying are fixed. But as soon as you’re giving options to the player you had to use multiple scripts. The best way to get input from the user is via a conversation. Dialogs can be just like menus.

But if I’m not mistaken a conversation is another resource right?


So there’s no way to do it via chat? Like user types in chat?

If you’re building a module, you’re always creating resources. :slight_smile:

It can be done through chat but conversation or dialog is much easier to use. Take a look at SIM Tools if you really want to muck around with chat.

Just in case, because it seems to me that ppls coming here ignore existing content from some reason, maybe in fear of nwn:ee compatibility?

Have you checked and considered various already existing finished forge systems that are available on vault?

genisys forge
omega forge
or even the vanilla HotU forge? iirc it is a conversation x2_smith, you just need to assign it to the npc

1 Like

Thank you both again for the replies.
I’ll have a peek at the existing forges and see if I can just modify it?

The module I’m building this for is short on resources, and wants to remain hak free.
So keeping this as only one script that can be applied to an existing object is what im shooting for.

If a conversation forge needs to call on multiple scripts it wont work as well for us.