ZZT-OOP questions

NOTE: I HATE A LOT OF YOUR ZZT GAMES, SO WATCH OUT!

Moderators: Commodore, Zenith Nadir

User avatar
meldels
Ordinery
Posts: 43
Joined: Thu Aug 09, 2012 7:04 pm
Location: VOILA

ZZT-OOP questions

Post by meldels »

Is there somewhere I can go to find out what the basic commands for coding in ZZT are? If not, would someone be willing to possibly walk me through a few simple things that I'd like to make.

EDIT: Is it possible for an admin to delete or merge the other threads with this one, or something similar?
Last edited by meldels on Mon Aug 13, 2012 6:33 pm, edited 1 time in total.
User avatar
Quantum P.
Level 17 Accordion Thief
Posts: 1433
Joined: Fri Sep 12, 2003 1:41 am
Location: Edmonds, WA
Contact:

Re: Basic commands?

Post by Quantum P. »

Here's an online manual for the ZZT-OOP programming language. It's got a short tutorial and a reference.

You can get a similar manual from ZZT itself, by pressing H from inside the editor.

If there's anything in particular that you'd like to make, let us know, and we'll give you any programming advice you need.
User avatar
meldels
Ordinery
Posts: 43
Joined: Thu Aug 09, 2012 7:04 pm
Location: VOILA

Re: Basic commands?

Post by meldels »

Thanks a lot. Also is ZZT case sensitive, ever?

off-topic: Just wanted to say, so far this community has been much more helpful than I expected based on what the "suvival guide" thread says.


EDIT: I'd like to point out a mistake I found in the tutorial,

It says this:

Code: Select all

@Lefty          ' This object's name
/e/e/e/e        ' Move east 4 times
/w/w/w/w        ' Move west 4 times
#send Righty Do ' Send the "Do" message to the object named "Righty"
#end            ' and halt.
When I believe there should be a colon after "Righty". I've tested it.
User avatar
Saxxon
the Gargoyle.
Posts: 608
Joined: Tue Jul 25, 2006 10:02 am
Contact:

Re: Basic commands?

Post by Saxxon »

ZZT is not case sensitive.

Also, good catch on the tutorial.
User avatar
meldels
Ordinery
Posts: 43
Joined: Thu Aug 09, 2012 7:04 pm
Location: VOILA

Re: Basic commands?

Post by meldels »

Could someone tell me what's wrong with my code here?

Code: Select all

:LOOP
/i
#IF NOT BLOCKED SEEK IF ALLIGNED DO
#SEND:LOOP
#END

:DO
YOUAREALLIGNED2ME
/i/i/i/i/i
#SEND:LOOP
#END

:TOUCH
#PUT NORTH GREEN FAKE
#BECOME GREEN FAKE
#END
What I want the object to do is speak when nothing is between the player and the object, and if touched disappear.
User avatar
Schroedingers Cat
We must invent teleportation!
Posts: 721
Joined: Mon Jun 19, 2006 11:35 pm
Location: Idaho, Wisconsin

Re: Basic commands?

Post by Schroedingers Cat »

meldels wrote:Could someone tell me what's wrong with my code here?
You need to put another pound sign (#) before the second IF command.
Also:
:LOOP 'it is not necessary to name this as "loop", just FYI
/i 'personal preference of mine would be to put this after the #if command so that the #if is executed as soon as possible
#IF NOT BLOCKED SEEK IF ALLIGNED DO 'as noted above, the second "if" should be "#if"
#SEND:LOOP 'the word send is entirely unnecessary. "#loop" works identically, and uses less memory
#END 'this line is never seen, so remove it to save space

:DO
YOUAREALLIGNED2ME
/i/i/i/i/i
#SEND:LOOP 'again, #loop is preferred
#END 'never seen, etc

:TOUCH
#PUT NORTH GREEN FAKE
#BECOME GREEN FAKE
#END 'also, never seen since the code ends once the object #DIEs or #BECOMEs something.
SUGGESTED CODE:

Code: Select all

:LOOP
#IF NOT BLOCKED SEEK #IF ALLIGNED DO
/i
#LOOP

:DO
YOUAREALLIGNED2ME
/i/i/i/i/i
#LOOP

:TOUCH
#PUT NORTH GREEN FAKE
#BECOME GREEN FAKE
Also, since there's nothing above :loop that you'd care about, #restart would also work.
If you wanted to execute the code faster, you could add "#CYCLE 1" (the default is 3) near the top, after the object name (which is not present on this object, so the first line is fine).
User avatar
meldels
Ordinery
Posts: 43
Joined: Thu Aug 09, 2012 7:04 pm
Location: VOILA

Re: Basic commands?

Post by meldels »

Thanks, that's really helpful, also; How long is an "/i"? Why is "RESTART" and "CYCLE" quicker and what exactly does "CYCLE" do? Also can you do "#IF BLOCKED W DO" or "#IF BLOCKED WEST DO"?

EDIT: I'd like to ask this as well; How many units(don't know what it would be in this case.) does any thing(don't know what to call non-objects, those are what I mean.) take? And how do I delete boards?

EDIT II: Is there any such command as "WAIT UNTIL MESSAGE ENDS" or "WAIT UNTIL PREVIOUS CODE SNIPPET ENDS" rather than guessing how many '/i's a flashing message is worth? And can you send player commands via objects? "SEND PLAYER SHOOT" etc
User avatar
Commodore
fgsdfs
Posts: 2471
Joined: Wed Mar 12, 2003 5:44 pm
Location: :noitacoL
Contact:

Re: Basic commands?

Post by Commodore »

all the movement commands (including /i) have a delay determined with the cycle command. Cycle 1 is the fastest, and it gets slower as you increase the cycle. You should almost always use #cycle 1, because it gives the best response time. Without using #cycle 1 the player can actually run past #if alligned conditions.

If you are not already, you should be using kevedit. With kevedit you can set the cycle of an object without having use the actual command. http://kevedit.sourceforge.net/download.html

You cannot delete boards in the built-in editor. Again kevedit.

I am not sure what you mean by units. There can only be 150 "objects" on the board, that includes custom objects, built-in enemies, and even things like bullets.

Flashing messages: You have fiddle with idles. Another good reason to avoid using flashing messages too much. If you have a lot to write, use the text box, people can proceed at their own speed.

unfortunately the player can not be influenced like that by objects.

Also check out this: http://zzt.org/zgames/z/zeol.zip
*POW* *CLANK* *PING*
User avatar
meldels
Ordinery
Posts: 43
Joined: Thu Aug 09, 2012 7:04 pm
Location: VOILA

Re: Basic commands?

Post by meldels »

That's exactly what I wanted to know, and yes that's what I meant by units/creatures etc. Also, is there a limit to how much text, or, how many lines of code an object can have? And does Cycle 3 save on anything?

I was going to make an object that is just a timer for certain things to happen, no collisions or anything with the player. Would cycle 3 save on '/i's? Meaning, in cycle 1 I may have to use '/i/i/i/i/i/i' but, with cycle 3 I can get the same speed with fewer, '/i/i/i'. And the object I was talking about before is actually at the bottom of the screen AND it uses a fair amount of '/i's. Because of that the player really can't run past, so I could use cycle 3 to save on '/i's right? And secondly is it possible to "#IF ALLIGNED /n DO" or something similar as in "If I am alligned from an origin one space north, then do" or "IF ALLIGNED MONSTER1 DO" as in "If MONSTER1 is alligned with player" that way in a loop I could do "#IF ALLIGNED MONSTER1 DO#IF ALLIGNED MONSTER2 DO2#IF ALLIGNED MONSTER3. . ." ?

And as for kevedit, I'm willing to try it and see what it's like but I like to stay away from other editors, I want to do everything from scratch in the most efficient way possible.
User avatar
Commodore
fgsdfs
Posts: 2471
Joined: Wed Mar 12, 2003 5:44 pm
Location: :noitacoL
Contact:

Re: Basic commands?

Post by Commodore »

meldels wrote:Also, is there a limit to how much text, or, how many lines of code an object can have?
No, there is a ~14k limit to the overall size of one board. Most of that size is code, but an object can have any amount of code within the limits of the board.
meldels wrote:Would cycle 3 save on '/i's? Meaning, in cycle 1 I may have to use '/i/i/i/i/i/i' but, with cycle 3 I can get the same speed with fewer, '/i/i/i'.
Exactly right.
meldels wrote:And the object I was talking about before is actually at the bottom of the screen AND it uses a fair amount of '/i's. Because of that the player really can't run past, so I could use cycle 3 to save on '/i's right?
Probably, you'll find out with only a little testing.
meldels wrote: And secondly is it possible to "#IF ALLIGNED /n DO" or something similar as in "If I am alligned from an origin one space north
Alligned only works on the object that is calling it and it only detects the player. For more fancy things you have to use two, one that checks horizontal, and one that checks vertical.
meldels wrote: And as for kevedit, I'm willing to try it and see what it's like but I like to stay away from other editors, I want to do everything from scratch in the most efficient way possible.
Traditionally using the default editor you import a toolkit (or a board of STK) to get extra colors/weird items:
STK - http://zzt.org/zgames/p/PureSTK.zip
Toolkits - http://zzt.org/zgames/z/zfiles251.zip
*POW* *CLANK* *PING*
User avatar
Schroedingers Cat
We must invent teleportation!
Posts: 721
Joined: Mon Jun 19, 2006 11:35 pm
Location: Idaho, Wisconsin

Re: Basic commands?

Post by Schroedingers Cat »

Commodore wrote: You cannot delete boards in the built-in editor. Again kevedit.
To clarify, you can clear a board of most of its information, but the board is still present unless you use KevEdit to delete it. In other words, if you have a 15 board game, and you decide to delete a board, in the original editor, the board count will still be 15. Of course, if there are no passages to the board, then as far as the play is concerned, the board might as well not exist.

Also, there is no harm in setting the #cycle repeatedly. That is

Code: Select all

#cycle 1
#if alligned do
/i#restart
will set the cycle to 1 multiple times, but it will have no effect on the programming.
meldels wrote:Also can you do "#IF BLOCKED W DO" or "#IF BLOCKED WEST DO"?
That is correct. That former is preferable, since it uses less memory and allows more code per line. Something like

Code: Select all

#if not blocked w #if not blocked e do
might not fit onto one line otherwise.
User avatar
meldels
Ordinery
Posts: 43
Joined: Thu Aug 09, 2012 7:04 pm
Location: VOILA

Re: Basic commands?

Post by meldels »

When you say "uses less memory" you mean takes less time to do, or takes less 'space'? And what's the relation of space usage by text to that of objects and already programmed objects? Also could someone explain what STK actually is, or how it came to be?


On a side note: Is it alright to post/make new topics as much as I have been? I was reading some past topics that might mean otherwise.
User avatar
Schroedingers Cat
We must invent teleportation!
Posts: 721
Joined: Mon Jun 19, 2006 11:35 pm
Location: Idaho, Wisconsin

Re: Basic commands?

Post by Schroedingers Cat »

Board memory -- space. ~14k

Certain objects and most prefab enemies use up memory (though I do not know off-hand how much per), which is why there are "stat-less objects", which are great if you want to have a bunch of smiley faces with no code (stat-less objects do not have any ZZT-OOP code). I do know that the more programming an object has, the more memory is used.

If you haven't noticed, the forums are a little bit slow. I don't think anyone minds multiple threads, but since the two are so closely related, it might be better to rename one to "ZZT-OOP QUESTIONS" and make new threads if they aren't related to using the editor, like a new thread for a game you're working on.

I am personally thrilled to have as much activity on the fora as we have these past couple of days.
User avatar
Commodore
fgsdfs
Posts: 2471
Joined: Wed Mar 12, 2003 5:44 pm
Location: :noitacoL
Contact:

Re: ZZT-OOP questions

Post by Commodore »

each character of code is a byte. Carriage return characters count too, and you can follow up movements with a command to save that byte.
for example:

/i/i/i#restart

this line is a byte shorter than if a new line character came after /i/i/i (two lines)

It's sort of hard to run into the memory barrier unless you are really jamming lots of code in there. Shaving off bytes like this is not that important unless you are planning something big or have lots of copies of many objects (in which case you should consider using #bind)
*POW* *CLANK* *PING*
User avatar
Saxxon
the Gargoyle.
Posts: 608
Joined: Tue Jul 25, 2006 10:02 am
Contact:

Re: Basic commands?

Post by Saxxon »

It sounds like you are very interested in some of the more intricate workings of the engine:

* A stat object is a tile with special properties. In ZZT, each stat object takes 33 bytes, and you get a total of 151 per board, one of which is the player. Code takes up space 1:1, it is not compressed or tokenized, and a newline is 1 byte.

* Board tiles are encoded horizontally, so if you want to save space, use longer runs of similar horizontal tiles (same color and element).

* ZZT has multiple methods of sending messages. #SEND TARGET:LABEL works the same as #TARGET:LABEL. #RESTART is a built-in label but you can save space in a really extreme manner by using a 1-character label like :R and using #R.

* Up to 33 commands can be executed at a time. The things that suspend execution are idling, movement, shooting, throwing stars. Displaying a scroll does not suspend code execution- in fact, when the player chooses a hyperlink, this counter resets.

* It is only necessary to use # at the very beginning of a line to mark it as a command. #IF BLOCKED N PUT N EMPTY is a perfectly valid command.

* The / and ? prefixes work an interesting way: they will read directions until it finds a "definite" direction. So you can actually do /RNDP OPP SEEK.

* THEN exists, but it doesn't actually do anything but increase readability of code.

* The CYCLE command determines how many ticks an object will wait for between processing code. #CYCLE 1 executes code on every tick. #CYCLE 2, every other. However, when an object is executed is directly related to the index of the object: if objects are deleted, it's possible the wait may vary. Cycles higher than 1 will be staggered, so multiple objects with a cycle of 3, for example, will move on all different ticks.
Post Reply