Zinc

kingkingyyk3

Visitor (Welcome to the Jungle, Baby!)
Reaction score
216
The syntax of "scope" in Zinc is? (or use library instead scope?)

How to use double boolean expression in Zinc?
Example :
JASS:
if x > 0 and y < 0 then


Do I need to use?
JASS:
if (x>0)
{
    if (y<0)
    {
       //My script here. =)
    }
}
 

Vexorian

Why no custom sig?
Reaction score
187
why isnt this possible:

JASS:

local integer test

test += 10


@ king:

try && for and and || for or
I think I will add += , /=, *= and -= to Zinc (to be used exclusively in statements).

kingkingyyk3: Zinc requires libraries instead of scopes, it is not a big issue besides adding all the requirements you need . I know it is annoying but it is best this way, imho.
 

Xorifelse

I'd love to elaborate about discussions...........
Reaction score
87
I think I will add += , /=, *= and -= to Zinc (to be used exclusively in statements).

kingkingyyk3: Zinc requires libraries instead of scopes, it is not a big issue besides adding all the requirements you need . I know it is annoying but it is best this way, imho.
Well, if you're gonna add that.. at least add i++ / i-- to it as well.
 

kingkingyyk3

Visitor (Welcome to the Jungle, Baby!)
Reaction score
216
kingkingyyk3: Zinc requires libraries instead of scopes, it is not a big issue besides adding all the requirements you need . I know it is annoying but it is best this way, imho.

It will be trouble to my spells if I use Zinc to code them. I need to add large amount of requirements since they use many libraries.

90136796.jpg

I am working on a map, which uses Zinc. Jasshelper gave me this error just now.

This is the function which causes error.
JASS:
    public function TransmissionFromUnitByType(integer whichType, player whichPlayer, string whichTitle, string whichText, real whichDuration)
    {
        SetCinematicScene(whichType, GetPlayerColor(whichPlayer), whichTitle, whichText, whichDuration, 0.);
    }
 

Vexorian

Why no custom sig?
Reaction score
187
Are you using 0.A.0.0 ? I fixed a bug that looked like that in that version.

I need to add large amount of requirements since they use many libraries.
Yes.

The best approach to this is to just add requirements to the library as you use those functions... you could have a wrapper library that requires all your most common libraries and just require that one, I guess.
 

Vexorian

Why no custom sig?
Reaction score
187
Well, if you're gonna add that.. at least add i++ / i-- to it as well.
why?

x+=1; is ...better, ++ would make sense if I wanted pre-increment and post-increment, but since those things are only useful when used as expressions and not as statements, then there would be no point in that.

I am not even that sure I want += it is a little worthless.
 

kingkingyyk3

Visitor (Welcome to the Jungle, Baby!)
Reaction score
216
The best approach to this is to just add requirements to the library as you use those functions... you could have a wrapper library that requires all your most common libraries and just require that one, I guess.
Hmm, nice idea.

I am using 0.9.Z.5, I will update it.

Update : I have 0.A.0.0 now, but it still give me the error.

If I code the function in vJass, it does not give me any error.
 

Vexorian

Why no custom sig?
Reaction score
187
Always report crash errors in jasshelper's thread . It stops me from forgetting, I need the whole code (library included), because the function you gave me does not crash for me.
 

kingkingyyk3

Visitor (Welcome to the Jungle, Baby!)
Reaction score
216
JASS:
//! zinc
library Hashtable
{
    public hashtable Hashtable_ht = InitHashtable();
    
    //! textmacro HASHTABLE_OBJECT takes PREFIX, NAME, SOURCE, OBJECT, OBJECT2ID
    $PREFIX$ struct $NAME$
    {
    
        static method operator[]=($OBJECT$ which$OBJECT$, integer whichData)
        {
            SaveInteger(Hashtable_ht,$SOURCE$,$OBJECT2ID$(which$OBJECT$),whichData);
        }
        
        static method operator[]($OBJECT$ which$OBJECT$) -> integer
        {
            return LoadInteger(Hashtable_ht,$SOURCE$,$OBJECT2ID$(which$OBJECT$));
        }
        
        method onDestroy()
        {
            FlushChildHashtable(Hashtable_ht,$SOURCE$);
        }
        
    }
    //! endtextmacro
    
    struct Data
    {
    }
    
    public function AllocateIndex() -> integer
    {
        return Data.create();
    }
}
//! endzinc


JASS:
//! zinc
library TimerStack requires Hashtable
{
    timer Timers [];
    integer Count = 0;
    timer t;
    integer Statusz;
    
    //! runtextmacro HASHTABLE_OBJECT("private","Status","Statusz","timer","GetHandleId")
    
    function NewTimer() -> timer
    {
        if (Count > 0)
        {
            Count = Count - 1;
            t = Timers[Count + 1];
            Status[t] = 1;
            return t;
        }
        t = CreateTimer();
        Status[t] = 1;
        return t;
    }
    
    function ReleaseTimer(timer whichTimer)
    {
        PauseTimer(whichTimer);
        if (Status[whichTimer] == 1)
        {
            Count = Count + 1;
            Timers[Count] = whichTimer;
            return;
        }
    }
    
    function onInit()
    {
        Statusz = AllocateIndex();
    }
}
//! endzinc


JASS:
//! zinc
library CameraFunc
{
    player LocalPlayer;
    playercolor pc[];
    
    public function StartCinematic (player whichPlayer)
    {
        if (LocalPlayer == whichPlayer)
        {
            ShowInterface(false,bj_CINEMODE_INTERFACEFADE);
            EnableUserControl(false);
            EnableOcclusion(false);
        }
    }
    
    public function EndCinematic (player whichPlayer)
    {
        if (LocalPlayer == whichPlayer)
        {
            ShowInterface(true, bj_CINEMODE_INTERFACEFADE);
            EnableUserControl(true);
            EnableOcclusion(true);
        }
    }
    
    public function LockCameraToTarget(player whichPlayer, unit whichUnit)
    {
        if (LocalPlayer == whichPlayer)
        {
            SetCameraTargetController(whichUnit, 0., 0., false);
        }
    }
    
    public function TransmissionFromUnit(unit whichUnit, string whichTitle, string whichText, real whichDuration)
    {
        SetCinematicScene(GetUnitTypeId(whichUnit), GetPlayerColor(GetOwningPlayer(whichUnit)), whichTitle, whichText, whichDuration, 0.);
    }
    
    public function TransmissionFromUnitByType(integer whichType, player whichPlayer, string whichTitle, string whichText, real whichDuration)
    {
        SetCinematicScene(whichType, GetPlayerColor(whichPlayer), whichTitle, whichText, whichDuration, 0.);
    }
    
    public function ResetCamera(player whichPlayer)
    {
        if (LocalPlayer == whichPlayer)
        {
            ResetToGameCamera(0.);
        }
    }
    
    public function PanCamera(player whichPlayer, real x, real y)
    {
        if (LocalPlayer == whichPlayer)
        {
            PanCameraTo(x,y);
        }
    }
    
    public function IssueSelectUnit(player whichPlayer, unit whichUnit)
    {
        if (LocalPlayer == whichPlayer)
        {
            SelectUnit(whichUnit,true);
        }
    }
    
    function onInit()
    {
        LocalPlayer = GetLocalPlayer();
    }
}
//! endzinc


Jasshelper gives error when :
Hashtable + Timer Stack + Whole Camera Func including TransmissionFromUnitByType
Hashtable + Whole Camera Func including TransmissionFromUnitByType
Timer Stack + Whole Camera Func including TransmissionFromUnitByType

Does not give error :
Hashtable + Timer Stack + Whole Camera Func without TransmissionFromUnitByType
Hashtable + Whole Camera Func without TransmissionFromUnitByType
Timer Stack + Whole Camera Func without TransmissionFromUnitByType

Tested in several map, jasshelper gives same error.
 

Vexorian

Why no custom sig?
Reaction score
187
ok got it, something odd about the input line stuff becoming greater than expected,
 

Lyerae

I keep popping up on this site from time to time.
Reaction score
105
A new langauge?
What's the point? Why not just improve vJASS, instead of creating a new language?

Anyway, I don't really see any advantages behind using Zinc over vJASS, but I haven't had a chance to read the manual yet, so meh.
 

Romek

Super Moderator
Reaction score
963
> Zinc is for lazy people, like me, IMO.
No, it's not.
 

Vexorian

Why no custom sig?
Reaction score
187
A new langauge?
What's the point? Why not just improve vJASS, instead of creating a new language?

Anyway, I don't really see any advantages behind using Zinc over vJASS, but I haven't had a chance to read the manual yet, so meh.
JASS:
library InstantKill
{
    constant integer SPELL_ID = 'A000';
    function onInit()
    {
        trigger t = CreateTrigger();
        TriggerRegisterAnyUnitEventBJ(t, EVENT_UNIT_SPELL_EFFECT);
        TriggerAddCondition(t, function()->boolean {
            return SPELL_ID == GetSpellAbilityId();
        });
        TriggerAddAction(t, function() {
            KillUnit(GetSpellTargetUnit() );
        });
    }
}

Well, I can't just fix vJass without exploring first, zinc is a new ground in which I can try stuff without breaking backwards compatibility. Boa is coming soon so we are going to have 3 languages, the other idea is to give more choice for people. and when/if vJass2 comes down, we'll have 4 languages...

Anyway, I prefer Zinc right now, not because of the C syntax but because it is structured much better, implicit private and things like no scopes and the fact there are anonymous functions/methods and most importantly, while and for ... But the whole point of this is to allow people to choose what they want, so if you want to stick to vJass please do it.

Edit: PS improving vJass and creating a new language are not mutually exclusive.
 

Romek

Super Moderator
Reaction score
963
> Yes, IYO.
You use Zinc because you're lazy. That doesn't mean Zinc is made for the lazy.
Note that Zinc introduces new features; which is the reason that JASSers are switching to Zinc - Not laziness.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top