can someone tell me what is wrong with this shop item script?
it's a modified version of Joe 123's script
the 2 problems are that link can pick up multiple items and and he uses his weapons when he sets down an item
here is the script
Spoiler
// Shop script, originally by Joe 123 // These two scripts make a shop very similar to the ones in the Oracles games. // I've included them both in the same submission because they use a lot of the same functions, and are very similar in what they do. // They were inspired by a script by Matthew, but re-written completely. int holding_item; int holded_item; // This script makes a single shop item at the position of the ffc, which Link can buy by pressing a button. // * Item's graphic must be set as the ffc's graphic, and due to my failing at drawing counters to the screen you'll have to add your own price somehow. // * D0 is the combo it is set to wehn link picks it up // * D1 is the item ID to sell // * D2 is the price to sell it for // * D3 is the message to ask if you want to buy it // * D4 is the screen's D register to log whether the item has been sold or not in. // Basically, set it to a different number (from 1 to 8) for each single sale item you have on-screen. // Set to 0 if the item can be bought several times. // * D5 is the item ID of the required item to buy this (require bow to buy arrows) // * D6 is the number that is drawn beside the item for things like levels and amounts. set to 0 if you don't want it to be drawn // * D7 is the input to check for, 0 for A, 1 for B, 2 for L and 3 for R // * Make sure you set the two constants in the section of code that's common to both scripts ffc script ShopItem { void run(int combo, int itm, int price, int message, int perm, int req_item, int number, int input) { this->Misc[0] = this->Data; // original combo this->Misc[1] = this->X; // original x this->Misc[2] = this->Y; // original y bool holding = false; bool show_item = false; if(Link->Item[req_item] || req_item==0) { if(perm==0) show_item = true; else if(Screen->D[perm] == 0) show_item = true; } while(show_item) { if(holding_item > 0 && holding) { this->X = Link->X; this->Y = Link->Y-16; DrawToLayer(this,3,128); if (CanTake(this, input)) { SetInput(0,false); SetInput(1,false); Game->PlaySound(SFX_CURSOR); this->Data = this->Misc[0]; this->X = this->Misc[1]; this->Y = this->Misc[2]; holding = false; holding_item = 0; holded_item = holded_item; if(Link->Item[LTM_HOLDING]) Link->Item[LTM_HOLDING] = false; } SetInput(0,false); SetInput(1,false); } else { this->X = this->Misc[1]; this->Y = this->Misc[2]; Screen->DrawInteger(3, this->X, this->Y-12, FONT_MATRIX, 8, -1, 0, 0, price, 0, 128); if (number > 0) Screen->DrawInteger(3, this->X+16, this->Y+8, FONT_MATRIX, 8, -1, 0, 0, number, 0, 128); if(CanTake(this, input)) { SetInput(0,false); SetInput(1,false); Game->PlaySound(SFX_CURSOR); this->Data = combo; this->X = Link->X; this->Y = Link->Y-16; holding = true; holding_item = 1; holded_item = FFCNum(this); if(!Link->Item[LTM_HOLDING]) Link->Item[LTM_HOLDING] = true; } } if(perm!=0) { if(Screen->D[perm] != 0) show_item = false; } Waitframe(); } this->Data = 0; } }
Edited by Shadowblitz16, 11 January 2017 - 06:21 PM.