Jump to content

Photo

Modular item scripts

item

  • Please log in to reply
3 replies to this topic

#1 DigitalDetective47

DigitalDetective47

    resident dumbass

  • Members
  • Real Name:Em
  • Pronouns:They / Them

Posted 25 May 2024 - 06:27 PM

Is there any way for an item script to access information about the item that called it?

Edited by DigitalDetective47, 25 May 2024 - 07:10 PM.


#2 DigitalDetective47

DigitalDetective47

    resident dumbass

  • Members
  • Real Name:Em
  • Pronouns:They / Them

Posted 26 May 2024 - 12:10 PM

this->ID


#3 Alucard648

Alucard648

    Wizard

  • Members
  • Location:castle Dracula

Posted 28 May 2024 - 12:04 AM

There was no such parameter in 2.53. Use this function in 2.53.

//Returns ID of item from itemdata pointer
int ItemID (itemdata it){
	for (int i=0; i<256; i++){
		itemdata n = Game->LoadItemData(i);
		if (it==n) return i;
	}
	return -1;
}


#4 Emily

Emily

    Scripter / Dev

  • ZC Developers
  • Pronouns:She / Her

Posted 28 May 2024 - 10:41 AM

 

There was no such parameter in 2.53. Use this function in 2.53.

//Returns ID of item from itemdata pointer
int ItemID (itemdata it){
	for (int i=0; i<256; i++){
		itemdata n = Game->LoadItemData(i);
		if (it==n) return i;
	}
	return -1;
}

You don't need `this->ID` though to get the *information of the item*, only the ID number. If what they want is actually just information about the item, `this->` in general has all of it (since `this->` is already the itemdata for the item)





Also tagged with one or more of these keywords: item

2 user(s) are reading this topic

0 members, 2 guests, 0 anonymous users