- Joined
- Mar 7, 2013
- Messages
- 20
Problem Sloved!
Hi there.
I'm pretty new to Jass and made my self a trigger
If I test my map with the editor and the event fires my trigger.
The Game complitly crashes(throws up an error report, saying something like "bla couldn't be written"(maybe a pointer-error?!))
I'm using the jessnewgenpack and didn't get any syntax-errros(expected the "Undeclared Varibale gg_trg..."-error) so I can't figure out what exactly causes the problem.
I noticed, that if i don't save the map befor testing WC3 throws me back to the menu(What usually happens if there's an error in the code).
Would be nice if someone could help me out ^^
Maybe I used to much Wrappers, but I like them, couse they give the Post a little bit of tidiness.
Hi there.
I'm pretty new to Jass and made my self a trigger
If I test my map with the editor and the event fires my trigger.
The Game complitly crashes(throws up an error report, saying something like "bla couldn't be written"(maybe a pointer-error?!))
I'm using the jessnewgenpack and didn't get any syntax-errros(expected the "Undeclared Varibale gg_trg..."-error) so I can't figure out what exactly causes the problem.
I noticed, that if i don't save the map befor testing WC3 throws me back to the menu(What usually happens if there's an error in the code).
Would be nice if someone could help me out ^^
JASS:
globals
hashtable hBratenTimer = InitHashtable() //Hashtable for Timers
constant integer BRATEN_TIMER_COLUMN=0
constant integer BRATEN_ITEM_COLUMN=1
constant integer BRATEN_UNIT_COLUMN=2
integer anzTimer = 0
constant integer GEB_FLEISCH = 'I00A'
constant integer EISEN_BARREN = 'I00E'
constant integer BROT = 'I00S'
endglobals
//------------------------------------------------
function Item_is_Teig takes item whichItem returns boolean
return GetItemTypeId(whichItem) == 'I00T'
endfunction
function Item_is_Fleisch takes item whichItem returns boolean
return GetItemTypeId(whichItem) == 'I002'
endfunction
function Item_is_Eisenerz takes item whichItem returns boolean
return GetItemTypeId(whichItem) == 'I00D'
endfunction
function Handlerfunc takes nothing returns nothing
local item whichItem
local integer whichProd
local unit whichUnit
local integer charges
local timer t = GetExpiredTimer()
set whichItem = LoadItemHandle( hBratenTimer, GetHandleId(t), BRATEN_ITEM_COLUMN)
set whichUnit = LoadUnitHandle( hBratenTimer, GetHandleId(t), BRATEN_UNIT_COLUMN)
set charges = GetItemCharges(whichItem)
if(Item_is_Teig(whichItem)) then
set whichProd = BROT
elseif(Item_is_Fleisch(whichItem)) then
set whichProd = GEB_FLEISCH
elseif(Item_is_Eisenerz(whichItem)) then
set whichProd = EISEN_BARREN
endif
//-------
if( UnitHasItem( whichUnit, whichItem )) then
if( charges == 1 ) then
call RemoveItem(whichItem)
//--- "Delete" Timer+Entrie
call PauseTimer(t)
call DestroyTimer(t)
//call SaveBoolean( hBratenTimer, timerRow, BRATEN_INUSE_COLUMN, false )
else
call SetItemCharges(whichItem, (charges-1))
endif
call CreateItemLoc(whichProd, GetUnitLoc(whichUnit))
else
call RemoveItem(whichItem)
//--- "Delete" Timer+Entrie
call PauseTimer(t)
call DestroyTimer(t)
//call SaveBoolean( hBratenTimer, timerRow, BRATEN_INUSE_COLUMN, false )
endif
call CreateTextTagUnitBJ( ( GetItemName(GetLastCreatedItem())+" fertig."), whichUnit, 0, 10, 50, 100, 50, 0 )
call SetTextTagPermanentBJ( GetLastCreatedTextTag(), false )
call SetTextTagLifespanBJ( GetLastCreatedTextTag(), 2.00 )
call SetTextTagVelocityBJ( GetLastCreatedTextTag(), 64, 90 )
call SetTextTagFadepointBJ( GetLastCreatedTextTag(), 1.00 )
set t = null
endfunction
function Lagerfeuer_braten takes unit whichUnit, item whichItem returns nothing
local timer t = CreateTimer()
local integer i
//------Different Timers for drifferent Indigrents
if(Item_is_Teig(whichItem)) then
call TimerStart(t, 20.00, true, function Handlerfunc)
elseif(Item_is_Fleisch(whichItem)) then
call TimerStart(t, 10.00, true, function Handlerfunc)
elseif(Item_is_Eisenerz(whichItem)) then
call TimerStart(t, 40.00, true, function Handlerfunc)
endif
//------Save Timer+Variables in Hashtable
if Item_is_Teig(whichItem) or Item_is_Fleisch(whichItem) or Item_is_Eisenerz(whichItem) then
call BJDebugMsg("SpeichereTimer")
call SaveTimerHandle( hBratenTimer, GetHandleId(t), BRATEN_TIMER_COLUMN, t )
call SaveItemHandle( hBratenTimer, GetHandleId(t), BRATEN_ITEM_COLUMN, whichItem )
call SaveUnitHandle( hBratenTimer, GetHandleId(t), BRATEN_UNIT_COLUMN, whichUnit )
call CreateTextTagUnitBJ( ( GetItemName(whichItem)+" wird verarbeitet.(Dauer: "+R2S(TimerGetTimeout(t))+"sek.)"), whichUnit, 0, 10, 50, 100, 50, 0 )
call SetTextTagPermanentBJ( GetLastCreatedTextTag(), false )
call SetTextTagLifespanBJ( GetLastCreatedTextTag(), 2.00 )
call SetTextTagVelocityBJ( GetLastCreatedTextTag(), 64, 90 )
call SetTextTagFadepointBJ( GetLastCreatedTextTag(), 1.00 )
set t = null
endif
endfunction
//---------------------Trigger Functions--------------------------
function Trig_Lagerfeuer_fuellen_Conditions takes nothing returns boolean
return GetUnitTypeId(GetTriggerUnit()) == 'h009'
endfunction
function Trig_Lagerfeuer_fuellen_Actions takes nothing returns nothing
call Lagerfeuer_braten(GetTriggerUnit(), GetManipulatedItem())
endfunction
//===========================================================================
function InitTrig_Lagerfeuer_fuellen takes nothing returns nothing
set gg_trg_Lagerfeuer_fuellen = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ( gg_trg_Lagerfeuer_fuellen, EVENT_PLAYER_UNIT_PICKUP_ITEM )
call TriggerAddCondition( gg_trg_Lagerfeuer_fuellen, Condition( function Trig_Lagerfeuer_fuellen_Conditions ) )
call TriggerAddAction( gg_trg_Lagerfeuer_fuellen, function Trig_Lagerfeuer_fuellen_Actions )
endfunction
So the reason I was creating this trigger is:
In the map I've a unit, that can cook.
If I put a cookable inigrent into the inventory of the cook-unit, it should decreas the charges remaining in the indigrent by 1 and creat a product after a period of time.
If there still charges remaining it should do this(decreas the charges remaining in the indigrent by 1 and creat a product after a period of time) again.
If the charges remain are 0 then it should remove the item.
In the map I've a unit, that can cook.
If I put a cookable inigrent into the inventory of the cook-unit, it should decreas the charges remaining in the indigrent by 1 and creat a product after a period of time.
If there still charges remaining it should do this(decreas the charges remaining in the indigrent by 1 and creat a product after a period of time) again.
If the charges remain are 0 then it should remove the item.
If the trigger is fiered it calls the "Lagerfeuer_braten"-Funktion(maybe cook is a better name^^). The "Lagerfeuer_braten"-Funktion starts a periodic timer, wich expiretime depens on the Item(Indigrent) given to the Cook-Unit. Becouse I need to know what Item and which Unit is involved I save the Timers-Handel in a hashtable and connect it with the needed data. When the timer fieres it calls the "Timer_Create_Product_out_of_Item"-Function this Function Loads the needed Variables form the hashtable and decreases the Unit's Item charges by one or if they're 0 removes it and destroys the Timer.
Maybe I used to much Wrappers, but I like them, couse they give the Post a little bit of tidiness.
Last edited: