Need Example of Slide Spell with Structs

emjlr3

Change can be a good thing
Reaction score
395
rofl none of that makes any sense to me grim, is it sorta like vexs? which is what i use, however it looks like urs can have more total
 

grim001

New Member
Reaction score
10
Well you know how you can only attach one integer to something with CSData?

Well imagine declaring 20 copies of CSData, now you can attach 20 different integers with 20 different function names.

Now imagine making it attach some other kind of thing just by changing every instance of the word "integer" to a different type such as "real" or "unit"

Only real purpose now is to attach integers to things to retrieve a struct..
 

emjlr3

Change can be a good thing
Reaction score
395
could you give an example of yours usage grim?

I am more of a visual learner
 

Tom Jones

N/A
Reaction score
437
JASS:
//Imagine that grims system is right above this comment.
//! runtextmacro DS_Declare("Unit","unit")
//Now we're able to store units, by using SetUnit(), and getting them again by using GetUnit().

scope test
globals
    private timer t
endglobals

function Timer_Actions takes nothing returns nothing
    set u = GetUnit(GetExpiringTimer())

    call UnitDamageTarget(u,u,15,false,false,ATTACK_TYPE_NORMAL,DAMAGE_TYPE_NORMAL,WEAPON_TYPE_WHKNOWS)
    set u = null
endfunction

function...
    local unit u = GetTriggerUnit()
    local integer i = GetData(t)

    if i == 0 then
        call TimerStart(t,0.05,true,function Timer_Actions)
    endif
    set i = i+1 
    call SetData(t,i)    
    call SetUnit(t,u)
    set u = null
endfunction
endscope
@Grim.
The system storage is limited to one handle type per handle right?
 

substance

New Member
Reaction score
34
JASS:
struct TimedFade
unit fader
integer alpha = 255
integer interval
integer maxinteger
endstruct
	
function UnitFadeTimedAction takes nothing returns nothing
    local TimedFadeData data = GetData(GetExpiredTimer())
    
	if (data.maxinteger > 0) then
		set data.alpha = data.alpha - R2I(((0.05*data.interval+1)))
		call SetUnitVertexColor(u,data.alpha,data.alpha,data.alpha,data.alpha)
	else
		call ReleaseTimer(t)
	endif
	set data.maxinteger = data.maxinteger - 1
endfunction

function UnitFadeTimed takes unit u, real time, real percent returns nothing
	local timer t = NewTimer()
	local TimedFadeData data = TimedFadeData.create()
	
	if (time == 0) then
		call SetUnitVertexColor(u,255,255,255,0)
		return
	endif
	if (percent > 100) or (percent <= 0) then
		set percent = 100
	endif
	if (percent != 100) then
		set percent = RAbsBJ(percent-100)
	endif
	set data.interval = R2I(((data.alpha/time)+1))
	set data.maxinteger = R2I((((time*(percent/100))/0.05)+1))
	if (data.maxinteger <= 0) then
		return
	endif
	
	call SetData(t, integer(data))
	call TimerStart(t,0.05,true,function UnitFadeTimedAction)
endfunction


A more practical example, imo. However I dont normally attatch to timers.
 

grim001

New Member
Reaction score
10
The system storage is limited to one handle type per handle right?

You could define SetUnit and SetUnit2 and SetUnit3 ad infinitum to attach as many as you wanted, but it makes more sense to just use this to attach integers that point to structs.
 

Tom Jones

N/A
Reaction score
437
You could define SetUnit and SetUnit2 and SetUnit3 ad infinitum to attach as many as you wanted, but it makes more sense to just use this to attach integers that point to structs.
Yes agreed, though if your all ready are using the New Gen editor, or vJass in general, I would say that it's easier to simply declare an integer array and an integer for indexing.
 

grim001

New Member
Reaction score
10
Actually attaching (at least integers) to timers, triggers and units is still needed at times.
 

--Thanatos--

New Member
Reaction score
33
Gah.. So it was supposed to be like this?

JASS:

struct idu
    unit caster
    integer level
endstruct

//and then use this?

function whoa takes nothing returns nothing
    local timer mytimer = GetExpiredTimer()
    local idu mystruct = GetData(mytimer,idu)
endfunction

function TimerStarting takes nothing returns nothing
    local timer Blah = CreateTimer()
    local idu mystruct = idu.create()
    call SetData(Blah,mystruct)
    call TimerStart(Blah,3204239.,false,function whoa)
endfunction


Also... will this be a Handle Stack in the end?
 

substance

New Member
Reaction score
34
You dont have to specificy when using GetData:
JASS:
local idu mystruct = GetData(mytimer)


Also you should typecast the struct/integer:
JASS:
call SetData(Blah,integer(mystruct))
 

grim001

New Member
Reaction score
10
No, it is not a stack. But you could write a stack system and use this to attach an integer pointing to the stack.
 

--Thanatos--

New Member
Reaction score
33
Ok this started to piss me off.
OffTopic: JassNewGen
It worked at last morning, the mockery that says: "Map couldn't be found" and blah. >_> Now it couldn't give me Syntax Checks. And I couldn't test my map with ur DataSystem. (Must disable the trigger, dunno why, if I don't it will only show the Main Menu on the Test).
 
Reaction score
456
You always need to save before testing, if you have done changes in the map, else it will most likely go to main screen.
 

--Thanatos--

New Member
Reaction score
33
I always save. The annoying word "Map Couldn't be found" is the main misery, I couldn't even see the Syntax Errors.
 

--Thanatos--

New Member
Reaction score
33
Bump.

Aw,, come on help me. T_T

EDIT: NVM Found out Jass NewGen cannot check maps with long name. >_>
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top