Jump to content

Photo

Selecting an item via Script and Getting the tile of an item from an I


  • Please log in to reply
4 replies to this topic

#1 Unames

Unames

    Newbie

  • Members

Posted 11 October 2015 - 03:53 PM

My quest makes use of a scripted sub-screen for swapping equipment and displaying information. I am trying to set up selecting items from said sub-screen. The first issue is the actual selection of the items: How would I make it so by clicking on an item on the scripted sub-screen, that item will be selected to the B button. I also use a quick select similar to the wii version of twilight princess, which needs similar functionality. 

The second issue is retrieving the tiles and csets of the items link has collected, using the item IDs. Using the item pointer seems to require the item to be present on the screen, and the itemdata pointer does not appear to have any way of retrieving the tile. This is needed for drawing the items on the sub-screen.

How would these be done?


Edited by Unames, 11 October 2015 - 03:54 PM.


#2 coolgamer012345

coolgamer012345

    🔸

  • Members
  • Location:Indiana, USA

Posted 11 October 2015 - 04:03 PM

Ironically, I made a subscreen very recently. What I did was have a few arrays that were 255 in size, for each item that could possibly be on the subscreen, which stored the default X,Y, and Tab positions for each item (each 'tab' being kinda like how the subscreen in OoT had different sections) and create items when the pause button was pressed, and move the items to the correct positions (using their ->Misc's for the X,Y positions) depending on the current tab, and remove them when the pause button was pressed again. What I did for selecting items was having an array for each item that would be on the subscreen, that contained their ID's, and whenever I pressed the Left/Right/Up/Down I would find an item that had a More-Leftward/Rightward/Upward/Downward position, respectively. To actually set the items to the A/B buttons, use Link->SelectAButton(dir) and Link->SelectBButton(dir) in a while loop that stops when the current selected item is on the A/B.

 

 

If you want, I could PM you my code, which should be able to be modified rather easily due to the way it's set up.


  • Bagu likes this

#3 Timelord

Timelord

    The Timelord

  • Banned
  • Location:Prydon Academy

Posted 13 October 2015 - 07:42 AM

SUCCESSOR's code from items.zh.
 
//Changes B to specified item
void SwapEquipmentB(int it){
	if(!Link->Item[it]) return;
	if(it == EquipmentB()) return;
	if(it == EquipmentA()) SwapEquipment();
	//save current item to mark where we started
	int storeB = EquipmentB();
	//move to next item before checking conditions
	do{ Link->SelectBWeapon(SHIFT_DIR);}
	//if Item B is the right item or the item we started at stop
	while(EquipmentB() != it && storeB != EquipmentB() &&  EquipmentB())
}

//Change A to specified item gives item if needed
void SetEquipmentA(int it){
	//if Link doesn't have the item give it to him
	if(!Link->Item[it]) Link->Item[it] = true;
	SwapEquipmentA(it);
}
[

Old Version

Edited by ZoriaRPG, 13 October 2015 - 07:43 AM.

  • Bagu likes this

#4 Bagu

Bagu

    Fandomizer

  • Members
  • Real Name:A.I. Bot Bottomheimer
  • Location:Germany

Posted 18 January 2020 - 05:50 PM

SUCCESSOR's code from items.zh.

//Changes B to specified item
void SwapEquipmentB(int it){
	if(!Link->Item[it]) return;
	if(it == EquipmentB()) return;
	if(it == EquipmentA()) SwapEquipment();
	//save current item to mark where we started
	int storeB = EquipmentB();
	//move to next item before checking conditions
	do{ Link->SelectBWeapon(SHIFT_DIR);}
	//if Item B is the right item or the item we started at stop
	while(EquipmentB() != it && storeB != EquipmentB() &&  EquipmentB())
}

//Change A to specified item gives item if needed
void SetEquipmentA(int it){
	//if Link doesn't have the item give it to him
	if(!Link->Item[it]) Link->Item[it] = true;
	SwapEquipmentA(it);
}
[
Old Version


Hey, if I understand this right, it's exactly what I need for my "A Button = Swords only" Subscreen.
...but how to use this code.

Where should I place it in the script.
Could it be used as a global script, or dmap script, in the sub slot?

#5 Bagu

Bagu

    Fandomizer

  • Members
  • Real Name:A.I. Bot Bottomheimer
  • Location:Germany

Posted 18 January 2020 - 06:24 PM

My subscreen should just work like the classical preset (Zelda 3esque), but include this one function.(fix "A" and "B" start/end positions)
That would be so great (and all I need to complete the final version of my quest)

Edited by Bagu, 18 January 2020 - 06:26 PM.



0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users