- Joined
- Jan 6, 2008
- Messages
- 2,627
I solved this problem some minutes after i posted, sorry :>
Okay, this is my script(s)
Create the Units
I discovered that the if in function Selection doesnt work, but im sure it should, now, how to make it work properly, i need to select destructables in range of the unit.
Okay, this is my script(s)
Create the Units
JASS:
globals
unit array ci_dummyunits
endglobals
function UCREATE takes nothing returns nothing
local integer i = 1
local integer x
local integer y
local integer modelpath = 'invb' // TO FIND THIS OUT ON YOUR DUMMY, CTRL-D AND YOU WILL SEE A CODE ON 4 LETTERS!
loop
exitwhen i > udg_ci_slotcount
set x = R2I(GetDestructableX(udg_ci_slots[i]))
set y = R2I(GetDestructableY(udg_ci_slots[i]))
set ci_dummyunits[i] = CreateUnit(Player(0), modelpath, x, y, 0)
set i = i+1
endloop
endfunction
function InitTrig_InventoryCreateUnits takes nothing returns nothing
call TimerStart(CreateTimer(),0.,false,function UCREATE)
endfunction
JASS:
library InvetorySelectUnits initializer init
globals
integer selecteduniti
destructable selectedunit
endglobals
function pickdest takes nothing returns nothing
local integer i
call DisplayTextToForce( GetPlayersAll(), "Bagel" )
loop
exitwhen i > udg_ci_itemcount
if ( ( GetDestructableTypeId(GetEnumDestructable()) == udg_ci_itemdest[i] ) ) then
set selectedunit = GetEnumDestructable()
call DisplayTextToForce( GetPlayersAll(), GetDestructableName(selectedunit) )
endif
set i = i+1
endloop
call DisplayTextToForce( GetPlayersAll(), "Bagel" )
endfunction
function Selection takes nothing returns nothing
local integer i
local location p
local trigger selection = CreateTrigger()
loop
exitwhen i > udg_ci_slotcount
if ( ( GetTriggerUnit() == ci_dummyunits[i] ) ) then
set p = GetUnitLoc(ci_dummyunits[i])
call DisplayTextToForce( GetPlayersAll(), "Bagel" )
set selecteduniti = i
call EnumDestructablesInCircleBJ( 150., p, function pickdest )
call TriggerAddAction( selection, function pickdest )
call RemoveLocation(p)
endif
set i = i+1
endloop
endfunction
//===========================================================================
function init takes nothing returns nothing
local trigger sel = CreateTrigger()
call TriggerRegisterPlayerSelectionEventBJ( sel, Player(0), true )
call TriggerAddAction(sel, function Selection)
endfunction
endlibrary
I discovered that the if in function Selection doesnt work, but im sure it should, now, how to make it work properly, i need to select destructables in range of the unit.