trade:getItem()

Post Reply
Avatarati
Posts: 53
Joined: Mon Jun 30, 2014 2:51 pm

trade:getItem()

Post by Avatarati » Thu Feb 23, 2017 5:45 am

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.
Last edited by Avatarati on Thu Feb 23, 2017 11:41 am, edited 1 time in total.

Avatarati
Posts: 53
Joined: Mon Jun 30, 2014 2:51 pm

Re: trade:getItem()

Post by Avatarati » Thu Feb 23, 2017 6:20 am

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...

User avatar
TeoTwawki
Developer
Posts: 527
Joined: Mon Jul 15, 2013 9:50 pm

Re: trade:getItem()

Post by TeoTwawki » Thu Feb 23, 2017 12:10 pm

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
Hi, I run The Demiurge server.


Image
Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live. - Martin Golding
PLS USE [ code ] CODE TAGS [ /code ] WHEN POSTING CODE
DO NOT PRIVATE MESSAGE ME ABOUT BUGS

User avatar
demolish
Developer
Posts: 262
Joined: Thu Jul 26, 2012 7:12 am

Re: trade:getItem()

Post by demolish » Thu Feb 23, 2017 2:31 pm

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
<Giblet[NewBrain]> kj with this first step would be fine on my shit
Click here for a guide on scripting missions.

Avatarati
Posts: 53
Joined: Mon Jun 30, 2014 2:51 pm

Re: trade:getItem()

Post by Avatarati » Thu Feb 23, 2017 11:40 pm

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.

Avatarati
Posts: 53
Joined: Mon Jun 30, 2014 2:51 pm

Re: trade:getItem()

Post by Avatarati » Thu Feb 23, 2017 11:41 pm

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.

Delaide
Posts: 478
Joined: Sat Jun 14, 2014 8:58 am

Re: trade:getItem()

Post by Delaide » Fri Feb 24, 2017 5:09 am

You can store your custom adjustments by just doing git -> stash save, pull, then pop your stash.

Avatarati
Posts: 53
Joined: Mon Jun 30, 2014 2:51 pm

Re: trade:getItem()

Post by Avatarati » Fri Feb 24, 2017 6:12 am

Thanks.

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

User avatar
TeoTwawki
Developer
Posts: 527
Joined: Mon Jul 15, 2013 9:50 pm

Re: trade:getItem()

Post by TeoTwawki » Fri Feb 24, 2017 4:26 pm

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.
Hi, I run The Demiurge server.


Image
Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live. - Martin Golding
PLS USE [ code ] CODE TAGS [ /code ] WHEN POSTING CODE
DO NOT PRIVATE MESSAGE ME ABOUT BUGS

User avatar
whasf
Site Admin
Posts: 1312
Joined: Thu Jul 19, 2012 9:11 pm

Re: trade:getItem()

Post by whasf » Fri Feb 24, 2017 7:31 pm

[moved to scripting forum]
-- Whasf

Post Reply