AddItem function

Post » Sat May 28, 2011 2:59 am

I haven't been able to find a topic on this problem though I suspect it's common and well known for veteran modders. I could not get the AddItem function to work with a variable. Is that even possible somehow?

My code looks something like

Player->AddItem itemname variable

or

Player->AddItem "itemname" variable

where the variable is higher then 0 of course

I have tried it with local short, float and long variables and global short variables and it never worked. The error I get is that the script doesn't acknowledge the variable and considers the value to be zero. The weird part is it does work if I type it in the console and use a global variable. Does anybody know any work-arounds, perhaps by using Morrowond Script Extender? Any help would be appreciated, thanks.
User avatar
Jonathan Montero
 
Posts: 3487
Joined: Tue Aug 14, 2007 3:22 am

Post » Sat May 28, 2011 5:05 am

Additem will only accept a variable if it's in a dialog result, not a script unfortunately.http://www.uesp.net/morrow/editor/mw_cscommands.shtml#additem But, MWSE's xAddItem will accept a variable. The amount will be of type short.
User avatar
Sheeva
 
Posts: 3353
Joined: Sat Nov 11, 2006 2:46 am

Post » Sat May 28, 2011 1:49 am

You can sort of simulate variable additem in precompiled scripts using while/if, for instance

long countset count to 1756while ( count >= 100 )    additem "gold_001" 100    set count to ( count - 100 )endwhilewhile ( count >= 10 )    additem "gold_001" 10    set count to ( count - 10 )endwhileif ( count > 0 )    additem "gold_001" 1    set count to ( count - 1 )endif
[EDIT}replaced last endwhile with endif
User avatar
loste juliana
 
Posts: 3417
Joined: Sun Mar 18, 2007 7:37 pm

Post » Fri May 27, 2011 10:55 pm

Thank you both for your help. This will help me work around the problem. That count code is a very smart idea if you want to avoid making the mode dependable on the script extender. Also thank god the people who created the script extender thought of making the function work with variables, I sure don't understand why Bethesda didn't see the need for such flexibility in their editor. Also I might be able to just do it all in dialogue result with a helping script. Thanks again.
User avatar
DAVId Bryant
 
Posts: 3366
Joined: Wed Nov 14, 2007 11:41 pm

Post » Sat May 28, 2011 10:26 am

Also thank god the people who created the script extender thought of making the function work with variables, I sure don't understand why Bethesda didn't see the need for such flexibility in their editor.


Bethesda 'didn't see the need' because they didn't have a need.

Something the Bethesda devs poiinted out a long time ago, when MW was still new: the Construction Set and the script language were not designed primarily for the players as a general purpose set of tools for us to build anything we wanted.

Instead, the Construction Set and the script language were designed as tools for the Bethesda devs to build the game world they wanted, and then they released the tools with the game as a bonus for the players.

So the editor and the script language have just the features and capabilities the devs needed to build Morrowind; the 'missing' features that people gripe about periodically are things the devs didn't need to build the game.

So if 'AddItem' and 'RemoveItem' don't accept variables in scripts, it's because the devs didn't need that capability to build the game world.

As Abot pointed out, you can use stacked 'While' blocks to add or remove variable numbers of items. If you pick the number of 'While' blocks and the sizes of the increments carefully, you can handle fairly large numbers of items without bogging the game down significantly.

...just passing through...
User avatar
Emmie Cate
 
Posts: 3372
Joined: Sun Mar 11, 2007 12:01 am

Post » Sat May 28, 2011 8:45 am

*snip*

Instead, the Construction Set and the script language were designed as tools for the Bethesda devs to build the game world they wanted, and then they released the tools with the game as a bonus for the players.

So the editor and the script language have just the features and capabilities the devs needed to build Morrowind; the 'missing' features that people gripe about periodically are things the devs didn't need to build the game.
*snip*

either that or scenario writers (or whatever official title world builders have) had to make due with what the coders had time/funding (same thing really) to give them.

especially considering what was "wanted" compared to what we got, going by half implemented and cut features and content present in the vanilla game.

makes me wonder, has anyone attempted a MWSE rewrite of the original content?

i dont mean to sound like i'm complaining, i do understand deadlines and the generalities of running a for-profit business.... i just have a sneaking suspicion that at least one of the gamesas wold builders had similar complaints. i'd be quite surprised if this wasent the case.
User avatar
Mariana
 
Posts: 3426
Joined: Mon Jun 12, 2006 9:39 pm


Return to III - Morrowind