Page 1 of 1

trade:getItem()

Posted: Thu Feb 23, 2017 5:45 am
by Avatarati
I started working on my server again, and noticed that trade:getItem() is not returning a simple ID integer anymore, but rather some type of user data. What changed? I was using trade:getItem() to find out what item ID the user was trading to an NPC. This was highly useful in several files of mine :(

How do I determine which item ID the user has traded now? hasItemQty is only useful when you know what will be traded, I need something for the unknown item that is traded.

Re: trade:getItem()

Posted: Thu Feb 23, 2017 6:20 am
by Avatarati
I see what happened now...

A commit on August 11, 2016 "changed getItem to return item object"

Guess I have to change every instance of getItem to getItemID...

My weekend schedule just filled up...

Re: trade:getItem()

Posted: Thu Feb 23, 2017 12:10 pm
by TeoTwawki
My weekend schedule just filled up...
Do you really have that many custom trades or are you just not pulling changes form DSP master? Please tell me I haven't run into yet another user that thinks they have to manually edit their fork to get updates in doing drag n drop updates. The horrors I have seen where somebody updates source without updating scripts, and other nightmare fuel. :shock: :? :o

Re: trade:getItem()

Posted: Thu Feb 23, 2017 2:31 pm
by demolish
Avatarati wrote:I see what happened now...

A commit on August 11, 2016 "changed getItem to return item object"

Guess I have to change every instance of getItem to getItemID...

My weekend schedule just filled up...
or.. you could just open notepad++ and directory replace getItem( with getItemID(
(case sensitive)

though you'll probably wanna search for getItem( first and keep open any stock dsp scripts so you can change them back after directory replace

Re: trade:getItem()

Posted: Thu Feb 23, 2017 11:40 pm
by Avatarati
Do you really have that many custom trades or are you just not pulling changes form DSP master? Please tell me I haven't run into yet another user that thinks they have to manually edit their fork to get updates in doing drag n drop updates. The horrors I have seen where somebody updates source without updating scripts, and other nightmare fuel. :shock: :? :o
I usually download a new repository then I have a folder with all affected files. I'll copy and paste everywhere that has a //CUSTOM CODE comment. Sometimes things will change, so I'll need to tweak it a little.
Please tell me I haven't run into yet another user that thinks they have to manually edit their fork to get updates in doing drag n drop updates.
Explain? I'd love to know a simpler way.

Re: trade:getItem()

Posted: Thu Feb 23, 2017 11:41 pm
by Avatarati
or.. you could just open notepad++ and directory replace getItem( with getItemID(
(case sensitive)

though you'll probably wanna search for getItem( first and keep open any stock dsp scripts so you can change them back after directory replace
My original number was a little exaggerated. It's already fixed. Ended up not being many places it was used - was using hasItemQty most of the time.

Re: trade:getItem()

Posted: Fri Feb 24, 2017 5:09 am
by Delaide
You can store your custom adjustments by just doing git -> stash save, pull, then pop your stash.

Re: trade:getItem()

Posted: Fri Feb 24, 2017 6:12 am
by Avatarati
Thanks.

I can't help but wonder what happens when you have a code conflict though.

Re: trade:getItem()

Posted: Fri Feb 24, 2017 4:26 pm
by TeoTwawki
You "edit conflicts" in git. (if you are a tortoisegit user, do NOT choose "resolve" - doesn't do what ppl assume it does)

I edit my conflicts using tortoise's packed in diff viewer. It has a nice UI highlights all the code that needs my attention.

Pulling darkstar:master onto yourFork:yourBranch should be all you need to do to update 99% of the time, if you regularly see mountains of conflicts you should rethink what you have been doing/how you have been doing it. Examples of good practices include using block comments on npc script you are disabling and then putting your replacement code after the disabled section, and using separate files for custom SQL inserts deletions alter table and replace statements.

Re: trade:getItem()

Posted: Fri Feb 24, 2017 7:31 pm
by whasf
[moved to scripting forum]