- Joined
- Sep 30, 2009
- Messages
- 698
Because I haven't found any vJass Texttag libraries and I wanted to create one.
I think I heard somewhere that texttags could be created for a single player only without desyncs but I can't test it right now so I am asking here.
Also I am wondering if this line would work, or if I need 2 ifs there:
(if you create a texttag for a null player it should be created for all instead)
I think I heard somewhere that texttags could be created for a single player only without desyncs but I can't test it right now so I am asking here.
Also I am wondering if this line would work, or if I need 2 ifs there:
if GetLocalPlayer() == .owner or .owner == null then
(if you create a texttag for a null player it should be created for all instead)
JASS:
library Texttag
struct Texttag
private texttag tag
private real Size
private real X
private real Y
private real Height
private boolean Visible
readonly player owner
readonly real xvel
readonly real yvel
method operator size takes nothing returns real
return .Size
endmethod
method operator size= takes real size returns nothing
set .Size = size * 0.023 / 10
set .text = .Text
endmethod
method operator x takes nothing returns real
return .X
endmethod
method operator x= takes real x returns nothing
call .setPosition(x, .y)
endmethod
method operator y takes nothing returns real
return .Y
endmethod
method operator y= takes real y returns nothing
call .setPosition(.x, y)
endmethod
method operator height takes nothing returns real
return .Height
endmethod
method operator height= takes real h returns nothing
set .Height = h
call .setPosition(.x, y)
endmethod
method operator visible takes nothing returns boolean
return .Visible
endmethod
method operator visible= takes boolean visible returns nothing
set .Visible = visible
if GetLocalPlayer() == .owner or .owner == null then
call SetTextTagVisibility(.tag, .Visible)
endif
endmethod
method setPosition takes real x, real y returns nothing
set .x = x
set .y = y
if GetLocalPlayer() == .owner or .owner == null then
call SetTextTagPos(.tag, .x, .y, .Height)
endif
endmethod
method setVelocity takes real speed, real angle returns nothing
set .xvel = speed * 0.071 / 128 * Cos(angle * bj_DEGTORAD)
set .yvel = speed * 0.071 / 128 * Sin(angle * bj_DEGTORAD)
if GetLocalPlayer() == .owner or .owner == null then
call SetTextTagVelocity(.tag, .xvel, .yvel)
endif
endmethod
//! runtextmacro TEXTTAG_OPERATER("age", "Age", "real", "")
//! runtextmacro TEXTTAG_OPERATER("lifespan", "Lifespan", "real", "")
//! runtextmacro TEXTTAG_OPERATER("permanent", "Permanent", "boolean", "")
//! runtextmacro TEXTTAG_OPERATER("suspended", "Suspended", "boolean", "")
//! runtextmacro TEXTTAG_OPERATER("text", "Text", "string", ", .Size")
method destroy takes nothing returns nothing
call DestroyTextTag(.tag)
call .deallocate()
endmethod
static method create takes player p returns thistype
local thistype this = thistype.allocate()
set .owner = p
if GetLocalPlayer() == .owner or .owner == null then
set .tag = CreateTextTag()
endif
return this
endmethod
endstruct
//! textmacro TEXTTAG_OPERATER takes name, Func, type, special
private $type$ $Func$
method operator $name$ takes nothing returns $type$
return $Func$
endmethod
method operator $name$= takes $type$ var returns nothing
set .$Func$ = var
if GetLocalPlayer() == .owner or .owner == null then
call SetTextTag$Func$(.tag, var $special$)
endif
endmethod
//! endtextmacro
endlibrary
Last edited: