• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Some questions about icons

Status
Not open for further replies.
Level 7
Joined
Jan 29, 2010
Messages
213
Hi all, I have a litle problem here. I want to make multiboar witch would show items witch your having in your inventory without setting icons on variables like:
"s(1) = ReplaceableTextures\CommandButtons\BTNAbomination.blp".

Is there are some kind of more simple way, something like this:
"Multiboard - Set the icon for (Last created multiboard) item in column 1, row 1 to (Icon of (Item carried by Triggering unit in slot 1))".
 
Level 14
Joined
Apr 20, 2009
Messages
1,543
I'm not sure if this is possible, you would need to find the file path of the icon of the item carried in some slot of a hero.
I would have to check some Jass native's to see if there is anything usefull that might be abled to do this. Just a second...
 
Level 37
Joined
Mar 6, 2006
Messages
9,243
You could save the image path (string) using the item type as a key into a hashtable.

Saving string:
call SaveStr(hash, GetHandleId('ratc'), 0, "ReplaceableTextures\\CommandButtons\\BTNClawsOfAttack.blp")

Loading string:
set s = LoadStr(hash, GetHandleId(GetItemTypeId(UnitItemInSlot(unit, slot))))

ratc is the raw code of your item type. ratc = Claws of attack +12. Remember to initialize the hashtable.
 
Last edited:
Level 14
Joined
Apr 20, 2009
Messages
1,543
You could save the image path (string) using the item type as a key into a hashtable.

Saving string:
call SaveStr(hash, GetHandleId('ratc',), 0, "ReplaceableTextures\\CommandButtons\\BTNClawsOfAttack.blp")

Loading string:
set s = LoadStr(hash, GetHandleId(GetItemTypeId(UnitItemInSlot(unit, slot))))

ratc is the raw code of your item type. ratc = Claws of attack +12. Remember to initialize the hashtable.

Is there no way of returning the path of a specific icon? Does it need to be stored?? I can't find anything usefull in the native's list :S
 
Level 7
Joined
Jan 29, 2010
Messages
213
Thenks for replaying so fast. But theres one thing witch I hate my self to ask... I forgot how to stop we from checking custom scripts.

I mean I cant get your triggers working on custom script:
Line 21: Expected a variable name.
set s = LoadStr(hash, GetHandleId(GetItemTypeId(UnitItemInSlot(unit, slot))))
 
Level 14
Joined
Apr 20, 2009
Messages
1,543
Thenks for replaying so fast. But theres one thing witch I hate my self to ask... I forgot how to stop we from checking custom scripts.

I mean I cant get your triggers working on custom script:
Line 21: Expected a variable name.
set s = LoadStr(hash, GetHandleId(GetItemTypeId(UnitItemInSlot(unit, slot))))

slot is a variable, you did not define it.
unit should also be set to the unit that you want to target.
Try changing it to something like:
set your_unit = Peasent 001 or something like that... (in GUI)
set s = LoadStr(hash, GetHandleId(GetItemTypeId(UnitItemInSlot(udg_your_unit, 0)))) (in Custom Script)

0 = slot 1 of the unit.
1 = slot 2 etc...

So to explain a little bit better: basically you save the image path of the item in a string. You reference it by setting the raw code of the item in a key. Later on you load that same string from the hashtable by loading the key, which then checks if slot 1 contains that same item raw code. If it does then the string will be returned and put inside variable s. If it doesn't s will be empty.

Let's break it up in parts:

call SaveStr(hash,
hash is the name of the hashtable

GetHandleId('ratc',),
This is the ID of the type of the item, in this case Claws of Attack + 12 (the ID of an object is called raw code)

0,
This is the spot where the string is saved inside your hashtable. However we won't use this for loading the string from the hashtable but it needs to be set.
When creating more items and image paths inside your hashtable you would have to change this unless you want to overwrite the same spot inside the hashtable.

"ReplaceableTextures\\CommandButtons\\BTNClawsOfAttack.blp")
And ofcourse the string that needs to be saved.

set s = LoadStr(hash,
Here it says load the hashtable named hash.

GetHandleId(GetItemTypeId(UnitItemInSlot(udg_your_unit, 0))))
Get the ID of the type of the item in slot 1 of the unit stored in your_unit variable. When the item in slot 1 is the same as one of the items in the hashtable, the string of that corresponding item will be loaded and set into variable s.

So basically what we did with the hashtable is something like:
if the item in slot 1 of your unit is the same as Claws of attack +12 then set s = "ReplaceableTextures\\CommandButtons\\BTNClawsOfAttack.blp"
you can then use s inside your multiboard.

There is no way of returning the image path from an item directly. You have to save or set it somewhere :(

I hope this helps in explaining how it works.
 
Last edited:
Level 7
Joined
Jan 29, 2010
Messages
213
Even when I made all things how u said I still got an error disabling all trigger. It happens allways when Im using custom scripts. Even those customs scipts witch is destroying groups or removing unit from the game :/

It appears error is not in custom script. WE itself allways blocks customs scripts for me, what I mean it's that I want to make WE stop checking them.
 
Level 14
Joined
Apr 20, 2009
Messages
1,543
Even when I made all things how u said I still got an error disabling all trigger. It happens allways when Im using custom scripts. Even those customs scipts witch is destroying groups or removing unit from the game :/

It seems error is not in custom script but same we allways blocks customs scripts for me, what I mean it's that I want to make WE stop checking theml.

If a custom script is not spelled exactly the way it should then the game does not work. It will not start unless you solve the custom script, remove the custom script or disable the trigger. There are no other ways of removing the world editor's syntax checker. Which is normal because incorrect code should not be executed...

Could you show us the trigger so that we can see what went wrong?

Also is it displaying a different error as before or the same one?
 
Level 7
Joined
Jan 29, 2010
Messages
213
Line 23: Expected a variable name.

set s = LoadStr(hash, GetHandleId(GetItemTypeId(UnitItemInSlot(udg_u, 0))))

  • icons
    • Events
      • Time - Elapsed game time is 2.00 seconds
    • Conditions
    • Actions
      • Set u = Paladin 0000 <gen>
      • Custom script: set s = LoadStr(hash, GetHandleId(GetItemTypeId(UnitItemInSlot(udg_u, 0))))
      • Multiboard - Create a multiboard with 5 columns and 1 rows, titled icons
      • Multiboard - Hide (Last created multiboard)
      • Multiboard - Set the width for (Last created multiboard) item in column 0, row 1 to 2.00% of the total screen width
      • Multiboard - Set the icon for (Last created multiboard) item in column 1, row 1 to s
      • Multiboard - Show (Last created multiboard)
 
Level 14
Joined
Apr 20, 2009
Messages
1,543
Line 23: Expected a variable name.

set s = LoadStr(hash, GetHandleId(GetItemTypeId(UnitItemInSlot(udg_u, 0))))

  • icons
    • Events
      • Time - Elapsed game time is 2.00 seconds
    • Conditions
    • Actions
      • Set u = Paladin 0000 <gen>
      • Custom script: set s = LoadStr(hash, GetHandleId(GetItemTypeId(UnitItemInSlot(udg_u, 0))))
      • Multiboard - Create a multiboard with 5 columns and 1 rows, titled icons
      • Multiboard - Hide (Last created multiboard)
      • Multiboard - Set the width for (Last created multiboard) item in column 0, row 1 to 2.00% of the total screen width
      • Multiboard - Set the icon for (Last created multiboard) item in column 1, row 1 to s
      • Multiboard - Show (Last created multiboard)

Can you try doing this: set udg_s = LoadStr(hash, GetHandleId(GetItemTypeId(UnitItemInSlot(udg_u, 0))))
and then create a variable called s of type string in your variable editor? Then use that variable inside the multiboard.

If that also doesn't work add a custom script above the LoadStr which contains the following: local string s

The error you are getting is there because s is not defined. Your setting the variable even though it still has to be created. udg_ means that your using a global variable created in your variable editor. When you don't specify this then your using a local variable, which you first have to create by saying: local <variable type> <name>
I hope this helps.

Also when your using a local variable you can't simply type in s when adding it to the multiboard because then your just saying set the item to a string containing s. You would have to use a custom script again to add it if your going to use a local variable. It might be better to try the first option I gave you since it's easyer to use with GUI.
 
Level 7
Joined
Jan 29, 2010
Messages
213
Can you try doing this: set udg_s = LoadStr(hash, GetHandleId(GetItemTypeId(UnitItemInSlot(udg_u, 0))))
and then create a variable called s of type string in your variable editor? Then use that variable inside the multiboard.

I tried writing s and udg_s
the variable s is string.
variable u is unit.

In the past, when I tested other players maps with custom scripts it worked ok.
But when I turned off trigger which has an custom script and then turn on I got error ( I think its WE error not custom script)
 
Level 14
Joined
Apr 20, 2009
Messages
1,543
I tried writing s and udg_s
the variable s is string.
variable u is unit.

In the past, when I tested other players maps with custom scripts it worked ok.
But when I turned off trigger which has an custom script and then turn on I got error ( I think its WE error not custom script)

Let me check the LoadStr native to see if it is being used in the correct way. And no it can not be a WE error when it is being showed in the world editor syntax checker.

EDIT: Ow I see, hash is also a local variable. Try making it global, your targeting a non existing hashtable.
Example: make a hashtable variable called hash, create a hashtable ans set the variable to the hashtable. Then do the following:

call SaveStr(udg_hash, GetHandleId('ratc',), 0, "ReplaceableTextures\\CommandButtons\\BTNClawsOfAttack.blp")

(in whatever trigger you called this, also make sure that you create the hashtable before you call this function)

and:

set udg_s = LoadStr(udg_hash, GetHandleId(GetItemTypeId(UnitItemInSlot(udg_u, 0))))

Now there should be no local variables left.
Maker gave you this code so that you can write it in a Jass function so that you won't have to use any global variables but local ones. In which case would've worked.
But since your trying to use GUI triggers it's easyer to just use global variables for transition between triggers.
 
Level 7
Joined
Jan 29, 2010
Messages
213
  • sadfafas
    • Events
      • Time - Elapsed game time is 2.00 seconds
    • Conditions
    • Actions
      • Set u = Paladin 0000 <gen>
      • Custom script: call SaveStr(udg_hash, GetHandleId('ratc',), 0, "ReplaceableTextures\\CommandButtons\\BTNClawsOfAttack.blp")
      • Custom script: set udg_s = LoadStr(udg_hash, GetHandleId(GetItemTypeId(UnitItemInSlot(udg_u, 0))))
Code:
Line 24: Expected exppression
Line 25: Invalid argument type (Integer)
Code:
//***************************************************************************
//*
//*  Global Variables
//*
//***************************************************************************

globals
    // User-defined
    unit                    udg_u                      = null
    string                  udg_s
    hashtable               udg_hash                   = null

    // Generated
    unit                    gg_unit_Hpal_0000          = null
    trigger                 gg_trg_icon                = null
endglobals

function InitGlobals takes nothing returns nothing
    set udg_s = ""
endfunction

function Trig_icon_Actions takes nothing returns nothing
    set udg_u = gg_unit_Hpal_0000
    call SaveStr(udg_hash, GetHandleId('ratc',), 0, "ReplaceableTextures\\CommandButtons\\BTNClawsOfAttack.blp")
    set udg_s = LoadStr(udg_hash, GetHandleId(GetItemTypeId(UnitItemInSlot(udg_u, 0)))) 
endfunction

//===========================================================================
function InitTrig_icon takes nothing returns nothing
    set gg_trg_icon = CreateTrigger(  )
    call TriggerRegisterTimerEventSingle( gg_trg_icon, 2.00 )
    call TriggerAddAction( gg_trg_icon, function Trig_icon_Actions )
endfunction
 
Level 14
Joined
Apr 20, 2009
Messages
1,543
  • sadfafas
    • Events
      • Time - Elapsed game time is 2.00 seconds
    • Conditions
    • Actions
      • Set u = Paladin 0000 <gen>
      • Custom script: call SaveStr(udg_hash, GetHandleId('ratc',), 0, "ReplaceableTextures\\CommandButtons\\BTNClawsOfAttack.blp")
      • Custom script: set udg_s = LoadStr(udg_hash, GetHandleId(GetItemTypeId(UnitItemInSlot(udg_u, 0))))
Code:
Line 24: Expected exppression
Line 25: Invalid argument type (Integer)
Code:
//***************************************************************************
//*
//*  Global Variables
//*
//***************************************************************************

globals
    // User-defined
    unit                    udg_u                      = null
    string                  udg_s
    hashtable               udg_hash                   = null

    // Generated
    unit                    gg_unit_Hpal_0000          = null
    trigger                 gg_trg_sadfafas            = null
endglobals

function InitGlobals takes nothing returns nothing
    set udg_s = ""
endfunction

function Trig_sadfafas_Actions takes nothing returns nothing
    set udg_u = gg_unit_Hpal_0000
    call SaveStr(udg_hash, GetHandleId('ratc',), 0, "ReplaceableTextures\\CommandButtons\\BTNClawsOfAttack.blp")
    set udg_s = LoadStr(udg_hash, GetHandleId(GetItemTypeId(UnitItemInSlot(udg_u, 0))))

I'm at work at this moment, when I get home which I will go right now I'll try to fix this for you. I think it got something to do with the comma in GetHandleId and the integer provided in UnitItemInSlot. I'll take a look when I get home...
 
Level 14
Joined
Apr 20, 2009
Messages
1,543
hmm okay lets put the natives next to each other and see what we do wrong.

JASS:
native LoadStr takes hashtable table, integer parentKey, integer childKey returns string
native GetHandleId takes handle h returns integer
native GetItemTypeId takes item i returns integer
native UnitItemInSlot takes unit whichUnit, integer itemSlot returns item

Ah I see, GetItemTypeId returns an integer and GetHandleId takes a handle...

A handle is everything except for: real, string, integer, and boolean.

Okay, try this D0W3R:

  • sadfafas
    • Events
      • Time - Elapsed game time is 2.00 seconds
    • Conditions
    • Actions
      • Set u = Paladin 0000 <gen>
      • Hashtable - Create a hashtable
      • Set hash = (Last created hashtable)
      • Custom script: call SaveStr(udg_hash, GetHandleId('ratc'), 0, "ReplaceableTextures\\CommandButtons\\BTNClawsOfAttack.blp")
      • Custom script: set udg_s = LoadStr(udg_hash, GetHandleId(GetItemType(UnitItemInSlot(udg_u, 0))))
 
Last edited:
Level 7
Joined
Jan 29, 2010
Messages
213
Yeah, take the comma away after the 'ratc'
Srry huh? Im noob...

Okay, try this D0W3R:

  • sadfafas
    • Events
      • Time - Elapsed game time is 2.00 seconds
    • Conditions
    • Actions
      • Set u = Paladin 0000 <gen>
      • Hashtable - Create a hashtable
      • Set hash = (Last created hashtable)
      • Custom script: call SaveStr(udg_hash, GetHandleId('ratc'), 0, "ReplaceableTextures\\CommandButtons\\BTNClawsOfAttack.blp")
      • Custom script: set udg_s = LoadStr(udg_hash, GetHandleId(GetItemType(UnitItemInSlot(udg_u, 0))))

Still isn't working.
Code:
Line 26: Invalid argument type (Integer)
Line 27: Invalid number of arguments (Integer)
Code:
//***************************************************************************
//*
//*  Global Variables
//*
//***************************************************************************

globals
    // User-defined
    unit                    udg_u                      = null
    string                  udg_s
    hashtable               udg_hash                   = null

    // Generated
    trigger                 gg_trg_icon                = null
    unit                    gg_unit_Hpal_0000          = null
endglobals

function InitGlobals takes nothing returns nothing
    set udg_s = ""
endfunction

function Trig_icon_Actions takes nothing returns nothing
    set udg_u = gg_unit_Hpal_0000
    call InitHashtableBJ(  )
    set udg_hash = GetLastCreatedHashtableBJ()
    call SaveStr(udg_hash, GetHandleId('ratc'), 0, "ReplaceableTextures\\CommandButtons\\BTNClawsOfAttack.blp")
    set udg_s = LoadStr(udg_hash, GetHandleId(GetItemType(UnitItemInSlot(udg_u, 0))))
endfunction

//===========================================================================
function InitTrig_icon takes nothing returns nothing
    set gg_trg_icon = CreateTrigger(  )
    call TriggerRegisterTimerEventSingle( gg_trg_icon, 2.00 )
    call TriggerAddAction( gg_trg_icon, function Trig_icon_Actions )
endfunction
 
Last edited:
Level 7
Joined
Jan 29, 2010
Messages
213
Srry I still getting errors but this time both is on: "Invalid argument type (Integer).
PlS check it by your self it would be much more easier than chating here 2days along and not getting any results... :/
Download: icon.w3x
 
Level 14
Joined
Apr 20, 2009
Messages
1,543
me too... :D

I know that every handle has a unique ID.
Which you can return by calling GetHandleId.
It takes a handle (any variable except for real, string, integer, and boolean).
It then returns an integer (the Unique ID of the handle).
You can use this to check if 2 handles are the same.

However I'm not sure when it should be used...
 
Status
Not open for further replies.
Top