"How do I ZScript?"

Discuss all aspects of editing for ZDoom.
Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.

Re: "How do I ZScript?"

Postby gwHero » Thu Nov 09, 2017 4:59 pm

ZippeyKeys12 wrote:
Blue Shadow wrote:
ZippeyKeys12 wrote:How does one add strings together?

Check here. You might find the answer.

I tried that, maybe I'm doing something else wrong.


Several ways. With .. you can concatenate, and with string.format() strings and more.
Example with both methods:
Code: Select allExpand view
string s1 = "test";
string s2 = s1..
   string.format("%s %s", "test2", "test3");


Result:
testtest2 test3
User avatar
gwHero
 
Joined: 08 May 2017
Location: The Netherlands

Re: "How do I ZScript?"

Postby ZippeyKeys12 » Thu Nov 09, 2017 8:58 pm

Yeah I ended up using String.Format, thx

EDIT: Are there constructors for non-Actor classes?
ZippeyKeys12
 
Joined: 15 Jun 2016

Re: "How do I ZScript?"

Postby Nash » Fri Nov 10, 2017 4:11 am

ZippeyKeys12 wrote:
EDIT: Are there constructors for non-Actor classes?


Not yet...
User avatar
Nash
Nash Muhandes [Audio Engineer | Game Designer | Scripting]
 
 
 
Joined: 27 Oct 2003
Location: Kuala Lumpur, Malaysia

Re: "How do I ZScript?"

Postby ZippeyKeys12 » Fri Nov 10, 2017 2:04 pm

Nash wrote:
ZippeyKeys12 wrote:
EDIT: Are there constructors for non-Actor classes?


Not yet...


I saw that, but it was several months ago so I thought mayb they were here :cry: 😩 :cry:

And also plz, somebody 🙏, can one register eventhandlers from ZScript rather than MAPINFO

EDIT 2: Why can't I return null for a String function? How would I do that?
EDIT 3: Also, when I try replacing \n in a string, if \n is inside a const array it won't work
i.e
Spoiler: Example Code

Seems like backslash expressions lose their meaning in a constant array. Should I file a bug report or is there something I'm missing?
I'm really tired right now :shock:
Weird that there were no errors from having no commas in the array, though. :?

EDIT 4: Is there a way to evaluate a string as a math expression, i.e: "100/3+4"
ZippeyKeys12
 
Joined: 15 Jun 2016

Re: "How do I ZScript?"

Postby Uberkreatur » Mon Nov 13, 2017 7:27 am

Zscript is still documented not enough.
1. What is the difference between MonsterMove() and TryWalk()?
2. MonsterMove() and TryWalk() works like A_Chase with CHF_DONTTURN flag. If monster changes angle, it continues to move in the original direction. How to set this direction?
Uberkreatur
 
Joined: 26 Dec 2014
Location: Russia

Re: "How do I ZScript?"

Postby Apeirogon » Tue Nov 14, 2017 2:19 pm

How work with DoEffect?
I want item that take every half of second one plasma cell and give at whole seond one point of health, to maximum health. How make it?
Apeirogon
I have a strange sense of humour
 
Joined: 12 Jun 2017

Re: "How do I ZScript?"

Postby dodopod » Tue Nov 14, 2017 3:34 pm

Uberkreatur wrote:Zscript is still documented not enough.
1. What is the difference between MonsterMove() and TryWalk()?
2. MonsterMove() and TryWalk() works like A_Chase with CHF_DONTTURN flag. If monster changes angle, it continues to move in the original direction. How to set this direction?


  1. I'm not an expert on this, but I believe that MonsterMove() just tries to move an actor in its current direction (movedir). It returns true if the actor is able to move, and false it it's blocked. If you look in gzdoom.pk3, you'll see that TryWalk is defined as

    Code: Select allExpand view
    bool TryWalk ()
    {
        if (!MonsterMove ())
        {
            return false;
        }
        movecount = random[TryWalk]() & 15; // Sets movecount to a random number less than 16
        return true;
    }


    movecount is a countdown used by A_Chase. When it reaches 0, the actor either attacks, or if it can't, it randomly changes direction.
  2. Here's roughly what A_Chase did in the original Doom source code (translated into ZScript):

    Code: Select allExpand view
    if (--movecount < 0 || !MonsterMove())
    {
        NewChaseDir();
    }


    NewChaseDir(), in turn, calls TryWalk(), which resets movecount.
dodopod
 
Joined: 04 Oct 2017

Re: "How do I ZScript?"

Postby gwHero » Thu Nov 16, 2017 8:29 pm

Does somebody know how to clear a midtexture from a linedef with ZScript?
I have some midtexture lights on several linedefs. Now switching the lights on works as follows:

Code: Select allExpand view
TextureId textlight = TexMan.CheckForTexture ("ZLIGHTLM", TexMan.Type_Any);
int linenum = 0;   
int LightLineTag = 666;
LineIdIterator lit = LineIdIterator.Create(LightLineTag);         
while ((linenum = lit.Next()) >= 0)         
{   
   level.lines[linenum].sidedef[1].SetTexture(1, textlight); // sidedef[1] = back
}

But I don't know how to switch them off.

[EDIT] Found it: (just similar to the hack commonly used in ACS SetLineTexture with "-"):
assigning the TextureId like this before using the SetTexture:
Code: Select allExpand view
TextureId textlight = TexMan.CheckForTexture ("-", TexMan.Type_Any);
User avatar
gwHero
 
Joined: 08 May 2017
Location: The Netherlands

Previous

Return to Editing

Who is online

Users browsing this forum: crowbars82, phantombeta, zrrion the insect and 2 guests