• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

I encountered a problem with the hashmap in WRUST

Status
Not open for further replies.
Level 1
Joined
Apr 5, 2023
Messages
2
I am new to s using wurst. I plan to make a class of binding item types, meaning I can get this data from an item.

But I need help with the hashmap. When I have a specific item, I can read the atr_item instance I have saved through this GetItemTypeIdk typically. When I try to define a function that can read this class directly from the item, I get an error.

Below is the full code and a screenshot of what happens. How do I fix it?

1.png


2.png


Wurst:
public class Atr_item
    int Attack = 0
    int Armor = 0
    int Str = 0
    int Agi = 0
    int Int = 0
    int HP = 0
    int HPs = 0
    int Speed = 0

    construct(int Attack, int Armor, int Str, int Agi, int Int, int HP, int HPs, int Speed)
        this.Attack = Attack
        this.Armor = Armor
        this.Str = Str
        this.Agi = Agi
        this.Int = Int
        this.HP = HP
        this.HPs = HPs
        this.Speed = Speed

    function check_test()
        print(this.Attack)
        print(this.Armor)
        print(this.Str)

public HashMap itemMap

init
    let itemMap = new HashMap<integer, Atr_item>
    
    item array i
    i[0] = createItem('I000', ZERO2)
    itemMap.put(itemToIndex(i[0]), new Atr_item(10, 0, 0, 0, 0, 0, 0, 0))
    i[0].remove()

    i[1] = createItem('I001', ZERO2)
    itemMap.put(itemToIndex(i[1]), new Atr_item(0, 10, 0, 0, 0, 0, 0, 0))
    i[1].remove()

    i[2] = createItem('I002', ZERO2)
    itemMap.put(itemToIndex(i[2]), new Atr_item(0, 0, 10, 0, 0, 0, 0, 0))
    i[2].remove()

    i[3] = createItem('I000', ZERO2)
    let temp = itemMap.get(itemToIndex(i[3]))
    
    temp.check_test()

public function item.getattr() returns Atr_item
    return itemMap.get(GetItemTypeId(this))
 
Status
Not open for further replies.
Top