Page 1 of 1
Giwo: What's the new format of CreateBlankItem and CreateDFNItem?
Posted: Wed Jul 21, 2004 3:38 pm
by Xuri
Neither seems to work any longer....all I get is a message in console saying 7 arguments are required..
Posted: Wed Jul 21, 2004 4:13 pm
by giwo
CreateBlankItem( socket, character, amount, "itemName", isStackable, [isString], colour, objectType, inPack, bSend );
note [isString] is optional, so 9-10 args
CreateDFNItem( socket, character, "scriptSection", unused true/false, [amount], [objectType], [inPack], [autoStack(unused)] )
Takes 4-8 params, the last 4 are all optional (but must be in that order if used).
Posted: Wed Jul 21, 2004 4:41 pm
by Xuri
And what are the options for ObjectType? 0/1 is item/char? Vice versa?

Posted: Wed Jul 21, 2004 4:46 pm
by giwo
Well, I think what I'm going to do for the JS engine is map the object type enumerator to a string. IE objectType "item" = OT_ITEM, etc.
The numbers, as they are, are not at all in any order (since they are an enum in the source).
OT_CBO = 0
OT_CHAR = 1
OT_ITEM = 2
OT_MULTI = 3
OT_BOAT = 4
OT_SPAWNER = 5
Note that for your usage (in CreateBlank and CreateDFN Item) only OT_ITEM (IE 2) and OT_SPAWNER (IE 5) are valid.
Thus 2 for a normal item, or 5 for a spawner.
Posted: Wed Jul 21, 2004 5:05 pm
by Xuri
Hm
This crashes UOX3 for me:
Code: Select all
var itemMade = CreateDFNItem( pUser.socket, pUser, "0x0df8", false, 1, 2, true, false ); //give the player some wool
(Part of) the callstack:
UOX::cBaseObject::GetObjType() line 893 + 3 bytes
UOX::cWeight::subtractItemWeight(UOX::cBaseObject * 0xff00ff06, UOX::CItem * 0x06cc50d8) line 295 + 8 bytes
UOX::CItem::SetAmount(unsigned long 3) line 555
UOX::cItem::CreateScriptItem(UOX::cSocket * 0x06ccccd0, UOX::CChar * 0x06cc5730, std::basic_string<char,std::char_traits<char>,std::allocator<char> > {0x0096ddc1 "0x0df8"}, unsigned long 3, UOX::ObjectType OT_CHAR, unsigned char 0) line 276
UOX::SE_CreateDFNItem(JSContext * 0x01cf9640, JSObject * 0x01ceda58, unsigned int 8, long * 0x02b63614, long * 0x0012e428) line 741 + 57 bytes
JS32! 1001fd71()
01cdb9c8()
01cf9640()
01d17bf8()
01d33348()
01d50f58()
01d6e9b0()
01d8c590()
01daa0b8()
01dc55f8()
01de5968()
...
..
.
Posted: Wed Jul 21, 2004 5:23 pm
by giwo
I'm seeing some weirdness there....
for one thing, it looks like the amount is 3 instead of 1.
But most importantly, it looks like it's creating a character rather than an item, notice it says UOX::ObjectType OT_CHAR
I'm going to have to watch the JS engine and see if it's modifying values somewhere.
Posted: Fri Jul 23, 2004 4:42 am
by giwo
Heh, ewps
Was looking at old source for params for those two functions *smacks self*
This is the format...
CreateDFNItem( socket, character, "itemsection", [amount], [objectType], [spawnInPack(true/false)] );
Min 3 args, max 6 args
CreateBlankItem( socket, character, amount, "itemName", ID, color, objectType, spawnInPack(true/false) );
Must be 7 args
Posted: Fri Jul 23, 2004 4:46 am
by Xuri
Hum.. why was the "stackable" parameter removed? For blank items at the very least this may be important - since not all items are set to stackable by tiledata values..
Posted: Fri Jul 23, 2004 4:50 am
by giwo
It was passing along to the old createitem funcs in the source, which have been changed, and thus doing nothing, currently.
I can add it back on to the js function, I suppose
Posted: Fri Jul 23, 2004 5:01 am
by Xuri
Hm that would be nice

Posted: Mon Jul 26, 2004 4:04 pm
by giwo
In my latest, in place of the objectType of 2 or 5, you would now pass "ITEM" or "SPAWNER" (note you must pass a string), it will then match it to the object type and carry it along
Posted: Mon Jul 26, 2004 4:20 pm
by Xuri
So...
Code: Select all
var itemMade = CreateDFNItem( pUser.socket, pUser, "0x103b", 1, 2, true ); // makes a loaf of bread
becomes
Code: Select all
var itemMade = CreateDFNItem( pUser.socket, pUser, "0x103b", 1, "ITEM", true ); // makes a loaf of bread
?
And here I've already gone through all my scripts and fixed 'em up to use 2

heh..
Posted: Mon Jul 26, 2004 4:25 pm
by giwo
*nod*
apologies, but it should make life easier (at least readability) in the future.
Posted: Mon Jul 26, 2004 4:28 pm
by Xuri
No problem.
Posted: Mon Jul 26, 2004 5:12 pm
by Xuri
Apparently it's only the CreateDFNItem which works.
The following gives an error in console:
Code: Select all
var tempItem = CreateBlankItem( pSock, pUser, 1, "#", 0x04a9, 0x0, "ITEM", false );
The error:
| ERROR: CreateBlankItem: Invalid number of arguments (takes 7)
Posted: Mon Jul 26, 2004 5:16 pm
by giwo
ewps.
Just toss out that last false, as it will default to fasle (hopefully ;0 )
It accepts one more var than the error-catching will allow, I will fix that tonight (as it should allow 8 vars, not 7 ).
Posted: Mon Jul 26, 2004 5:19 pm
by Xuri
Ah. Okay

Changed the if( argc != 7 ) to 8 and works like a charm
