• 🏆 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!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

Help to get started with Hashtable

Status
Not open for further replies.
Level 1
Joined
Feb 11, 2011
Messages
6
Hello. Currently im making a custom map. I got stuck on few triggers.
I want to make in example 3 rocks(units) and when worker hits it, he should go to rect and drop items there. Problem is i don't know how to make that worker to get back attacking SAME rock and not the nearest or random after he dropped items. There going to be lots of workers and rocks so i don't know how to make this. Please help!
 
Level 21
Joined
Nov 4, 2013
Messages
2,017
Then why not basing rocks on "trees"? You create a destructible based on Summer Tree Wall and change its model to a rock. Therefore the worker goes to harvest a rock, deposits the resources and returns back to the same rock. It requires 0 triggers, it is very easy and 100% efficient.
 
Level 1
Joined
Feb 11, 2011
Messages
6
Oh my god... The same problem as with every forum. If i ask help with hashtables then help me with hashtables not finding another solution.
Now if there is rock, iron, uranium. How would i make lumber that workers harvest would give me 3 different resources???
 
Level 9
Joined
Apr 23, 2011
Messages
527
Oh my god... The same problem as with every forum. If i ask help with hashtables then help me with hashtables not finding another solution.

lol
if you don't want an easier solution/to listen in general then good luck

an issue i can find with the tree-rock thing is that the worker would have to return the resource at some point. setting the max to some high number (or 0) and/or removing the stand/walk lumber animation might work. i think this is how MineralZ did it.
 
Level 1
Joined
Feb 11, 2011
Messages
6
Found open source map of mineralz. There are harvest tree and stuff but it works with hashtables. He made lots of hashtables and i cant understand any of it, its too complicated.
 
Hashtable is like 2d array, it has columns and rows.

You can save data into cell [1][2] for example. (column: 1, row: 2)
But when you want to save data specific for a unit you don't use simple
values like "1" or "2" for cell definition. (they are called keys btw)
But here, you wantt use the HandleId of the unit as key.
HandleId is just a number that is unique for each unit, so it won't come in conflict.

Example:
Set myInt = HandleId(MyUnit)
Save "data" in Hashtable[myInt][0].
(second key didn't bother me, so I just chose "0" as example.)

I don't have editor right now, but example for your question:

1. Attacker attacks Stone (you said it's a unit)
2. Save <Stone> in <hashtable[x][y]>
3. Order attacker to go back/or what ever.
4. When done, order again to attack "LoadUnit <hashtable[x][y]".

x = HandleId(Attacker)
y = Second key does not matter here.


Now this should work. He would attack/ go back/ attack again.
But at this moment you still can't define what resource was braught back.
But this can be solved later, when you understood how to work with hashtables first.

I quickly found this tutorial about hashtables: http://www.hiveworkshop.com/forums/trigger-gui-editor-tutorials-279/hashtables-mui-133407/
It's not about custom resources, but maybe you can get a basic understanding of how it works.

There are maybe some custom resource systems somewhere around here.
I have not found one quickly, but once found one, I will post here, or someone else will maybe.

Try it out, ask again if something does not work, or isn't clear:).
 
Last edited:
Level 1
Joined
Feb 11, 2011
Messages
6
Finally I made a script. Simple and seems to work. There was a problem when i couldn't find any functions for some values and hastables. It was because of bad version of UMSWE. Then i tried on vanilla WE and everything worked. Now i have some clue on hastables and my simple script works. Thanks IcemanBo
 
Last edited:
Level 24
Joined
Aug 1, 2013
Messages
4,657
Download a unit indexer... I use bribe's
Make a global unit array and save the rock in that array on the index of the Custom data of the peasant when the peasant hits the rock.
After that... you know what rock each peasant has hit last.
No use for hashtables.

Also make sure that you null the variable when the peasant gets removed... or when the rock is destroyed if possible.
 
Status
Not open for further replies.
Top