Open Zelda Help

Quick Links: Website - Forums

Main
Thanks to

Everyone who have help out with creating this.

How you can to Help

Post comments on the website help section, this can include code examples. Comment on the usable of this Help file on the forums

How to use this with Quest Designer 2.0.4

Copy this file into "Quest Designer 2.0.4\editor\helps". Start Code-Genie and change the active help file at Help->Active Help to this file. When you press F1 during editing, the currently edited word will be automatically looked up in the active help file.

Donate to Open Zelda

Help out the developers and donate to Open Zelda via Sourceforge

Last Updated: Thursday, 12 August 2004 (release 4)


F.A.Q. Index

Main » F.A.Q.
  • Open Zelda Questions
  • Quest Designer Questions
  • Miscellaneous Questions
  • Improvement Questions
  • Common Problems


F.A.Q. : Common Problems

Main » F.A.Q. (Online Version)
Open Zelda can't find D3D8.DLL? KERNEL32.DLL is missing "IsProcessorFeaturePresent" feature?
You must have DirectX 8.1 or higher to run Open Zelda.
Open Zelda keeps crashes on startup when testing a quest.
The most like cause is that of a scripting error that has got past the compiler like sending the wrong type of argument via a CallFuntion(). Check the scripts you have edited after you last test.
Sometime Audio could be the problem, so try testing without sound, you can turn it off in Quest Properties.

Lastly OZ6 doesn't handle quests with alot of content, like having too many entities would cause the save system not to function.
Quest Won't Load?
First, make sure you computer meet the requirements (Simple System Info Tool). Also make sure you have enough free hard drive space, size of the quest just to play, and each save game takes up size of the quest again (rough guesses).

If it still does work, start a new thread on the Help Forum and post the content of ErrorChk.txt file and your system information.
Why doesn't Open Zelda work for me? Why doesn't Quest Designer work for me?
Try the following things first:
  1. Make sure your computer meet the requirements
  2. Update all drivers
  3. Extracted all the compressed files from the Zip file before running the program.
Quest Designer has some extra steps
  4. Set the screen color depth to 16bit colors.
  5. Set your mouse cursors to the default ones.
  6. Don't run a alpha/beta version.

If it still doesn't work start a new thread on the OZ Help Forum and post the ErrorChk.txt file and your system settings.


F.A.Q. : Improvement Questions

Main » F.A.Q. (Online Version)
What have people already suggested for improvements?
Improvements can be post straight to sourceforge feature request list, but we suggest you discussion it on the forums first.
Will OZ have Online Play/Multi Play?
It's on the drawing board.
Will OZ support custom keybindings?
Yes, in the near future...
Will OZ support mouse/gamepad?
OZ will soon have gamepad support (In the meanwhile try JoyToKey ). Mouse support will have to wait for a long while.
Will OZ support MP3/OGG/WMA?
No, because an MP3/OGG/WMA file is too large for long music tracks and uses a lot of CPU power for playback. OZ is capable of using ".it" files for music (it can also use MOD and MIDI although they're not recommended) and small low quality "*.wav" files for sound effects. Note: OZ does use FMOD which support MP3/OGG/WMA and handfull of other formats, OZ will not be able to use them.
Will OZ/QD support layers?
Not yet, but it hopefully will in the future. Layers are useful for bridges and other thing you can walk over and under.
Will QD support sprite rotation/flipping/mirroring?
32 bit graphics are good for different alpha values. Although useful (saving you the trouble of having to do a sprite for each direction), rotating sprites will not be supported for a long time since they would require too many code changes (rotation by scripts works though).
The New Quest Designer does have these but still in beta phase


F.A.Q. : Miscellaneous Questions

Main » F.A.Q. (Online Version)
What is this FAQ?
FAQ stands for Frequently Asked Questions. They are commonly asked questions concerning anything related to Open Zelda (like websites, forum, game and editor).
Can I convert wav/mp3/ogg/wma to it/midi/mod?
Short answer is not really.
while they are some programs that will convert them, it's not the recommend unless your comfortable with editing MIDI.
How do you post a question in the forums?
If you have a question read through the whole FAQ first. If the answer isn't here, post the question in Open Zelda Help forum. Please have a topic that's related to the question. A topic like "How does the 'something' work?" is much more helpful than "Help please!". Include as much detail as you can on what you want to know, include your computer specification (like graphic card and OS), include any code you have written (see next question).
How do you post script code in the forums?
Use the BB code: [php] text [/php] , so it includes all the spaces and use a monospace font type, and highlights the code . Be sure you remove the smilies in that post, so ');' will not become a smiley. For this site, you use change code with script
How to best take a screen shot and save it?
Use Alt + Print Screen (for a windows SS only) and paste into a Image Program (Try PSP). In PSP, you can select Export > PNG Optimizer to save it in the best format.
How to find out what version of DirectX is running? How to enable Direct3D? I got the latest version of DirectX and Direct3D is enabled, but OZ still doesn't work?
Bring up the run dialog (start -> run ) type "DxDiag". Main Window. If DirectX Version isn't DirectX 8.1 or higher, you need to download a newer version. Display Window. Check to see if Direct3D is enabled, if not enable it. If OZ still doesn't run, try testing Direct3D. If all else fails, "Save All Information" and post the text file on the OZ forum.
Is there any chat channel?
Yes, the Official Open Zelda channel is located on the initialized.org. If you have any questions or want to talk about OZ, join the channel. You should stay around for more than half an hour if you expect an answer from me (if I'm busy); I can't be active ALL the time. For common info type &info in the channel. Zelda is a bot and he will protect the channel and set correct status on every member.
IRC Detail
Server: irc.initialized.org
Port: 6667
Channel: #oz
mIRC & Chatzilla Users can goto irc://irc.initialized.org/oz. Web based version at Gaming Universe.
Newbie?
So your a newbie and your wondering what to do? First off the frontpage has latest (3) file listed right under the header, so download them and make sure you have read the Known Bugs. Second, download & read Pikachu19192 Tutorial & QD for Dummies V1.2. By now you should know the basics, if you get stuck, read through other entities or join the forum and ask some questions.
Some dates seem to be wrong. Why don't you change them? What time zone do you use?
We are using the standard European date system (yyyy-mm-dd). Years>Month>Days>Hours>Minutes>Seconds is more logical than using the US system since it's a descending scale. Since Open Zelda come from all around the world, it's better to state all time in GMT.
What emulators and ROMs?
An emulator is a program simulating another system, so programs/games made from them can be run. A game from another system is usually called ROM (Read Only Memory, the way they where stored before). Emulators and ROMs are usually illegal. Links to ROMs will not be discussed because that's not allowed in GU. SNES9X and ZSNES are emulators to SNES.
What have people already suggested for improvements?
Improvements can be post straight to sourceforge feature request list, but we suggest you discussion it on the forums first.
What is a Quest?
It's a story/mission in OZ. Everyone with a few skills can do a quest with the editor; you don't need to make new entity scripts and graphics.
What is FPS?
Frames Per Second, which is how fast the program/screen is updated (the higher the better). Having a higher FPS than your screen sync (usually between 60-100) will not improve the smoothness. You can choose to show FPS in the OZ Options menu. You probably need a computer upgrade if you get less than 30 FPS on the default quest.
What is GU? What are the rules in GU? What is AGN?
GU is the Gaming Universe. The rules are listed in this thread and they are also used in the Open Zelda sections. Remember the don't double post if its less then 24 hours between the posts, use edit post instead. AGN was home to the old OpenZelda forums
What is IRC?
IRC stands for Internet Relay Chat. It is a faster way to chat (compared to the forums and ICQ) - especially when several people are online at the same time. mIRC and Gaim are some examples of good IRC clients.
What is Paint Shop Pro? What useful tools does it have?
Paint Shop Pro (PSP) is a very good paint program, useful for making new/change sprites. It's much better than the old "Microsoft Paint". When making sprites it can be nice to use a grid of size 4 or 8. First go to View - Grid and Change Grid then set Grid Spacing to 8 or 4. When changing color scheme on sprites the Color Replacer tool can be really useful. When showing a picture on the web it's good to have the file size as small as possible. Choose File-Export-PNG Optimizer and then Palette-Based and Optimized Octree for optimum file size. PNG is much better picture file type than JPEG when showing SS (but not for photos).
What is Zelda World?
Zelda World is a chat program programmed by GD (and another person that made the network code). It was meant to be the next OZ version at first but only one map was made (which is the same one as 5.00). It allows you to walk around, go into buildings and chat. It can be a useful program when you need some way (besides the forum or IRC) to communicate. If anyone wants to host/serv please state GMT time and IP at least one day before, so that more people have enough time to see it. The project is long dead and the source will not be released.
Who is GD?
GD was the original OZ's programmer. In January 2003, he GPL both OpenZelda and Quest Designer.


F.A.Q. : Open Zelda Questions

Main » F.A.Q. (Online Version)
When is the next version going to come out?
When it's ready.
But at last status update, Kronuz (aka the head programmer) mention June/July as possible release for a stable version.
How do I distribute my Quest as an executable?
You can't. But you could rename the quest to default.qst and place in the quests directory, and it would be loaded at startup. A program called ResHack can be use to change the icon and remove "Load Quest" from the menu.
Anything more I should know about OZ and QD?
It's coded in C++ using the DirectX library (hence only for Windows). The scripting is in Small ( pdf ), a language that's similar to C (hence not object oriented). The program Code-Genie is used for writing scripts.
Can I convert wav/mp3/ogg/wma to it/midi/mod?
Short answer is not really.
while they are some programs that will convert them, it's not the recommend unless your comfortable with editing MIDI.
Newbie?
So your a newbie and your wondering what to do? First off the frontpage has latest (3) file listed right under the header, so download them and make sure you have read the Known Bugs. Second, download & read Pikachu19192 Tutorial & QD for Dummies V1.2. By now you should know the basics, if you get stuck, read through other entities or join the forum and ask some questions.
What have people already suggested for improvements?
Improvements can be post straight to sourceforge feature request list, but we suggest you discussion it on the forums first.
What is a Parameter
Parameter is the charater that replaces # in the entity's name. example, if a sprite called "_guardb", it would run "_guard#.zes" and have a parameter of "b"
What is Open Zelda?
Open Zelda (OZ for Short) is a game engine. Its main purpose is to play Zelda 3 (Z3) like games (called quests). It has much more potential then Zelda Classic since it's capable of doing almost anything. It can even do total conversions - games completely different from Zelda. The OZ editor is called Quest Designer.
What is the current version? When will the next version be out? How old are OZ?
The most recent beta version of Open Zelda is v6.2.4 (2002-07-31), and the Quest Designer is v2.0.4 (2002-07-29) (Note: QD 2.1 is a older version). The release date of the next beta is unknown. OZ 6 is a few years old and the whole project started a couple of years ago.
Why doesn't Open Zelda work for me? Why doesn't Quest Designer work for me?
Try the following things first:
  1. Make sure your computer meet the requirements
  2. Update all drivers
  3. Extracted all the compressed files from the Zip file before running the program.
Quest Designer has some extra steps
  4. Set the screen color depth to 16bit colors.
  5. Set your mouse cursors to the default ones.
  6. Don't run a alpha/beta version.

If it still doesn't work start a new thread on the OZ Help Forum and post the ErrorChk.txt file and your system settings.
Why is a 3D graphics card needed? Why is DirectX 8.1 Needed?
OZ is actually a 2D plane in a 3D view. OZ now has hardware support, like alpha blending, rotations, and lights effects. Software-only is not supported because even the fastest processor would only get a couple of FPS. OZ used DirectX 8.1 because it is about 10% faster then 8.0.


F.A.Q. : Quest Designer Questions

Main » F.A.Q. (Online Version)
When is the next version going to come out?
When it's ready.
But at last status update, Kronuz (aka the head programmer) mention June/July as possible release for a stable version.
Anything more I should know about OZ and QD?
It's coded in C++ using the DirectX library (hence only for Windows). The scripting is in Small ( pdf ), a language that's similar to C (hence not object oriented). The program Code-Genie is used for writing scripts.
Can I convert wav/mp3/ogg/wma to it/midi/mod?
Short answer is not really.
while they are some programs that will convert them, it's not the recommend unless your comfortable with editing MIDI.
How do you add new music to a quest? How do you change the default music of a group?
First you must move the music file (preferably IT) to the sounds folder in the QD folder. Then select Sound Manager in the Quest Resources menu in the QD. After that, right click on the Music folder and select Add File to Folder . Now choose IT file type and select the music file and click Open. To change the default music of a group, select a screen on the map and choose Edit Group . Then select the Group's Music from the list.
How do you add new sprite to a quest?
First you must move the BMP and SPT (if include) files to the sprite sheet directory. In QD, select Quest Resources > Graphic Manager. To add an alreadly made sprite sheet right click on folder you want to add it to (note: "Sprite Sheet in Project:" is the root folder). If a SPT wasn't include you click on the "Create New" button.
How do you set the start location? How do the 'world coordinates' work?
Go to the QD menu, find Options->Quest Properties there's a Player Starting Position section there. The coordinates have to be in world coordinates. To get these, just edit the screen you want the player to start on, put the cursor where he should start and the coordinates should be given on the right of the screen. Every screen is 320x240 pixels. World coordinates are relative to the upper-left hand corner of the map - the counting starts on screen (0, 0) and every screen east and south you add 320 and 240. Example: in middle of (2, 3) the world coordinate is: (2.5*320, 3.5*240) = (800, 840).
Newbie?
So your a newbie and your wondering what to do? First off the frontpage has latest (3) file listed right under the header, so download them and make sure you have read the Known Bugs. Second, download & read Pikachu19192 Tutorial & QD for Dummies V1.2. By now you should know the basics, if you get stuck, read through other entities or join the forum and ask some questions.
What are the H1 and H2 fills for?
These represents holes, red H1 are normal holes, green h2 allow player to fall to a lower level.
The green h2 holes lower level can be set via scripting with SetLowerLevel
What have people already suggested for improvements?
Improvements can be post straight to sourceforge feature request list, but we suggest you discussion it on the forums first.
What is a mask/standard mask? What do the red value mean in masks?
Masks tell how a sprite behaves. A mask is made just like a normal sprite but it uses the red value which have a certain meaning and affect the gameplay. For example, at 0 it's impassable, and while at other value it could slows down everything passing it. A standard mask is a mask that is used in many sprite sheets - to minimize memory usage. Standard masks have a maximum size of 32x32 pixels. Because of this, sprites will seldom be larger (except on maps and other large pictures).
Standards Mask are name [Width]x[height]x[Value]. ex. 24x24x8

Red Values:
Most entities class solids as less then 129
0 | Solid
8 | Solid but item can be thrown over it
224 | Breaks thrown Items (use in door masks)
232 | Slow player down by 40
if you're running a latest version of the player script you also have
16 | leap north
24 | leap east
32 | leap south
40 | leap west
192 | Shallow Water
208 | Deep Water
216 | Ice
248 | Diggable grass
What is a Parameter
Parameter is the charater that replaces # in the entity's name. example, if a sprite called "_guardb", it would run "_guard#.zes" and have a parameter of "b"
What is a sprite?
A sprite is a picture of a thing - usually with transparency so it's not always square like. AnimGet will make it easy to take every frame of an animation and Hyrule Magic can be useful for making large maps from Z3. Strider has made complete OverWorld map of Z3 that can be useful.
What is Quest Designer?
Quest Designer (QD) is an editor for OZ where you can re-use/make maps and scripts. The QD needs graphics (sprite sheets), sound effects (*.wav), and music (*.it). It is easy to make maps and some simple scripts, but making new things and understanding how they behave (entity scripting) is a much harder task. Previous C programming can be helpful, but it's not a requirement.
Why are there opening so many DOS windows?
A command line window will open for every script that have been changed and needs to be complied. Do not try to close them, they will close when finished.
Why doesn't Open Zelda work for me? Why doesn't Quest Designer work for me?
Try the following things first:
  1. Make sure your computer meet the requirements
  2. Update all drivers
  3. Extracted all the compressed files from the Zip file before running the program.
Quest Designer has some extra steps
  4. Set the screen color depth to 16bit colors.
  5. Set your mouse cursors to the default ones.
  6. Don't run a alpha/beta version.

If it still doesn't work start a new thread on the OZ Help Forum and post the ErrorChk.txt file and your system settings.


Functions Index

Main » Scripting Functions
  • Animation
    Function in animation.inc
  • Counter
    Function in counter.inc
  • Entity
    Function in entity.inc
  • Float
    Function in float.inc
  • General
    Function in general.inc
  • Core
    Function in core.inc


Animation

Main » Scripting Functions » animation.inc

Script must have #include <animation> at the top when using these functions

AddAnimframe
Add a frame to animation ident[], x and y are displacement variables used if the sprite is misplaced or of different size along with similar things, code[] is the name of the sprite.
CreateAnim
Create an animation available to the current script file. "speed" is counted in frames per second.
CreateAnimWithID
Create a global animation available in all script files after creation. (speed is counted in FPS)
DeleteAnim
Delete the animation ident[].
DrawAnim
Draw the animation at x & y(world coordinates). Depth is the position from bottom (0) to top (***) on the current layer (the animation is drawn above anything on a lower depth). Red, green, blue and alpha, along with rotation and scale can also be set.
DrawAnimNoInc
Same as DrawAnim, but this version does not increase the current frame, the frame stays at the same place until increased by other means.
FinishedAnim
Returns true if the animation is at it's last frame
GetAnimCount
returns the current animation frame.
GetAnimHeight
Return the height of the current sprite in the animation.
GetAnimImage
Gets Image from the current frame of animation.
GetAnimWidth
Return the width of the current sprite in the animation.
GetMaxAnim
Return the value for the last animation frame in the animation.
IncrementAnim
Increment the current animation frame by 1.
SetAnimCount
Set the current animation frame to "val".
SetAnimDirection
Set the direction of the animation ident[]. (1 is forward, -1 is backwards)
SetAnimLoop
Set true or false, if the animation should loop, or stop at the last frame.
SetAnimSpeed
Set the speed of animation ident[] to "speed". (speed is counted in FPS)


AddAnimframe

AddAnimframe(ident[], x, y, code[]);

Main » Scripting Functions » animation.inc (Online Version)

Add a frame to animation ident[], x and y are displacement variables used if the sprite is misplaced or of different size along with similar things, code[] is the name of the sprite.
This is used with both CreateAnim AND CreateAnimWithID.

Code/Example

CreateAnimWithID(16, "animthing");

AddAnimframe("animthing", 0, 0 , "sprite01");
AddAnimframe("animthing", 7, -2, "sprite02");


CreateAnim

CreateAnim(speed, ident[]);

Main » Scripting Functions » animation.inc (Online Version)

Create an animation available to the current script file. "speed" is counted in frames per second. Useful for entities, normal static animations are created directly on the spritesheets.

Code/Example

new horse[20]; //creates a variable called horse to store the animation identifier
CreateAnim(16, horse); //creates an animation called horse


CreateAnimWithID

CreateAnimWithID(speed, ident[]);

Main » Scripting Functions » animation.inc (Online Version)

Create a global animation available in all script files after creation. (speed is counted in FPS)
An animation with the same identity CANNOT be created in another entity.

Code/Example

CreateAnimWithID(16, "deathanim");


DeleteAnim

DeleteAnim(ident[]);

Main » Scripting Functions » animation.inc (Online Version)

Delete the animation ident[].
Any tries to delete a non-existing animation is just ignored.

Code/Example

DeleteAnim("someanimation");


DrawAnim

DrawAnim(ident[], x, y, depth, layer = 0, r = 255, g = 255, b = 255, a = 255, rot = 0, scale = 100);

Main » Scripting Functions » animation.inc (Online Version)

Draw the animation at x & y(world coordinates). Depth is the position from bottom (0) to top (***) on the current layer (the animation is drawn above anything on a lower depth). Red, green, blue and alpha, along with rotation and scale can also be set.

Code/Example

DrawAnim("someanim", 3299, 1704, 0); //Any values that are pre-set can be left out if unchanged.


DrawAnimNoInc

DrawAnimNoInc(ident[], x, y, depth, layer = 0, r = 255, g = 255, b = 255, a = 255, rot = 0, scale = 100);

Main » Scripting Functions » animation.inc (Online Version)

Same as DrawAnim, but this version does not increase the current frame, the frame stays at the same place until increased by other means.

Code/Example

new anim[32] = "someanim";
new x = 2927;
new y = 4820;
new dpt = 32;

DrawAnimNoInc(anim, x, y, dpt);


FinishedAnim

FinishedAnim(ident[]);

Main » Scripting Functions » animation.inc (Online Version)

Returns true if the animation is at it's last frame

Code/Example

FinishedAnim("someanim");


GetAnimCount

GetAnimCount(ident[]);

Main » Scripting Functions » animation.inc (Online Version)

returns the current animation frame.

Code/Example

currentframe = GetAnimCount("thisanim");


GetAnimHeight

GetAnimHeight(ident[]);

Main » Scripting Functions » animation.inc (Online Version)

Return the height of the current sprite in the animation.


GetAnimImage

GetAnimImage(ident[], code[]);

Main » Scripting Functions » animation.inc (Online Version)

Gets Image from the current frame of animation.

Code/Example

//Setup string "image" so GetAnimImage has something to write to.
new image[20];
GetAnimImage(ananim, image);
//"image" now holds the current frame of animation.


GetAnimWidth

GetAnimWidth(ident[]);

Main » Scripting Functions » animation.inc (Online Version)

Return the width of the current sprite in the animation.


GetMaxAnim

GetMaxAnim(ident[]);

Main » Scripting Functions » animation.inc (Online Version)

Return the value for the last animation frame in the animation.


IncrementAnim

IncrementAnim(ident[]);

Main » Scripting Functions » animation.inc (Online Version)

Increment the current animation frame by 1.

Code/Example

new anim[20] = "someanim"; //Another possibility, instead of using "someanim" directly.
IncrementAnim(anim);


SetAnimCount

SetAnimCount(ident[], val);

Main » Scripting Functions » animation.inc (Online Version)

Set the current animation frame to "val".

Code/Example

SetAnimCount("anim1", 3); //sets it to the 4th frame. (0,1,2,3)


SetAnimDirection

SetAnimDirection(ident[], val);

Main » Scripting Functions » animation.inc (Online Version)

Set the direction of the animation ident[]. (1 is forward, -1 is backwards)

Code/Example

If ( isOpen("this") )
 SetAnimDirection("someanim", 1); //Play "someanim" normally
else
 SetAnimDirection("someanim", -1); //Play "someanim" in reverse


SetAnimLoop

SetAnimLoop(ident[], doesloop);

Main » Scripting Functions » animation.inc (Online Version)

Set true or false, if the animation should loop, or stop at the last frame.
The default is true, it does a loop.

Code/Example

SetAnimLoop("SomeAnim", false);


SetAnimSpeed

SetAnimSpeed(ident[], speed);

Main » Scripting Functions » animation.inc (Online Version)

Set the speed of animation ident[] to "speed". (speed is counted in FPS)


Core

Main » Scripting Functions » core.inc

Script must have #include <core> at the top when using these functions

clamp
description coming soon
max
Returns the largest value of the two.
min
Returns the minimum value of the two.
random
Takes an integer, max, and randomly returns a number between 0 and max -1 (note the - 1). The return value is also an integer. random(5) + 1 is between 1 to 5.
strcat
Appends "string2" to "string1".
strcmp
Returns 0 if string1[] is greater than string2[], and 0 if they are equal.
strcpy
Copies the content pointed by "string2"to "string1" stopping after the terminating null-character is copied.
strlen
Returns the length of a string excluding any empty cells.
strpack
description coming soon
strunpack
description coming soon
swapchars
description coming soon
tolower
Converts a single character to lower case.
toupper
Converts a single character to upper case.


clamp

clamp(value, min=cellmin, max=cellmax);

Main » Scripting Functions » core.inc (Online Version)

description coming soon


max

max(value1, value2);

Main » Scripting Functions » core.inc (Online Version)

Returns the largest value of the two.


min

min(value1, value2);

Main » Scripting Functions » core.inc (Online Version)

Returns the minimum value of the two.


random

random(max)

Main » Scripting Functions » core.inc (Online Version)

Takes an integer, max, and randomly returns a number between 0 and max -1 (note the - 1). The return value is also an integer. random(5) + 1 is between 1 to 5.

Code/Example

new Number;
//random(10) would return 0-9
Number = random(10) + 1;
if (Number <= 5) { // 50% chance
  //do something
}
else if  (Number <= 7) { // 20% chance
  //do something else
}
else { // 30% chance
  //do something else
}


strcat

strcat(const string1[], const string2[]);

Main » Scripting Functions » core.inc (Online Version)

Appends "string2" to "string1".

Code/Example

new temp[20] = "abc ";
strcat(temp,"123");
DrawBitmapText(temp, 11, 200, 1); //Prints abc 123


strcmp

strcmp(string1[], const string2[]);

Main » Scripting Functions » core.inc (Online Version)

Returns < 0 if string1[] is less than string2[];
> 0 if string1[] is greater than string2[], and 0 if they are equal.
Note that this comparison is case sensitive.


strcpy

strcpy(const string1[], const string2[]);

Main » Scripting Functions » core.inc (Online Version)

Copies the content pointed by "string2"to "string1" stopping after the terminating null-character is copied. "string1" should have enough memory space allocated to contain "string2".


strlen

strlen(const string[]);

Main » Scripting Functions » core.inc (Online Version)

Returns the length of a string excluding any empty cells.

Code/Example

new stringthing[20] = "abcd"
strlen(stringthing); //this returns 4, as the number of used cells.


strpack

strpack(dest[], const source[]);

Main » Scripting Functions » core.inc (Online Version)

description coming soon


strunpack

strunpack(dest[], const source[]);

Main » Scripting Functions » core.inc (Online Version)

description coming soon


swapchars

swapchars(c);

Main » Scripting Functions » core.inc (Online Version)

description coming soon


tolower

tolower(c);

Main » Scripting Functions » core.inc (Online Version)

Converts a single character to lower case.
Doesn't convert to upper case.


toupper

toupper(c)

Main » Scripting Functions » core.inc (Online Version)

Converts a single character to upper case. Doesn't convert to lower.


Counter

Main » Scripting Functions » counter.inc

Script must have #include <counter> at the top when using these functions

CreateCounter
Create a counter available to the current script with minimum and maximum values.
CreateCounterWithID
CreateCounterWithID(min, max, ident[]);
DeleteCounter
Delete the counter.
GetCounterValue
Return current the counter value.
IncCounterTarget
Increase the counter target by "val".
IncCounterValue
Increase the current counter value by "val".
SetCounterMax
Set the counter maximum value to something else than the original maximum value.
SetCounterMin
Set the counter minimum value to something else than the initial minimum.
SetCounterSpeed
Set the speed of the counter to val.
SetCounterTarget
Set the counter target to "val".
SetCounterValue
Set the current counter value to "val".


CreateCounter

CreateCounter(min, max, ident[]);

Main » Scripting Functions » counter.inc (Online Version)

Create a counter available to the current script with minimum and maximum values.

Code/Example

CreateCounter(min, max, ident[]);


CreateCounterWithID

CreateCounterWithID(min, max, ident[]);

Main » Scripting Functions » counter.inc (Online Version)

CreateCounterWithID(min, max, ident[]);
Create a counter available to all scripts after its creation.


DeleteCounter

DeleteCounter(ident[]);

Main » Scripting Functions » counter.inc (Online Version)

Delete the counter.


GetCounterValue

GetCounterValue(ident[]);

Main » Scripting Functions » counter.inc (Online Version)

Return current the counter value.


IncCounterTarget

IncCounterTarget(ident[], val);

Main » Scripting Functions » counter.inc (Online Version)

Increase the counter target by "val".


IncCounterValue

IncCounterValue(ident[], val);

Main » Scripting Functions » counter.inc (Online Version)

Increase the current counter value by "val".


SetCounterMax

SetCounterMax(ident[], val);

Main » Scripting Functions » counter.inc (Online Version)

Set the counter maximum value to something else than the original maximum value.


SetCounterMin

SetCounterMin(ident[], val);

Main » Scripting Functions » counter.inc (Online Version)

Set the counter minimum value to something else than the initial minimum.


SetCounterSpeed

SetCounterSpeed(ident[], val);

Main » Scripting Functions » counter.inc (Online Version)

Set the speed of the counter to val.


SetCounterTarget

SetCounterTarget(ident[], val);

Main » Scripting Functions » counter.inc (Online Version)

Set the counter target to "val".


SetCounterValue

SetCounterValue(ident[], val);

Main » Scripting Functions » counter.inc (Online Version)

Set the current counter value to "val".


Entity

Main » Scripting Functions » entity.inc

Script must have #include <entity> at the top when using these functions

AllocateStrings
Allocates the number(numstr) of strings for the entity. "length" is the length of all strings
AngleCollide
Checks for collisions.
AngleMove
Move the entity using the angle in GetMoveAngle(). (This moves the X/Y coordinates)
CallFunction
Call a public function in entity ident[]. If no entity has that ID, entity with the filename will be created.
ChangeDirection
Changes the direction of the entity to a new one.
CheckForHole
Check if entity collides with a hole.
ClearCollisionRect
Delete collision rectangle "index".
Collide
Check if any collision rectangle in ident[] collides with any in ident2[].
CollideAll
Check if all collision rectangles in ident[] collides with all in ident2[].
CollidePoint
Check if the point (x, y) falls within the collision rectangles of the Entity
CreateEntity
Creates a Entity at x,y sending the it's unique name to "code".
CreateEntityWithID
Creates a Entity at x,y and give it the name "code".
DeleteEntity
Delete the entity ident[]. basicly quits that entity.
GetAnglePointX
Get X value in front of entity at "dist".
GetAnglePointY
Get Y value in front of entity at "dist".
GetBounceValue
Get the entity's current bounce value. ( the player script makes use of this when throwing... )
GetCurrentEntity
Retrieve the name of the current entity in the list. ( Use ToString(GetCurrentEntity(), string) to copy it into a string)
GetDamage
Retrieve the value from SetDamage().
GetDirection
Get the current entity direction.
GetEntityCount
Get the total count of entities in the game currently.
GetFloat
Same as GetValue but returns a float value
GetGotoNextMessage
returns true, if message number from message "index" and answer "index2" exists
GetHealth
Returns Health vaule for entity
GetImage
Copy the image string into code[].
GetInitialX
Get the X position the entity was created on.
GetInitialY
Get the Y position was created on.
GetItem
Copy the item string into code.
GetLiftLevel
Retrieve the liftlevel for ident[].
GetMaxHealth
Returns Max. Health value for the entity.
GetMoveAngle
Get the movement angle for Entity in degrees.
GetNextMessage
description coming soon
GetNumNextMessages
description coming soon
GetParam
Returns the Param. The Param is the value of # in the entity's name.
GetParent
Set buffer[] to the name of the parent of ident[]
GetSpeed
Get the speed for entity;
GetSpeedMod
Retrieve the speed modification value for entity.
GetState
Returns State for Entity "indent"
GetString
Retrieve string nr "index" from entity and copy it into string[].
GetType
Retrieve the current entity type.
GetValue
Retrieve entity's "index" value.
GetWeight
Get the weight of entity.
GetX
Get the current X position for ident[].
GetY
Get the current Y position for ident[].
isActive
Returns Active Flag for the entity.
isCuttable
Returns Cuttable Flag for the entity.
isDead
Returns Dead Flag for the entity
isInteracting
Return Entity's Interacting Flag.
isLarge
Return Entity's Large Flag.
isOpen
Returns Open Flag for the entity
isOwned
Check if the Owned Flag is true for the wanted entity.
isPickable
Returns Pickable Flag for the entity.
isPushed
Return Entity's Pushed Flag.
isTaken
Returns Taken Flag for the entity
isVisible
Returns Visible Flag for the entity .
MessageMap
This is the basic code to make an NPC talk. When you are typing the message use ` to go to the next line and | to make an answer to a question that the NPC might ask
NextEntity
Go to the next entity in the list.
Respawn
Respawn dead entity in every "seconds" seconds
SetActiveDist
Set the distance in pixels from current scren X/Y that the entities will be run.
SetActiveFlag
Sets Entity's Active Flag.
SetActiveInGroups
If "val" equals true, Active Flag will be true even if your not in that group, otherwise it's false when you not in the same group as the entity, or not within it's active distance.
SetAngleFromDir
Set the angle to whatever the current direction is.
SetBounceValue
Set the entity's bounce value. ( player script makes use of this. )
SetCollisionRect
Create collision rectangle "index" for the entity. solid indicates if you can walk through it or not, left, top, right & bottom are the corresponding edges of the rectangle.
SetCuttableFlag
Sets Entity's Cuttable Flag.
SetDamage
Set the damage of ident[] to val. This works pretty much like using Set/GetValue().
SetDeadFlag
Sets Entity's Dead Flag. Use with Enemies & player entities.
SetDirection
Set the current direction for entity.
SetDirFromAngle
Set the direction according to what the current angle is.
SetFloat
Same as SetValue but use a float value
SetHealth
Set the the level of health for the entity.
SetImage
Set the main image sprite to code[].
SetInteractingFlag
Sets Entity's Interacting Flag.
SetItem
Gives Entity (Chest, enemy or shop) an Item.
SetLargeFlag
Sets Entity's Large Flag.
SetLiftLevel
Works the same as SetDamage(), set the lift level for entity ident[] to val.
SetMaxHealth
Set Max Health for the Entity.
SetMoveAngle
Set the Entity's movement angle to val. (counted in degrees)
SetOpenFlag
Sets Entity Open Flag
SetOwnedFlag
Sets Entity's Owned Flag.
SetPickableFlag
Sets Entity's Pickable Flag.
SetPosition
Set both X & Y position for ident[] at the same time.
SetPushedFlag
Sets Entity's Pushed Flag.
SetSpeed
Set the speed for entity to val.
SetSpeedMod
Set the speed modification value for entity to val.
SetState
Available States:
SetString
works like other Set function, but more than one can be set by giving a different index value (starting at 0). The Entity must use AllocateStrings().
SetTakenFlag
Sets Entity's Taken Flag
SetType
Set the entity type to val.
SetValue
Set Entity's "index" value to "val".
SetVisibleFlag
Sets Entity's Visible Flag.
SetWeight
Set the weight of entity to val.
SetX
Set the X position for ident[].
SetY
Set the Y position for ident[].
StartEntity
List entity from the start within the pixel distance of "dist" at x & y.


AllocateStrings

AllocateStrings(ident[], numstr, length);

Main » Scripting Functions » entity.inc (Online Version)

Allocates the number(numstr) of strings for the entity. "length" is the length of all strings


AngleCollide

AngleCollide(ident[], val1, val2, val3, val4, val5, val6);

Main » Scripting Functions » entity.inc (Online Version)

Checks for collisions.
val1 = distance(from entity + offset)
val2 = check depth(angle detail)
val3 = mask max value for check
val4(bool) = Check for holes?
val5 = X offset
val6 = Y offset

check depth angles:
note: will check up to val2's value
val2[1] = AngleMove;
val2[2] = AngleMove + (PI / 4));
val2[3] = AngleMove - (PI / 4));
val2[4] = AngleMove + (PI / 2));
val2[5] = AngleMove - (PI / 2));


AngleMove

AngleMove(ident[]);

Main » Scripting Functions » entity.inc (Online Version)

Move the entity using the angle in GetMoveAngle(). (This moves the X/Y coordinates)

Code/Example

// How is this would be written in OZ
new float: MoveAmt
new MoveAngle;
MoveAmt = (GetSpeed("this") + GetSpeedMod("this")) * GetTimeDelta();
MoveAngle = GetMoveAngle("this");
SetX("this", GetX("this") - floatround(MoveAmt * cos(MoveAngle) );
SetY("this", GetY("this") - floatround(MoveAmt * sin(MoveAngle) );


CallFunction

CallFunction(ident[], isLibrary, funcname[], typestr[], ...);

Main » Scripting Functions » entity.inc (Online Version)

Call a public function in entity ident[]. If no entity has that ID, entity with the filename will be created.
isLibrary is a bool value, if it's a library, set this to true.
funcname[] is the name of the function. If no public function exist, this will return -1
typestr[] is the order of the next few variables, s = string, n = value. ex. (**, "snnss", "blah", 2, 1, "Hey", "Buddy")


ChangeDirection

ChangeDirection(ident[]);

Main » Scripting Functions » entity.inc (Online Version)

Changes the direction of the entity to a new one.


CheckForHole

CheckForHole(ident[]);

Main » Scripting Functions » entity.inc (Online Version)

Check if entity collides with a hole.


ClearCollisionRect

ClearCollisionRect(ident[], index);

Main » Scripting Functions » entity.inc (Online Version)

Delete collision rectangle "index".


Collide

Collide(ident[], ident2[]);

Main » Scripting Functions » entity.inc (Online Version)

Check if any collision rectangle in ident[] collides with any in ident2[].


CollideAll

CollideAll(ident[], ident2[]);

Main » Scripting Functions » entity.inc (Online Version)

Check if all collision rectangles in ident[] collides with all in ident2[].


CollidePoint

CollidePoint(ident[], x, y);

Main » Scripting Functions » entity.inc (Online Version)

Check if the point (x, y) falls within the collision rectangles of the Entity


CreateEntity

CreateEntity(code[], x, y, ident[]);

Main » Scripting Functions » entity.inc (Online Version)

Creates a Entity at x,y sending the it's unique name to "code".


CreateEntityWithID

CreateEntityWithID(code[], x, y, ident[]);

Main » Scripting Functions » entity.inc (Online Version)

Creates a Entity at x,y and give it the name "code".


DeleteEntity

DeleteEntity(ident[]);

Main » Scripting Functions » entity.inc (Online Version)

Delete the entity ident[]. basicly quits that entity.


GetAnglePointX

GetAnglePointX(ident[], dist, xoffset);

Main » Scripting Functions » entity.inc (Online Version)

Get X value in front of entity at "dist".

Code/Example

// Get the Coordinates of a point in front of the player using his moveAngle
new px = GetAnglePointX("this", 9, 8);
new py = GetAnglePointY("this", 9, 8);
new point;
point = CheckMask(px, py, 1);


GetAnglePointY

GetAnglePointY(ident[], dist, yoffset);

Main » Scripting Functions » entity.inc (Online Version)

Get Y value in front of entity at "dist".

Code/Example

// Get the Coordinates of a point in front of the player using his moveAngle
new px = GetAnglePointX("this", 9, 8);
new py = GetAnglePointY("this", 9, 8);
new point;
point = CheckMask(px, py, 1);


GetBounceValue

GetBounceValue(ident[]);

Main » Scripting Functions » entity.inc (Online Version)

Get the entity's current bounce value. ( the player script makes use of this when throwing... )


GetCurrentEntity

GetCurrentEntity();

Main » Scripting Functions » entity.inc (Online Version)

Retrieve the name of the current entity in the list. ( Use ToString(GetCurrentEntity(), string) to copy it into a string)


GetDamage

GetDamage(ident[]);

Main » Scripting Functions » entity.inc (Online Version)

Retrieve the value from SetDamage().


GetDirection

GetDirection(ident[]);

Main » Scripting Functions » entity.inc (Online Version)

Get the current entity direction.

Avaiable Directions:

  1. north
  2. east
  3. south
  4. west
  5. northeast
  6. southeast
  7. southwest
  8. northwest


GetEntityCount

GetEntityCount();

Main » Scripting Functions » entity.inc (Online Version)

Get the total count of entities in the game currently.


GetFloat

GetFloat(ident[], index);

Main » Scripting Functions » entity.inc (Online Version)

Same as GetValue but returns a float value


GetGotoNextMessage

GetGotoNextMessage(ident[], index);

Main » Scripting Functions » entity.inc (Online Version)

returns true, if message number from message "index" and answer "index2" exists


GetHealth

GetHealth(ident[]);

Main » Scripting Functions » entity.inc (Online Version)

Returns Health vaule for entity


GetImage

GetImage(ident[], code[]);

Main » Scripting Functions » entity.inc (Online Version)

Copy the image string into code[].


GetInitialX

GetInitialX(ident[]);

Main » Scripting Functions » entity.inc (Online Version)

Get the X position the entity was created on.


GetInitialY

GetInitialY(ident[]);

Main » Scripting Functions » entity.inc (Online Version)

Get the Y position was created on.


GetItem

GetItem(ident[], code[]);

Main » Scripting Functions » entity.inc (Online Version)

Copy the item string into code.


GetLiftLevel

GetLiftLevel(ident[]);

Main » Scripting Functions » entity.inc (Online Version)

Retrieve the liftlevel for ident[].

Code/Example

GetLiftLevel(ident[]);


GetMaxHealth

GetMaxHealth(ident[]);

Main » Scripting Functions » entity.inc (Online Version)

Returns Max. Health value for the entity.


GetMoveAngle

GetMoveAngle(ident[]);

Main » Scripting Functions » entity.inc (Online Version)

Get the movement angle for Entity in degrees.


GetNextMessage

Main » Scripting Functions » entity.inc (Online Version)

description coming soon

Code/Example

GetNextMessage(ident[], index, index2);


GetNumNextMessages

Main » Scripting Functions » entity.inc (Online Version)

description coming soon

Code/Example

GetNumNextMessages(ident[], index);


GetParam

GetParam( ident[] );

Main » Scripting Functions » entity.inc (Online Version)

Returns the Param. The Param is the value of # in the entity's name.

Code/Example

//Loading _guards.zes
DrawText(GetParam( "this" ), 10, 10); // Prints out "s" at 10, 10


GetParent

GetParent( ident[], buffer[] );

Main » Scripting Functions » entity.inc (Online Version)

Set buffer[] to the name of the parent of ident[]

Code/Example

new Parent[20];

main()
{
    if (FirstRun())
    {
        // Get the entity who created this
        GetParent("this", Parent);
    }
    else
    {
        // If the parent is no longer froxen then delete this entity
        if ( GetState(Parent) != frozen )
            DeleteEntity("this");
    }
}


GetSpeed

GetSpeed(ident[]);

Main » Scripting Functions » entity.inc (Online Version)

Get the speed for entity;


GetSpeedMod

GetSpeedMod(ident[]);

Main » Scripting Functions » entity.inc (Online Version)

Retrieve the speed modification value for entity.


GetState

GetState(ident[]);

Main » Scripting Functions » entity.inc (Online Version)

Returns State for Entity "indent"
Available States:

  • standing
  • walking
  • hit
  • knocked
  • jumping
  • swimming
  • floating *
  • chasing
  • using
  • lifting
  • standLift
  • walkLift
  • dying
  • dead
  • falling
  • falling2
  • stunned
  • frozen
  • shocked *
  • burning
  • sleeping
  • waiting
  • leaping *
  • pushing *
  • pulling *
* Not available in QD 2.0.4


GetString

GetString(ident[], index, string[]);

Main » Scripting Functions » entity.inc (Online Version)

Retrieve string nr "index" from entity and copy it into string[].


GetType

GetType(ident[]);

Main » Scripting Functions » entity.inc (Online Version)

Retrieve the current entity type.


GetValue

GetValue(ident[], index);

Main » Scripting Functions » entity.inc (Online Version)

Retrieve entity's "index" value.


GetWeight

GetWeight(ident[]);

Main » Scripting Functions » entity.inc (Online Version)

Get the weight of entity.


GetX

GetX(ident[]);

Main » Scripting Functions » entity.inc (Online Version)

Get the current X position for ident[].


GetY

GetY(ident[]);

Main » Scripting Functions » entity.inc (Online Version)

Get the current Y position for ident[].


isActive

isActive(ident[]);

Main » Scripting Functions » entity.inc (Online Version)

Returns Active Flag for the entity.


isCuttable

isCuttable(ident[]);

Main » Scripting Functions » entity.inc (Online Version)

Returns Cuttable Flag for the entity.


isDead

isDead(ident[]);

Main » Scripting Functions » entity.inc (Online Version)

Returns Dead Flag for the entity

Code/Example

if (isDead("ENEMYNAME")) // Return true if "ENEMYNAME" is dead
{
    CallFunction("DOORNAME", false, "Open", "NULL"); //Opens "DOORNAME"
}


isInteracting

isInteracting(ident[])

Main » Scripting Functions » entity.inc (Online Version)

Return Entity's Interacting Flag.


isLarge

isLarge(ident[]);

Main » Scripting Functions » entity.inc (Online Version)

Return Entity's Large Flag.


isOpen

isOpen(ident[]);

Main » Scripting Functions » entity.inc (Online Version)

Returns Open Flag for the entity

Code/Example

if (isOpen("Chest"))  // Returns true is "Chest" is open
{
    InitTextBox("The Chest is open", 200, true);
}
else if (!isOpen("Chest"))  // Not needed, since isOpen returns a Boolean value
{
    InitTextBox("The Chest is close", 200, true);
}


isOwned

isOwned(ident[]);

Main » Scripting Functions » entity.inc (Online Version)

Check if the Owned Flag is true for the wanted entity.
Weapons/items from a chest/shop have a unique "ident", so isOwned can't be used to see if player own them.


isPickable

isPickable(ident[])

Main » Scripting Functions » entity.inc (Online Version)

Returns Pickable Flag for the entity.


isPushed

isPushed(ident[])

Main » Scripting Functions » entity.inc (Online Version)

Return Entity's Pushed Flag.


isTaken

isTaken(ident[]);

Main » Scripting Functions » entity.inc (Online Version)

Returns Taken Flag for the entity

Code/Example

if (isTaken("Item"))  // Returns true if "Item" has been taken
{
    InitTextBox("The Item has been taken", 200, true);
}


isVisible

isVisible(ident[]);

Main » Scripting Functions » entity.inc (Online Version)

Returns Visible Flag for the entity .


MessageMap

MessageMap(ident[], index, Message[], gotoNext, ...);

Main » Scripting Functions » entity.inc (Online Version)

This is the basic code to make an NPC talk. When you are typing the message use ` to go to the next line and | to make an answer to a question that the NPC might ask

Code/Example

MessageMap("OldMan", 0, "When I was your age,`I wrote programs in binary", true, 1);  //gotoNext is true so it continues to Message 1
/* Next line is a question */
MessageMap("OldMan", 1, "1 + 1 = `| 11 `| 2 `| 10", true, 2, 3, 4); // Selecting 11 will goto Message 2, 2 to Message 3 and soon
MessageMap("OldMan", 2, "11 is wrong", false); // you answered 11. gotoNext is false so it stop.
MessageMap("OldMan", 3, "2 is right", false); // you answered 2. gotoNext is false so it stop.
MessageMap("OldMan", 4, "10 is wrong", false); // you answered 10. gotoNext is false so it stop.


NextEntity

NextEntity(dist, x=-1, y=-1);

Main » Scripting Functions » entity.inc (Online Version)

Go to the next entity in the list.


Respawn

Respawn(ident[], seconds);

Main » Scripting Functions » entity.inc (Online Version)

Respawn dead entity in every "seconds" seconds


SetActiveDist

SetActiveDist(ident[], val);

Main » Scripting Functions » entity.inc (Online Version)

Set the distance in pixels from current scren X/Y that the entities will be run.
-2 means entities always run;
-1 means entities never run;


SetActiveFlag

SetActiveFlag(ident[], val);

Main » Scripting Functions » entity.inc (Online Version)

Sets Entity's Active Flag.


SetActiveInGroups

SetActiveInGroups(ident[], val);

Main » Scripting Functions » entity.inc (Online Version)

If "val" equals true, Active Flag will be true even if your not in that group, otherwise it's false when you not in the same group as the entity, or not within it's active distance.


SetAngleFromDir

SetAngleFromDir(ident[]);

Main » Scripting Functions » entity.inc (Online Version)

Set the angle to whatever the current direction is.


SetBounceValue

SetBounceValue(ident[], val);

Main » Scripting Functions » entity.inc (Online Version)

Set the entity's bounce value. ( player script makes use of this. )


SetCollisionRect

SetCollisionRect(ident[], index, solid, left, top, right, bottom);

Main » Scripting Functions » entity.inc (Online Version)

Create collision rectangle "index" for the entity. solid indicates if you can walk through it or not, left, top, right & bottom are the corresponding edges of the rectangle.


SetCuttableFlag

SetCuttableFlag(ident[], val);

Main » Scripting Functions » entity.inc (Online Version)

Sets Entity's Cuttable Flag.


SetDamage

SetDamage(ident[], val);

Main » Scripting Functions » entity.inc (Online Version)

Set the damage of ident[] to val. This works pretty much like using Set/GetValue().


SetDeadFlag

SetDeadFlag(ident[], val);

Main » Scripting Functions » entity.inc (Online Version)

Sets Entity's Dead Flag. Use with Enemies & player entities.


SetDirection

SetDirection(ident[], val);

Main » Scripting Functions » entity.inc (Online Version)

Set the current direction for entity.


SetDirFromAngle

SetDirFromAngle(ident[]);

Main » Scripting Functions » entity.inc (Online Version)

Set the direction according to what the current angle is.


SetFloat

SetFloat(ident[], index, floatval);

Main » Scripting Functions » entity.inc (Online Version)

Same as SetValue but use a float value


SetHealth

SetHealth(ident[], val);

Main » Scripting Functions » entity.inc (Online Version)

Set the the level of health for the entity.

Code/Example

//Each Heart is 100, so the next line will set it to half a heart.
SetHealth("player1", 50);


SetImage

SetImage(ident[], code[]);

Main » Scripting Functions » entity.inc (Online Version)

Set the main image sprite to code[].


SetInteractingFlag

SetInteractingFlag(ident[], val);

Main » Scripting Functions » entity.inc (Online Version)

Sets Entity's Interacting Flag.


SetItem

SetItem(ident[], code[]);

Main » Scripting Functions » entity.inc (Online Version)

Gives Entity (Chest, enemy or shop) an Item.

Code/Example

SetItem("Enemy", "_itemkeym"); // Gives "Enemy" an Master Key


SetLargeFlag

SetLargeFlag(ident[], val);

Main » Scripting Functions » entity.inc (Online Version)

Sets Entity's Large Flag.


SetLiftLevel

SetLiftLevel(ident[], val);

Main » Scripting Functions » entity.inc (Online Version)

Works the same as SetDamage(), set the lift level for entity ident[] to val.


SetMaxHealth

SetMaxHealth(ident[], val);

Main » Scripting Functions » entity.inc (Online Version)

Set Max Health for the Entity.


SetMoveAngle

SetMoveAngle(ident[], val);

Main » Scripting Functions » entity.inc (Online Version)

Set the Entity's movement angle to val. (counted in degrees)


SetOpenFlag

SetOpenFlag(ident[], val);

Main » Scripting Functions » entity.inc (Online Version)

Sets Entity Open Flag

Code/Example

if (isPushed("switch"))
    SetOpenFlag("Door", true);


SetOwnedFlag

SetOwnedFlag(ident[], val);

Main » Scripting Functions » entity.inc (Online Version)

Sets Entity's Owned Flag.
Use to see if player owns a weapon/item (if you know the ident[]).
[b]Set When?[/b]
Some Weapon/Item in FirstRun().
Chest/Shop when giving Weapon/Item to Player.
[b]Checked[/b]
_menulib to check it Weapon/Item is owned.


SetPickableFlag

SetPickableFlag(ident[], val);

Main » Scripting Functions » entity.inc (Online Version)

Sets Entity's Pickable Flag.


SetPosition

SetPosition(ident[], x, y);

Main » Scripting Functions » entity.inc (Online Version)

Set both X & Y position for ident[] at the same time.


SetPushedFlag

SetPushedFlag(ident[], val);

Main » Scripting Functions » entity.inc (Online Version)

Sets Entity's Pushed Flag.


SetSpeed

SetSpeed(ident[], val);

Main » Scripting Functions » entity.inc (Online Version)

Set the speed for entity to val.


SetSpeedMod

SetSpeedMod(ident[], val);

Main » Scripting Functions » entity.inc (Online Version)

Set the speed modification value for entity to val.


SetState

SetState(ident[], val);

Main » Scripting Functions » entity.inc (Online Version)

Available States:

  • standing
  • walking
  • hit
  • knocked
  • jumping
  • swimming
  • floating *
  • chasing
  • using
  • lifting
  • standLift
  • walkLift
  • dying
  • dead
  • falling
  • falling2
  • stunned
  • frozen
  • shocked *
  • burning
  • sleeping
  • waiting
  • leaping *
  • pushing *
  • pulling *
* Not available in QD 2.0.4

Code/Example

/* Make player go night-night */
SetState("player1", sleeping);  // Note that they is no " around sleeping


SetString

SetString(ident[], index, string[]);

Main » Scripting Functions » entity.inc (Online Version)

works like other Set function, but more than one can be set by giving a different index value (starting at 0). The Entity must use AllocateStrings().

Code/Example

/* Walk in "doorentrance" and out "doorexit" */
SetString("doorentrance", 0, "doorexit");


SetTakenFlag

SetTakenFlag(ident[], val);

Main » Scripting Functions » entity.inc (Online Version)

Sets Entity's Taken Flag


SetType

SetType(ident[], val);

Main » Scripting Functions » entity.inc (Online Version)

Set the entity type to val.


SetValue

SetValue(ident[], index, val);

Main » Scripting Functions » entity.inc (Online Version)

Set Entity's "index" value to "val".


SetVisibleFlag

SetVisibleFlag(ident[], val);

Main » Scripting Functions » entity.inc (Online Version)

Sets Entity's Visible Flag.


SetWeight

SetWeight(ident[], val);

Main » Scripting Functions » entity.inc (Online Version)

Set the weight of entity to val.


SetX

SetX(ident[], val);

Main » Scripting Functions » entity.inc (Online Version)

Set the X position for ident[].


SetY

SetY(ident[], val)

Main » Scripting Functions » entity.inc (Online Version)

Set the Y position for ident[].


StartEntity

StartEntity(dist = 40, x=-999, y=-999);

Main » Scripting Functions » entity.inc (Online Version)

List entity from the start within the pixel distance of "dist" at x & y.

Code/Example

// Go to the start of the Entity List
StartEntity(60); // Check for entities within 60 pixels
// Loop through all the entities within a certain distance
do
{
    ToString(GetCurrentEntity(), temp);
    // Check the Player can lift this, and that it is actually liftable
    if (GetLiftLevel(temp) != -1 && GetLiftLevel(temp) <= GetLiftLevel("this"))
    {
        // Check if the point (px, py) falls within the collision rectangles of the current Entity
        if (isActive(temp) && CollidePoint(temp, px, py))
        {
            // We are now lifting!
            SetState("this", lifting);

            PreLift();
            SetQKey(false);
            LiftID = temp;

            // Inform the object we are lifting that it has just been taken
            SetTakenFlag(temp, true);
            return 1;
        }
    }
}while( NextEntity() )


Float

Main » Scripting Functions » float.inc

Script must have #include <float> at the top when using these functions

float
Convert an integer into a floating point value.
float:floatdiv
description coming soon
float:floatfract
description coming soon
float:floatmul
description coming soon
float:floatstr
description coming soon
float:floatsub
description coming soon
float:operator
This is not a function used in scripting itself, when included it adds the possibility of using +, -, * and / in floating point numbers.
floatadd
description coming soon
floatcmp
description coming soon
floatround
Returns the floating point decimal rounded to the nearest integer.
GetTimeDelta
Returns the time taken to render the last frame in seconds.


floatadd

Main » Scripting Functions » float.inc (Online Version)

description coming soon

Code/Example

floatadd(float:dividend, float:divisor);


floatcmp

Main » Scripting Functions » float.inc (Online Version)

description coming soon

Code/Example

floatcmp(float:fOne, float:fTwo);


floatround

floatround(float:value, floatround_method:method=floatround_round);

Main » Scripting Functions » float.inc (Online Version)

Returns the floating point decimal rounded to the nearest integer.

Methods

  • fround_round : rounds to the nearest integer

  • fround_floor : rounds down to the nearest integer

  • fround_ceil : rounds up to the nearest integer

Code/Example

floatround(value, floatround_method:floatround_ceil); //rounds up
floatround(value, floatround_method:floatround_floor); //rounds down


GetTimeDelta

GetTimeDelta();

Main » Scripting Functions » float.inc (Online Version)

Returns the time taken to render the last frame in seconds.

Code/Example

new float: timer;
timer += GetTimeDelta();


float

float(value);

Main » Scripting Functions » float.inc (Online Version)

Convert an integer into a floating point value.


General

Main » Scripting Functions » general.inc

Script must have #include <general> at the top when using these functions

AKey
Return TRUE if A is pressed
CalculateAngle
Returns Angle from x1,y1 to x2,y2.
CheckForHoleXY
Return Hole type if Hole exist at x,y.
CheckMask
Returns Mask value at x,y. It will return 0, if checkForObjects = 1 & they is a collision rectangle at x,y.
ClearRestartTable
Clears Restart Table.
DownKey
Return true if DOWN is pressed.
DrawBitmapText
Writes text using images at the screen at screen x,y. The Text Images are currently are _OutsideSheet1. style can't not be changed.
DrawImage
Draw code[] at x/y.
DrawLine
Draws a line on screen from x1, y1 to x2, y2.
DrawRectangle
Draws a rectangle on the screen.
DrawText
Writes text at the screen at screen x,y. To change the text size you must use SetTextSize( size ). Arial is the font used.
EnableControls
Enable/Disable the key input.
EnterKey
Return TRUE if ENTER is pressed.
FadeTo
Fades screen to a color. Return False until it's finished.
FinishedReading
Returns true if you completed reading all the current messages.
FirstRun
Returns true if the current script is running for the first time.
GameOver
this just makes a game over screen, can be useful in some ocasions but is only really used in player1.zes
GetDayCount
Returns current day. note: start at Zero
GetGlobal
Returns Global "index".
GetGroupMaxX
Returns the Group max. X value.
GetGroupMaxY
Returns the Group max. Y value.
GetGroupMinX
Returns the Group min. X value.
GetGroupMinY
Returns the Group min. Y value.
GetHeight
Return the height of a sprite.
GetHourCount
Returns current hour.
GetLastAnswer
returns value of last answer.
GetLocal
Returns Local "index". A Local value available to that group only.
GetLowerLevelX
Gets the screen something falls to when it falls down a hole.
GetLowerLevelY
Gets the screen something falls to when it falls down a hole.
GetMinuteCount
Returns current minute.
GetPauseLevel
Returns the pause level.
GetWidth
Return the width of a sprite.
GetWorldX
description coming soon
GetWorldY
description coming soon
InitialPlayerX
Return Player starting X postion.
InitialPlayerY
Return Player starting Y postion.
InitTextBox
Displays a text box on screen with the width of "wid". Setting priority to true, will take over a previous text box. To added a line break use ` in "string"
LeftKey
Return TRUE if LEFT is pressed.
NearPoint
Return TRUE if x1 & y1 is within the range of dist from x2 & y2.
PlayMusic
Stop playing current music, then plays "code". If "Fade" is true, music would fading out & in when swapping.
PlaySound
Plays a sound at wanted "volume".
PutSprite
Draws Sprite "ident" at screen x/y.
QKey
Return TRUE if Q is pressed
RightKey
Return TRUE if RIGHT is pressed.
SetAKey
Set AKey Flag to val.
SetDayCount
Set current day.
SetDayLength
Set how long a Day is, val is in seconds, with default of 1800.
SetDownKey
Manually set the state of the down key.
SetEnterKey
Set EnterKey Flag to val.
SetGlobal
Sets Global "index" to val.
SetHourCount
Set current hour.
SetLeftKey
Set LeftKey Flag to val.
SetLocal
Sets Local "index" to val. A Local values is only available to that group.
SetLowerLevel
Set the level you fall to when you walk over a hole. x & y are world values.
SetMinuteCount
Set current minute.
SetMusicFadeSpeed
Set the speed the music fade to when swapping.
SetMusicVolume
Set the volume of the groups music to "volume". Volume is between 0-255
SetPauseLevel
0 - Unpaused
SetQKey
Set QKey Flag to val.
SetRestartPoint
This is useful for having your quest start you out in your house but later on have you restart in a dungeon once you get to one
SetRestartTable
Set Restart Table "index" to x,y;
SetRightKey
Set RightKey Flag to val.
SetSKey
Set SKey Flag to val.
SetSpriteAlpha
Set alpha for sprites called spriteCode[]
SetTextBoxColor
Changes the Text Color inside of the Text Box.
SetTextSize
Set the text size for DrawText, Font use is Arial.
SetUpKey
Set UpKey Flag to val.
SetWKey
Set WKey Flag to val.
SetWorldX
SetWorldY
description coming soon
SKey
Return TRUE if S is pressed
TextFile
Writes string[] into the error-log file.
ToFile
Writes "value" into the error-log file.
ToString
Copies a numeric value in val to the string.
UpdateWorldCo
Move Viewpoint to x,y.
UpKey
Return TRUE if UP is pressed.
Wipe
Wipes screen to a direction. Used when changing groups
WKey
Return TRUE if W is pressed.


AKey

AKey();

Main » Scripting Functions » general.inc (Online Version)

Return TRUE if A is pressed


CalculateAngle

CalculateAngle(x1,y1,x2,y2);

Main » Scripting Functions » general.inc (Online Version)

Returns Angle from x1,y1 to x2,y2.


CheckForHoleXY

CheckForHoleXY(x,y);

Main » Scripting Functions » general.inc (Online Version)

Return Hole type if Hole exist at x,y.


CheckMask

CheckMask(x, y, checkForObjects = 0);

Main » Scripting Functions » general.inc (Online Version)

Returns Mask value at x,y. It will return 0, if checkForObjects = 1 & they is a collision rectangle at x,y.


ClearRestartTable

ClearRestartTable();

Main » Scripting Functions » general.inc (Online Version)

Clears Restart Table.


DownKey

DownKey();

Main » Scripting Functions » general.inc (Online Version)

Return true if DOWN is pressed.


DrawBitmapText

DrawBitmapText(string[], x, y, style = 1, red = 255, green = 255, blue = 255, alpha = 255, scale = 200);

Main » Scripting Functions » general.inc (Online Version)

Writes text using images at the screen at screen x,y. The Text Images are currently are _OutsideSheet1. style can't not be changed.

Code/Example

if ( isOpen("Door") )
    DrawBitmapText("Door is open", 10, 10, 1, 0, 255); // Writes "Door is open" at 10,10 in Green
else
    DrawBitmapText("Door is closed", 10, 10, 1, 255); // Writes "Door is closed" at 10,10 in Red


DrawImage

DrawImage(code[], x, y, r = 255, g = 255, b = 255, a = 255, rot = 0, scale = 100);

Main » Scripting Functions » general.inc (Online Version)

Draw code[] at x/y. Places image above all sprites. Position is not based on world coordinates, but rather screen coordinates, ranging from 0,0 -> 640,480


DrawLine

DrawLine(x1, y1, x2, y2, width, red, green, blue, aplha = 255);

Main » Scripting Functions » general.inc (Online Version)

Draws a line on screen from x1, y1 to x2, y2.


DrawRectangle

DrawRectangle(x1, y1, x2, y2, red, green, blue, alpha = 255, angle = 0);

Main » Scripting Functions » general.inc (Online Version)

Draws a rectangle on the screen.


DrawText

DrawText(string[], x, y, red = 255, green = 255, blue = 255, alpha = 255);

Main » Scripting Functions » general.inc (Online Version)

Writes text at the screen at screen x,y. To change the text size you must use SetTextSize( size ). Arial is the font used.

Code/Example

if ( isOpen("Door") )
    DrawText("Door is open", 10, 10, 0, 255); // Writes "Door is open" at 10,10 in Green
else
    DrawText("Door is closed", 10, 10, 255); // Writes "Door is closed" at 10,10 in Red


EnableControls

EnableControls( enable );

Main » Scripting Functions » general.inc (Online Version)

Enable/Disable the key input.


EnterKey

EnterKey();

Main » Scripting Functions » general.inc (Online Version)

Return TRUE if ENTER is pressed.


FadeTo

FadeTo(red, green, blue, speed);

Main » Scripting Functions » general.inc (Online Version)

Fades screen to a color. Return False until it's finished.
Note FadeTo(255, 255, 255, speed) will return the screen to normal not white.

Code/Example

if( FadeTo(0, 0, 255, 160) )    //fades green
{
    FadeTo(255, 255, 255, 160);            //fade back to normal
}


FinishedReading

FinishedReading();

Main » Scripting Functions » general.inc (Online Version)

Returns true if you completed reading all the current messages.


FirstRun

FirstRun();

Main » Scripting Functions » general.inc (Online Version)

Returns true if the current script is running for the first time.
Screens/Groups scripts are running for the first time every time you enter them.

Code/Example

if (!FirstRun())
{
   //This isn't the first frame. why? note the ! before the FirstRun()

}


GameOver

GameOver();

Main » Scripting Functions » general.inc (Online Version)

this just makes a game over screen, can be useful in some ocasions but is only really used in player1.zes


GetDayCount

GetDayCount();

Main » Scripting Functions » general.inc (Online Version)

Returns current day. note: start at Zero


GetGlobal

GetGlobal(index);

Main » Scripting Functions » general.inc (Online Version)

Returns Global "index".


GetGroupMaxX

GetGroupMaxX();

Main » Scripting Functions » general.inc (Online Version)

Returns the Group max. X value.


GetGroupMaxY

GetGroupMaxY();

Main » Scripting Functions » general.inc (Online Version)

Returns the Group max. Y value.


GetGroupMinX

GetGroupMinX();

Main » Scripting Functions » general.inc (Online Version)

Returns the Group min. X value.


GetGroupMinY

GetGroupMinY();

Main » Scripting Functions » general.inc (Online Version)

Returns the Group min. Y value.


GetHeight

GetHeight(ident[]);

Main » Scripting Functions » general.inc (Online Version)

Return the height of a sprite.


GetHourCount

GetHourCount();

Main » Scripting Functions » general.inc (Online Version)

Returns current hour.


GetLastAnswer

GetLastAnswer();

Main » Scripting Functions » general.inc (Online Version)

returns value of last answer.


GetLocal

GetLocal(index);

Main » Scripting Functions » general.inc (Online Version)

Returns Local "index". A Local value available to that group only.


GetLowerLevelX

GetLowerLevelX();

Main » Scripting Functions » general.inc (Online Version)

Gets the screen something falls to when it falls down a hole.


GetLowerLevelY

GetLowerLevelY();

Main » Scripting Functions » general.inc (Online Version)

Gets the screen something falls to when it falls down a hole.


GetMinuteCount

GetMinuteCount();

Main » Scripting Functions » general.inc (Online Version)

Returns current minute.


GetPauseLevel

GetPauseLevel();

Main » Scripting Functions » general.inc (Online Version)

Returns the pause level.


GetWidth

GetWidth(ident[]);

Main » Scripting Functions » general.inc (Online Version)

Return the width of a sprite.


GetWorldX

GetWorldX();

Main » Scripting Functions » general.inc (Online Version)

description coming soon


GetWorldY

GetWorldY();

Main » Scripting Functions » general.inc (Online Version)

description coming soon


InitialPlayerX

InitialPlayerX();

Main » Scripting Functions » general.inc (Online Version)

Return Player starting X postion.


InitialPlayerY

InitialPlayerY();

Main » Scripting Functions » general.inc (Online Version)

Return Player starting Y postion.


InitTextBox

InitTextBox(string[], wid, priority);

Main » Scripting Functions » general.inc (Online Version)

Displays a text box on screen with the width of "wid". Setting priority to true, will take over a previous text box. To added a line break use ` in "string"


LeftKey

LeftKey();

Main » Scripting Functions » general.inc (Online Version)

Return TRUE if LEFT is pressed.


NearPoint

NearPoint(x1, y1, x2, y2, dist);

Main » Scripting Functions » general.inc (Online Version)

Return TRUE if x1 & y1 is within the range of dist from x2 & y2.

Code/Example

NearPoint(x1, y1, x2, y2, dist);


PlayMusic

PlayMusic(code[], fade);

Main » Scripting Functions » general.inc (Online Version)

Stop playing current music, then plays "code". If "Fade" is true, music would fading out & in when swapping.


PlaySound

PlaySound(code[], volume = 128);

Main » Scripting Functions » general.inc (Online Version)

Plays a sound at wanted "volume".


PutSprite

PutSprite(ident[], valx, valy, vald, layer = 0, r = 255, g = 255, b = 255, a = 255, rot = 0, scale = 100);

Main » Scripting Functions » general.inc (Online Version)

Draws Sprite "ident" at screen x/y.
vald is the depth or z-index.
layer is what layer is dawn on.
r,g,b,a are the Red,Green, Blue, Alpha value.


QKey

QKey();

Main » Scripting Functions » general.inc (Online Version)

Return TRUE if Q is pressed


RightKey

RightKey();

Main » Scripting Functions » general.inc (Online Version)

Return TRUE if RIGHT is pressed.


SetAKey

SetAKey(val);

Main » Scripting Functions » general.inc (Online Version)

Set AKey Flag to val.


SetDayCount

SetDayCount(val);

Main » Scripting Functions » general.inc (Online Version)

Set current day.


SetDayLength

SetDayLength(val);

Main » Scripting Functions » general.inc (Online Version)

Set how long a Day is, val is in seconds, with default of 1800.


SetDownKey

Main » Scripting Functions » general.inc (Online Version)

Manually set the state of the down key.

Code/Example

SetDownKey(val);


SetEnterKey

SetEnterKey(val);

Main » Scripting Functions » general.inc (Online Version)

Set EnterKey Flag to val.


SetGlobal

SetGlobal(index, val);

Main » Scripting Functions » general.inc (Online Version)

Sets Global "index" to val.


SetHourCount

SetHourCount(val);

Main » Scripting Functions » general.inc (Online Version)

Set current hour.


SetLeftKey

SetLeftKey(val);

Main » Scripting Functions » general.inc (Online Version)

Set LeftKey Flag to val.


SetLocal

SetLocal(index, val);

Main » Scripting Functions » general.inc (Online Version)

Sets Local "index" to val. A Local values is only available to that group.


SetLowerLevel

SetLowerLevel(x, y);

Main » Scripting Functions » general.inc (Online Version)

Set the level you fall to when you walk over a hole. x & y are world values.


SetMinuteCount

SetMinuteCount(val);

Main » Scripting Functions » general.inc (Online Version)

Set current minute.


SetMusicFadeSpeed

SetMusicFadeSpeed(speed = 110);

Main » Scripting Functions » general.inc (Online Version)

Set the speed the music fade to when swapping.


SetMusicVolume

SetMusicVolume(volume);

Main » Scripting Functions » general.inc (Online Version)

Set the volume of the groups music to "volume". Volume is between 0-255


SetPauseLevel

SetPauseLevel(val);

Main » Scripting Functions » general.inc (Online Version)

0 - Unpaused
1 - Paused
2 - Used when Wiping
3 - Used when Saving/Loading


SetQKey

SetQKey(val);

Main » Scripting Functions » general.inc (Online Version)

Set QKey Flag to val.


SetRestartPoint

SetRestartPoint(x, y);

Main » Scripting Functions » general.inc (Online Version)

This is useful for having your quest start you out in your house but later on have you restart in a dungeon once you get to one


SetRestartTable

SetRestartTable(index, x, y, desc[] );

Main » Scripting Functions » general.inc (Online Version)

Set Restart Table "index" to x,y;


SetRightKey

SetRightKey(val);

Main » Scripting Functions » general.inc (Online Version)

Set RightKey Flag to val.


SetSKey

SetSKey(val);

Main » Scripting Functions » general.inc (Online Version)

Set SKey Flag to val.


SetSpriteAlpha

SetSpriteAlpha( spriteCode[], newAlpha);

Main » Scripting Functions » general.inc (Online Version)

Set alpha for sprites called spriteCode[]


SetTextBoxColor

SetTextBoxColor(red, green, blue, alpha);

Main » Scripting Functions » general.inc (Online Version)

Changes the Text Color inside of the Text Box.


SetTextSize

SetTextSize( size );

Main » Scripting Functions » general.inc (Online Version)

Set the text size for DrawText, Font use is Arial.

Code/Example

SetTextSize( 10 );


SetUpKey

SetUpKey(val);

Main » Scripting Functions » general.inc (Online Version)

Set UpKey Flag to val.


SetWKey

SetWKey(val);

Main » Scripting Functions » general.inc (Online Version)

Set WKey Flag to val.


SetWorldX

SetWorldX(val);

Main » Scripting Functions » general.inc (Online Version)


SetWorldY

Main » Scripting Functions » general.inc (Online Version)

description coming soon

Code/Example

SetWorldY(val);


SKey

SKey();

Main » Scripting Functions » general.inc (Online Version)

Return TRUE if S is pressed


TextFile

TextFile(string[]);

Main » Scripting Functions » general.inc (Online Version)

Writes string[] into the error-log file.


ToFile

ToFile(value);

Main » Scripting Functions » general.inc (Online Version)

Writes "value" into the error-log file.


ToString

ToString(val, string[]);

Main » Scripting Functions » general.inc (Online Version)

Copies a numeric value in val to the string.


UpdateWorldCo

UpdateWorldCo(x, y);

Main » Scripting Functions » general.inc (Online Version)

Move Viewpoint to x,y.


UpKey

UpKey();

Main » Scripting Functions » general.inc (Online Version)

Return TRUE if UP is pressed.


Wipe

Wipe(direction, speed);

Main » Scripting Functions » general.inc (Online Version)

Wipes screen to a direction. Used when changing groups

Code/Example

//Ripped from Player1.zes
CheckForGroup()
{
    static wiped;
    new x = GetX("this");
    new y = GetY("this");

    if (GetPauseLevel() != 0)
        return;

    // Check if the player walks over any of the group boundaries
    if (x >= GetGroupMaxX() - 2)
    {
        if (wiped)
            return;
        SetX("this", GetGroupMaxX() + 2);
        Wipe(east, 500);
        wiped = true;
        return;
    }
    else if (x <= GetGroupMinX() - 10)
    {
        if (wiped)
            return;
        SetX("this", GetGroupMinX() - LastWidth - 4);
        Wipe(west, 500);
        wiped = true;
        return;
    }
    else if (y >= GetGroupMaxY())
    {
        if (wiped)
            return;
        SetY("this", GetGroupMaxY());
        Wipe(south, 500);
        wiped = true;
        return;
    }
    else if (y <= GetGroupMinY() - 16)
    {
        if (wiped)
            return;
        SetY("this", GetGroupMinY() - LastWidth - 4);
        Wipe(north, 500);
        wiped = true;
        return;
    }
    else
        wiped = false;
}


WKey

WKey();

Main » Scripting Functions » general.inc (Online Version)

Return TRUE if W is pressed.

Code/Example

if ( WKey() )
{
    SetWKey(false); //Set WKey() to false for rest of the frame

}


Quest Packs Index

Quest Packs

Main » Quest Packs
  • Open Zelda


Open Zelda's Public Functions

Quest Pack - Open Zelda

Main » Quest Packs » Open Zelda
  • Public Functions
  • Entities


Open Zelda's Entity Usage

Quest Pack - Open Zelda - Entities

Main » Quest Packs » OpenZelda » Entities
    _armos1
    Enemy - Armos: A statue which comes to life when you get near it and hops around after you.
    _bombweapon1
    Weapon - Bomb: The fuse counts down and then creates an explosion entity.
    _boom#
    Object - Moving Bomerang: Used when the boomerang is in movement.
    _boomerang#
    Weapon - Boomerang: Used for the player.
    _bubbleenemy#
    Enemy - Bubble: Invincible bouncing enemy, found in red & blue colors. Looks like a skull with 4 circulating bolts.
    _bush01
    Object - Bush: Normal throwable/cuttable bush, default liftlevel is 0, player liftlevel at beginning is 1.
    _chest1
    Object - Small Chest: Add content to it using:
    _crabenemy
    Enemy - Crab: Moving mindlessly around fast or slow.
    _d5switch1
    No corresponding sprite(!?), ignore for now.
    _doentrance#
    Object - Dungeon Entrance: Used for outside dungeon entrance.
    _doorlib
    Object - Door: Mainly "warping", and positioning afterwards.
    _dungeonentrance#
    This is the entity for all dungeon entrances inside the dungeon.
    _enemylib
    This is a library handling enemy functions like death, hitting, falling and more.
    _explosion1
    This is an explosion entity created on the fly by another entity, it plays it's animation once and deletes.
    _explosion2
    This is a small "decorative" explosion, created by... For example the sword when it hits something.
    _fire1#
    This is a burning animation, created by a firerod or a similar thing.
    _fireball1
    This entity is created by a firerod, and moves in a straight line until it hits something.
    _firerodweapon
    This weapon entity is placed in a chest, or on the screen, and is added to your inventory when picked up.
    _freezeeffect
    This is a decorative effect created by the icerod when freezing something.
    _gloveitem#
    This entity is placed in a chest, it handles gloves, that are used for lifting, # can be either 1, 2 or 3, depending on the type of glove you want.
    _greencrack1#
    description coming soon
    _greendoor1#
    description coming soon
    _greendoor2#
    description coming soon
    _greendoor3#
    description coming soon
    _greendoor4#
    description coming soon
    _greenstairs#
    description coming soon
    _guard#
    This is the entity for the guard enemies.
    _guardsword
    One of two weapons for the "_guard#" entity, this one in particular, is a sword, and is the default weapon for the guard.
    _guardtrident
    Second possible weapon for the guard.
    _housecrack1#
    description coming soon
    _housedoor1#
    description coming soon
    _iceblast1
    description coming soon
    _icerodweapon
    This entity is placed in a chest or on the ground and gives the player the "Ice rod" weapon.
    _itembomb#
    description coming soon
    _itemheart
    Small heart placed in the QD or in a chest, raises players health by 100(equal to one heart)
    _itemkey#
    description coming soon
    _itemlib
    description coming soon
    _itemmagic#
    Item- Magic refill container
    _itemrupee#
    description coming soon
    _menulib
    This library handles the menu appearing when you press enter.
    _npc1#
    description coming soon
    _npc2#
    description coming soon
    _npclib
    description coming soon
    _orbenemy#
    description coming soon
    _pbombweapon1
    Placed in a chest, and allows you to use the bomb as a weapon.
    _pot1
    description coming soon
    _rockcrack1#
    description coming soon
    _rockentrance1#
    description coming soon
    _sign01
    description coming soon
    _sparkle1
    description coming soon
    _spikeball
    this is the "spike" enemy, set it's initial direction using "SetDirection(ident[], east/west/north/south);"
    _switch1#
    description coming soon
    _swordweapon1
    description coming soon
    _tentacle1
    description coming soon
    _throwobj1#
    description coming soon


Open Zelda's Public Functions

Quest Pack - Open Zelda - Public Functions

Main » Quest Packs » OpenZelda » Public Functions
    Cracks
    HitByWeapon(wtype[], damage, x, y)
    Run when a weapons hits a enemy entity. "wtype" is the type of weapon, "damage" is the amount of damage cause by the weapon, "x" & "y" are where the enemy got hit.
    Cracks
    OpenNow()
    Opens door without animation delay.
    Cracks
    CloseNow()
    Closes door without animation delay.
    Doors
    Open()
    Makes the door open.
    Doors
    Close()
    Makes the door close.
    Enemies
    HitByWeapon(wtype[], damage, x, y)
    Run when a weapons hits a enemy entity. "wtype" is the type of weapon, "damage" is the amount of damage cause by the weapon, "x" & "y" are where the enemy got hit.
    Guard Enemies Weapons
    Draw(x, y, depth, direction, frame)
    Draws the weapon at "x", "y" on layer "depth". "direction" is either north, south, east or west and "frame" is the sprite offset.
    Pickable Items
    StartBounce()
    Makes an item bounce as if it has landed on a floor.
    player1.zes
    EndThrow()
    Changes the players state from lifting to standing and calls "BeginDestroy" on the thrown object.
    player1.zes
    BeginHit(x, y, damage)
    Controls the effects of being hurt at point x, y and deducts the level of 'damage'.
    player1.zes
    BeginKnockBack(x, y, strength, length )
    Knocks the player back from point x, y without damaging him. 'Strength' is the speed of knockback and 'length' is the distance.
    Throwable Objects
    Thrown()
    Checks if entity collides with other objects while being thrown.
    Throwable Objects
    BeginDestroy()
    Sets the entity status to destroyed and plays the destroyed sound effect.
    Throwable Objects
    Destroy()
    Draws the animation of the entity being destroyed.
    Throwable Objects
    HitByWeapon(wtype[], damage, x, y)
    Run when a weapons hits a enemy entity. "wtype" is the type of weapon, "damage" is the amount of damage cause by the weapon, "x" & "y" are where the enemy got hit.
    Weapon
    Init()
    An initial procedure which resets parameters for the script.
    Weapon
    DrawWeapon()
    Draws the weapon as the player uses it. Also produces weapon effects and checks for hits with some weapons.
    _doorlib.zes
    MoveToOtherDoor()
    Moves the player from one door to another. Handles fading effects moving from door to door.
    _doorlib.zes
    GetNewPosition(TargetDoor[])
    Places player in the middle of the target door sprite.
    _enemylib.zes
    CreateDeathAnim( buffer[] )
    Creates a standard death animation called "buffer".
    _enemylib.zes
    CreateFallAnim( buffer[] )
    Creates a falling animation.
    _enemylib.zes
    CheckForPlayer()
    Checks for collisions with the player and calls BeginHit().
    _enemylib.zes
    KillEnemy()
    Changes the state to dying and plays the default death sound.
    _enemylib.zes
    HandleDying(anim[], image[])
    Displays death animation. "anim" is the death animation identifier and "image" is the sprite code of the last frame.
    _enemylib.zes
    CheckForHoles(anim[])
    Checks for collisions with holes, resets falling animation "anim" and handles the falling sound effect.
    _enemylib.zes
    Fall(anim[], width, height)
    Displays the falling animation "anim" with the entity dimensions "width" and "height".
    _enemylib.zes
    CheckForChase(dir, enemyx, enemyy, detect)
    Checks if the player nearby and also if the player is in the field of vision.
    _enemylib.zes
    SetOnFire(lastImage[])
    Changes the state to burning and creates a fire entity over the "lastimage" sprite.
    _enemylib.zes
    Stunned(StunCount)
    Handles the stun delay.
    _enemylib.zes
    BeginFreeze(lastImage[])
    Changes the state to frozen and creates a frozen effect entity over the "lastimage" sprite.
    _enemylib.zes
    BeginHit(damage, x, y)
    Inflicts the amount of "damage" and knocks the enemy away from point "x", "y".
    _freezeeffect.zes
    SetArea(x, y, wid, hei)
    Draws sparkle animations over the area given by "x", "y" and "wid", "hei".
    _guard#.zes
    BeginKnockBack(x, y)
    Knocks the enemy back from point "x", "y" without damaging it.
    _guard#.zes
    SetHead(HeadNum)
    Sets the type of helmet the guard uses.
    _guard#.zes
    SetWeapon(Weapon[])
    Sets the type of weapon the guard uses.
    _itemlib.zes
    AddItem(item[], probability)
    Adds a pickable item to the main list of items and sets the frequency (0-100) of its appearance.
    _itemlib.zes
    RemoveItem(item[])
    Removes an item from the main list of available items.
    _itemlib.zes
    GetRandomItem(x, y, item[])
    Produces an item from the main list, selected at random, at coordinates "x", "y".
    _itemlib.zes
    DrawItemNumber( num, x, y, depth, alpha )
    Draws the little white numbers (1, 5, 10, 50, 100) on top of items to show their quantities.
    _menulib.zes
    Init()
    An initial procedure which resets parameters for the script.
    _menulib.zes
    HandleMenu()
    Initiates the menu dropping down if the enter key is pressed.
    _npc1#.zes
    SetInstruction(NewInstruction, instruction)
    Points to the next number "NewIntruction" in the set person scripts and can be used for setting up loops in npc actions. "instruction" is the number which this command is in person script.
    _npc1#.zes
    GetInstruction()
    Returns the current Person Script instruction.
    _npc1#.zes
    SetBodyDirection(dir, instruction)
    Sets the direction "dir" of the npc. "instruction" is the number which this command is in person script.
    _npc1#.zes
    SetHeadDirection(dir, instruction)
    Changes the direction "dir" of the head only. "instruction" is the number which this command is in person script.
    _npc1#.zes / _npclib.zes
    WalkTo( x, y, instruction )
    Makes an NPC walk to x, y in the order given by 'intruction'.
    _npc1#.zes / _npclib.zes
    Wait( timeToWait, instruction )
    Makes an NPC wait for 'timeToWait' in the order given by 'intruction'.
    _npc1#.zes / _npclib.zes
    WaitFor( WhoToWaitFor[], TargetInstruction, instruction )
    Waits for the NPC entity specified by 'WhoToWaitFor' to get to their 'TargetInstruction' in order to sycronise NPC movement.
    _npc1#.zes / _npclib.zes
    Say( Text[], instruction )
    Displays an NPC's message in the order given by 'intruction'.
    _npc1#.zes Listed
    Ghost()
    Sets the npc alpha to 40 which can be used for ghost-like npcs.
    _npc1#.zes Listed
    Transparent(tr)
    Sets the alpha of the npc to "tr".
    _npclib.zes
    CheckForTalk()
    Checks if the player is trying to talk with the NPC and displays the NPC's message
    _npclib.zes
    AfterTalk()
    Works out the next NPC message to be displayed after the current dialogue box is closed.
    _npclib.zes
    FacePlayer()
    Changes the NPC's direction to always face the player.


Code Snipplets

Main » Code Snipplets
Answer Yes, Be Healed
Dark_Link - [dark_link@charter.net]
This is a script that makes an NPC heal you, for a price.
chest game
link102
this script is from the OZ.cfl.
Circular Motion (2 methods)
hocuspocus - [kcc3121@rit.edu]
Two different methods for making an object go around either a fixed or mobile point. Just make sure do define all of the variables I used.
Custom HUDs
lukex
Replace DrawHUD() with one below in the main script.
Custom Menu's
lukex
Replace DrawMenu() with one below in the _menulib script.
darkworld chest game
KingOfHeart - [ancado@netzero.com]
This is for the darkworld chest game where your allowed to open two chests.
Door Closes behind you
lukex
Just something simple, might not work due to door scripts.
Enter Players Name
lukex
Only use with Open Zelda Quest Pack 2.9.0 or higher
MM Bank script
KingOfHeart - [ancado@netzero.com]
This script was used in Dark Link's revenge. Read the bottom to find out how to add interest.
OpenZelda Intro
Intro used when starting OpenZelda
Press Switch to make Chest Appear
lukex
Random Happenings
Dark_Link - [dark_link@charter.net]
Will this or that happen???
Replace in string
lukex
When ever the script finds ~ in the string it replaces it with replaceWith[] which in this case it's "Link".
Saving Counters
Dark_Link - [dark_link@charter.net]
Warning, this is a quick hack to fix a bug in OZ 6.2.4
Simple Quest Intro (unfinished)
lukex
This is modified verson of the intro of Ormola Zebeque Chapters: Battle for the Throne.
Simple Quest Intro with Enter Players Name (unfinished)
lukex
Merge Version of Simple Quest Intro and Enter Players Name. Can be easier change to password system instead of player name.
Text Fading In
hocuspocus - [kcc3121@rit.edu]
Draws text that slowly fades from clear to opaque a little while after the player enters the screen or group
Time Teller Man
Satanman - [satanman@mail.thegaminguniverse.com]
Script for a NPC to give the player the current time. also show how to change a single character in a string.


OpenZelda Intro

Main » Code Snipplets (Online Version)

Intro used when starting OpenZelda Code by GD

Code

#include <entity>
#include <general>
#include <float>
#include <core>

new float:ScrollCount = 150.00;
new float: logoCount = 0.00;

main()
{
if (FirstRun())
{
SetVisibleFlag("player1", false);
SetActiveFlag("player1", false);
SetHourCount( random(24) );
}

if ( ScrollCount < 820)
{
ScrollCount += 10.0 * GetTimeDelta();
UpdateWorldCo( floatround(ScrollCount), 0);
}

if ( ScrollCount >= 820 )
{
if ( logoCount < 255 )
logoCount+= 30.0 * GetTimeDelta();

DrawImage("_TitleSheet21", 300, 120, 255, 255, 255, floatround(logoCount), 0, 200);
DrawImage("_TitleSheet20", 240, 170, 255, 255, 255, floatround(logoCount), 0, 200);
SetTextSize(14);
DrawText("Load a Quest to Start", 226, 315, 255, 255, 255, floatround(logoCount) / 2);
}

if (EnterKey())
{
if ( ScrollCount < 820 )
{
// We havnt yet reached the scroll point so
// move the screen now.
ScrollCount = 820.00;

UpdateWorldCo( floatround(ScrollCount), 0);
logoCount = 255.00;
}
}

}


Answer Yes, Be Healed

Submitted by Dark_Link - [dark_link@charter.net]

Main » Code Snipplets (Online Version)

This is a script that makes an NPC heal you, for a price.

Code

#include <entity>
#include <general>
#include <counter>

main()
{
    if (FirstRun())
    {
        MessageMap("npc1", 0, "Do you want me to heal you [50R]? `|a-no`|why...yeeees!", true, 1, 2);
        MessageMap("npc1", 1, "Ok come back any time!", false, 0);
    }
    if (FinishedReading() && GetLastAnswer() == 1)
    {
        if ( GetCounterValue("rupees") >= 50 )
        {
            MessageMap("npc1", 2, "Here you go", false, 0);
            SetHealth("player1", GetMaxHealth("player1"));
            IncCounterTarget("rupees", -50);
        }
        else
        {
            MessageMap("npc1", 2, "Sorry, you're broke", false, 0);
            PlaySound("_error.wav", 200);
        }
    }
}


Random Happenings

Submitted by Dark_Link - [dark_link@charter.net]

Main » Code Snipplets (Online Version)

Will this or that happen???

Code

#include <entity>
#include <gereral>
#include <core>

new randomvalue;

main()
{
  if (FirstRun))
  {
    DoRandomThing();
  }
}

DoRandomThing()
{
  randomvalue = random(4); // Returns a value between 0-3
  if (randomvalue == 0)
  {
  }
  else if (randomvalue == 1)
  {
  }
  else if (randomvalue == 2)
  {
  }
  else if (randomvalue == 3)
  {
  }
}


Press Switch to make Chest Appear

Submitted by lukex

Main » Code Snipplets (Online Version)

Code

if (FirstRun())
{
  if (!isOpen("chest1")) // Check to see if "chest1" hasn't been open
  {
    ClearCollisionRect("chest1", 0); // clear the "chest1" collision area. 0 is the layer you want to clear.
    SetVisibleFlag("chest1", 0); // Makes "chest1" invisible
    SetActiveFlag("chest1", 0); // Makes "chest1" non active
    SetItem("chest1", "weapon_bow1");// Give "chest1" an item.
  }
}

if (isPushed("switch1")) // Checks you are standing on "switch1" switch
{
  SetActiveFlag("chest1", 1);// Makes "chest1" active
  SetVisibleFlag("chest1", 1);// Makes "chest1" visible
}


Saving Counters

Submitted by Dark_Link - [dark_link@charter.net]

Main » Code Snipplets (Online Version)

Warning, this is a quick hack to fix a bug in OZ 6.2.4
This is function used to save thew numer of Rupees, Bomb, Arrows, etc... you have, put the first part in the main script and the second part in the screen you start out in.
changed by lukex: made some changes might not work.

Code

//This is for the main script
#include <entity>
#include <general>
#include <counter>
#include <core>
main()
{
   if (FirstRun())
   {
      /*****************************************************
       *  Removed
       ****************************************************/
   }
   else
   {
       if ( GetPauseLevel() == 3 )
           SaveCounters(); // Should Save when you do
   }
      /*****************************************************
       *  Removed
       ****************************************************/
}

//----------------------------------------
// Name: DrawHUD()
//----------------------------------------
DrawHUD()
{
        /*****************************************************
       *  Removed
       ****************************************************/
}

//Save the counter values
SaveCounters()
{
   SetGlobal(4001, GetCounterValue("rupees"));
   SetGlobal(4002, GetCounterValue("bombs"));
   SetGlobal(4003, GetCounterValue("arrows"));
   SetGlobal(4004, GetCounterValue("magicMeter"));
   SetGlobal(4005, GetCounterValue("smallKeys"));
   SetGlobal(4006, GetCounterValue("masterKey"));
   SetGlobal(4007, GetCounterValue("HeartPieces"));
}

//And this is for the screen you start in
#include <entity>
#include <general>
#include <counter>

main()
{

    if(FirstRun())
    {
        LoadCounters();
    }
}
LoadCounters()
{
       SetCounterValue("rupees", GetGlobal(4001));
       SetCounterValue("bombs", GetGlobal(4002));
       SetCounterValue("arrows", GetGlobal(4003));
       SetCounterValue("magicMeter", GetGlobal(4004));
       SetCounterValue("smallKeys", GetGlobal(4005));
       SetCounterValue("masterKey", GetGlobal(4006));
       SetCounterValue("HeartPieces", GetGlobal(4007));
}


Time Teller Man

Submitted by Satanman - [satanman@mail.thegaminguniverse.com]

Main » Code Snipplets (Online Version)

Script for a NPC to give the player the current time. also show how to change a single character in a string.

Code

#include <entity>
#include <general>

new string1[45] = "the time is xx:xx";
new string2[4];
new string3[4];

main()
{
    new Hour = GetHourCount();
    new Minute = GetMinuteCount();

        // Convert Numbers to strings
    ToString(Hour, String2);
    ToString(Minute, String3);

    if (Hour < 10)
    {
        String1[12] = '0';
        String1[13] = String2[0];
    } else {
        String1[12] = String2[0];
        String1[13] = String2[1];
    }
    if (Minute < 10)
    {
        String1[15] = '0';
        String1[16] = String3[0];
    } else {
        String1[15] = String3[0];
        String1[16] = String3[1];
    }
    SetString("timeman", 0, string1);
}


Simple Quest Intro (unfinished)

Submitted by lukex

Main » Code Snipplets (Online Version)

This is modified verson of the intro of Ormola Zebeque Chapters: Battle for the Throne.

Code

#include <entity>
#include <general>
#include <float>
#include <core>

new float: introCount = 0.00;
new TextCount;

main()
{
    if ( FirstRun() )
    {
        CallFunction("_menulib", false, "ableMenu", "n", false); //On newer _menulib this disables the hud, menu & mape
        SetPauseLevel(1); // pauses game
        PlaySound( "title.it", 128); // Plays Music
        SetActiveFlag("player1", false); // disables Player
        SetTextSize( 12 );
    }
    /* See if User has pressed enter */
    if (EnterKey())
    {
        SetEnterKey(false);
        /* if Title hasn't finished, make it do so. Else Start the game  */
        if ( introCount < 128 )
        {
            introCount = 128.00;
            drawtitle();
        }
        else
            startgame();
    }
    else if ( introCount >= 160 )
    {
        /* Title has finished for a while, Start Story  */
        introCount = 160.00;
        if (FinishedReading()) {
            TextCount++;
        }
        switch( TextCount )
        {
        case 0:
            drawintro("Text","Image");
        case 1:
            drawintro("Text","Image");
        case 2:
            drawintro("Text","Image");
        case 3:
            drawintro("Text","Image");
        case 4:
            startgame();
        }
    } else {
        if (introCount < 160)
            drawtitle();

        introCount += 8.00 * GetTimeDelta();
    }

}
startgame() {
    SetActiveFlag("player1", true); // Make Player Active again
    SetPosition("player1", x, y); //x, y need to be changed
    /* Set Game to 12 o'clock */
    SetHourCount( 12 );
    SetMinuteCount( 00 );
    CallFunction("_menulib", false, "ableMenu", "n", true); //On newer _menulib this disables the hud, menu & mape
    SetPauseLevel(0); // Un-pauses

}

drawtitle() {
/* Insert you own DrawImage/PutSprite here*/
/* You can use floatround(introCount) here to change RGBA & scale */

}

drawintro(text[], image[]) {
    DrawImage(image, 320 - (GetWidth(image)/2), 240 - (GetHeight(image)/2);

    InitTextBox(text, 300, false);
}


chest game

Submitted by link102

Main » Code Snipplets (Online Version)

this script is from the OZ.cfl.

you need 1 npc: conman1
and 5 chests: random001
random002
random003
random004
random005

Code

#include <entity>
#include <general>
#include <counter>
#include <core>
#include <float>

new yoinkmoney = false;
new randomvalue;
new float: timer = 0.00;

main()
{
    if (FirstRun())
    {
        SetActiveFlag("random001", false);
        SetActiveFlag("random002", false);
        SetActiveFlag("random003", false);
        SetActiveFlag("random004", false);
        SetActiveFlag("random005", false);
        SetOpenFlag("random001", false);
        SetOpenFlag("random002", false);
        SetOpenFlag("random003", false);
        SetOpenFlag("random004", false);
        SetOpenFlag("random005", false);
    }

    MessageMap("conman1", 0, "Would you like to play? (10 rupees)`| get me outta here!`| Yeah, OK... what?", true, 1, 2);
    MessageMap("conman1", 1, "too bad, see you soon", false, 0);
    MessageMap("conman1", 2, "Thank you, come again", false, 0);

    if (FinishedReading() && GetLastAnswer() == 1)
    {
        if (GetCounterValue("rupees") >= 10)
        {
            InitTextBox("good, now open one of the boxes", 200, 1);
            IncCounterTarget("rupees", -10);
            BeginGame();
        }
        else
        {
            InitTextBox("Sorry, you don't have enough money", 200, 1);
            PlaySound("_error.wav", 240);
        }
    }
    if (yoinkmoney)
        BeginGame();
    else {
        ClearCollisionRect("random001", 0);
        ClearCollisionRect("random002", 0);
        ClearCollisionRect("random003", 0);
        ClearCollisionRect("random004", 0);
        ClearCollisionRect("random005", 0);
    }
}

BeginGame()
{
    if (yoinkmoney == false)
    {
        SetActiveFlag("random001", true);
        SetActiveFlag("random002", true);
        SetActiveFlag("random003", true);
        SetActiveFlag("random004", true);
        SetActiveFlag("random005", true);
        yoinkmoney = true;
        randomvalue = random(4);

        if (randomvalue == 0)
        {
            SetItem("random001", "_itemrupeep");
            SetItem("random002", "_itemrupeeg");
            SetItem("random003", "_itemrupeeb");
            SetItem("random004", "_itemrupeeg");
            SetItem("random005", "_itemrupeer");
        } else if (randomvalue == 1)
        {
            SetItem("random001", "_itemrupeeg");
            SetItem("random002", "_itemrupeer");
            SetItem("random003", "_itemrupeep");
            SetItem("random004", "_itemrupeeb");
            SetItem("random005", "_itemrupeeg");
        } else if (randomvalue == 2)
        {
            SetItem("random001", "_itemrupeeg");
            SetItem("random002", "_itemrupeeg");
            SetItem("random003", "_itemrupeeb");
            SetItem("random004", "_itemrupeeg");
            SetItem("random005", "_itemrupeeb");
        } else if (randomvalue == 3)
        {
            SetItem("random001", "_itemrupeep");
            SetItem("random002", "_itemrupeeg");
            SetItem("random003", "_itemrupeeg");
            SetItem("random004", "_itemrupeep");
            SetItem("random005", "_itemrupeeg");
        } else if (randomvalue == 4)
        {
            SetItem("random001", "_itemrupeep");
            SetItem("random002", "_itemrupeer");
            SetItem("random003", "_itemrupeeb");
            SetItem("random004", "_itemrupeeg");
            SetItem("random005", "_itemrupeeb");
        }
    }
    if (isOpen("random001") || isOpen("random002") || isOpen("random003") || isOpen("random004") || isOpen("random005"))
        timer += GetTimeDelta();

    if (timer >= 2.0)
    {
        SetActiveFlag("random001", false);
        SetActiveFlag("random002", false);
        SetActiveFlag("random003", false);
        SetActiveFlag("random004", false);
        SetActiveFlag("random005", false);
        yoinkmoney = false;
    }
}


Text Fading In

Submitted by hocuspocus - [kcc3121@rit.edu]

Main » Code Snipplets (Online Version)

Draws text that slowly fades from clear to opaque a little while after the player enters the screen or group

Code

#include <entity>
#include <general>
#include <float>

new float: timer = -64.00;

main()
{
    if(timer < 384)
    {
        timer += 64*GetTimeDelta();
        if(timer < 255 && timer > 0)
        {
            DrawBitmapText("really hard dungeon", 136, 220, 1, 255,255, 255, floatround(timer), 400);
        }
        else if(timer >= 255)
        {
            DrawBitmapText("really hard dungeon", 136, 220, 1, 255,255, 255, 255, 400);
        }
    }
}


MM Bank script

Submitted by KingOfHeart - [ancado@netzero.com]

Main » Code Snipplets (Online Version)

This script was used in Dark Link's revenge. Read the bottom to find out how to add interest.

Code

//add this line in your main script
CreateCounterWithID(0,999,"bank");

#include <entity>
#include <general>
#include <counter>
#include <core>
new bank = false;
new amount = false;
new checking = 0;
new money = 0;
new message = 0;
main()
{
//*** part1 for interest
new string[16];
ToString(GetCounterValue("bank"), string);
DrawBitmapText(string,(GetX("bankchest")- GetWorldX())* 2 + 32,(GetY("bankchest")- GetWorldY())* 2 + 45);

if(FirstRun())
{
MessageMap("banka", 0, "Hello can I help you? `| No `|I would like to deposit rupees. `|I would like to withdraw rupees. ", true, 1,2,3);
MessageMap("banka", 1, "Come again.", false, 0);
//*** part2 for interest
}
if(checking > 0)
{
if(GetPauseLevel()== 0)
SetQKey(false);
SetPauseLevel(1);
SetActiveFlag("banka",false);
ToString(GetCounterValue("money"), string);
DrawBitmapText(string,(GetX("player1")- GetWorldX())* 2 + 32,(GetY("player1")- GetWorldY())* 2 - 45);

    if(UpKey())
    {
    SetCounterValue("money",GetCounterValue("money")+ 1)
    SetUpKey(false);
    }
    else if(RightKey())
    {
    SetCounterValue("money",GetCounterValue("money")+ 10)
    SetRightKey(false);
    }
    else if(LeftKey())
    {
    SetCounterValue("money",GetCounterValue("money")- 10)
    SetLeftKey(false);
    }
    else if(DownKey())
    {
    SetCounterValue("money",GetCounterValue("money")- 1)
    SetDownKey(false);
    }

    if(QKey())
    {
    SetPauseLevel(0);
    if(checking == 1)
    {
        if(GetCounterValue("bank")>= GetCounterValue("money"))
        {
        InitTextBox("WithDrawing and here's your receipt.", 200, 0);
        IncCounterTarget("bank",- GetCounterValue("money"));
        IncCounterTarget("rupees", GetCounterValue("money"));
        }
        else
        {
        PlaySound("_error.wav",250);
        InitTextBox("You do not have that much money in the bank.", 200, 0);
        }
    }
    else if(checking > 1)
    {
        if(GetCounterValue("rupees")>= GetCounterValue("money"))
        {
        IncCounterTarget("rupees", - GetCounterValue("money"));
        IncCounterTarget("bank", GetCounterValue("money"));
        InitTextBox("Depositing and here's your receipt.", 200, 0);
        }
        else
        {
        PlaySound("_error.wav",250);
        InitTextBox("You do not have that much rupees.", 200, 0);
        }
    }
    DeleteCounter("money");
    SetValue("banka",3,0);//Reset the messagemap back to 0
    SetActiveFlag("banka",true);
    checking = 0;
    }
}
if (FinishedReading()&& checking == 0 && bank == true && GetLastAnswer()==2)
{
MessageMap("banka", 3, "How many rupees do you want to withdraw?", false, 0);
message = 1;
}
if(message == 1 && FinishedReading())
{
SetQKey(false);
message = 0;
CreateCounterWithID(0,200,"money");
checking = 1;
}
if(message == 2 && FinishedReading())
{
SetQKey(false);
message = 0;
CreateCounterWithID(0,200,"money");
checking = 2;
}
if (GetCounterValue("bank") > 0)
{
bank = true;
}
else
{
MessageMap("banka", 3, "According to your receipt you do not have enough money in the bank.", false, 0);
bank = false;
}
if (FinishedReading()&& amount == true && GetLastAnswer()==1)
{
MessageMap("banka", 2, "How many rupees do you want to deposit?", false, 0);
message = 2;
}
if (GetCounterValue("rupees") > 0)
{
amount = true;
}
else
{
MessageMap("banka", 2, "Sorry you don't have enough money to deposit.", false, 0);
amount = false;
}
}

//If you want interest you'll need these scripts

//add in part1
if(GetCounterValue("bank")== 0)
{
    SetValue("banka",9,GetDayCount());
}

//add in part2 for interest
if(GetDayCount()> GetValue("banka",9)&& GetCounterValue("bank")> 0)
    {
        IncCounterTarget("bank",(GetDayCount()- GetValue("banka",9))* GetCounterValue("bank")/ 10);
        SetValue("banka",9,GetDayCount());
    }
//use a number lower than 10 for more interest,higher for less


Circular Motion (2 methods)

Submitted by hocuspocus - [kcc3121@rit.edu]

Main » Code Snipplets (Online Version)

Two different methods for making an object go around either a fixed or mobile point. Just make sure do define all of the variables I used.

Code

//1st Method(only works for rotation around a fixed point):

if (GetPauseLevel() == 0)
{
    SetMoveAngle("this", CalculateAngle(GetX("this"), GetY("this"), GetX("fixedobject"), GetY("fixedobject")) - 90);
    AngleMove("this");
}

//2nd Method(for fixed or mobile points:

new x = GetX(what you are rotating around);
new y = GetY(what you are rotating around);

// Move the enemy if the game is unpaused
if (GetPauseLevel() == 0)
{
    angletimer += 60*GetTimeDelta();  //change 60 to a higher or lower number to speed up or slow down
    moveangle = floatround(angletimer);
    fx = floatround(32*Cos(moveangle));   //this will move the object around a fixed or mobile
    fy = floatround(32*Sin(moveangle));  //point with a radius of 32

}
if(isVisible("this")
{
    DrawAnim(moveAnim, x + fx, y + fy, y + 16);
    SetCollisionRect("this", 0, false, x + fx + adj, y + fy + adj, x + fx + width - adj, y + fy height - adj);
}


Replace in string

Submitted by lukex

Main » Code Snipplets (Online Version)

When ever the script finds ~ in the string it replaces it with replaceWith[] which in this case it's "Link".
This is currently used for NPC/Signs to say the players name in testing version.

Code

new message[1024] = "This is the string you wanting to replace ~ with replaceWith[]";
new messageLength = strlen(message);
new message_temp[1024];
new replaceWith[8] = "Link";
new replaceWithLength = strlen(replaceWith);
new padding = 0;
for (new o; o < messageLength; o++)
{
    if ( strcmp(message[o], "~") > 0 )
    {
        padding += replaceWithLength - 1;
        for (new q; q < replaceWithLength; q++)
        {
            message_temp[o + q] = replaceWith[q];
        }
    }
    else
    {
        message_temp[o + padding] = message[o];
    }
}
InitTextBox( message_temp, 200, false);


Enter Players Name

Submitted by lukex

Main » Code Snipplets (Online Version)

Only use with Open Zelda Quest Pack 2.9.0 or higher
this script allows the player to enter his name, and certain TextBox's say it.
This was a quickly done script, so if anyone improves it please post it here.

Code

#include <entity>
#include <general>
#include <core>

new player_name[8] = "______"; // _ has no bitmap image
new Current = 0;
new Selected = 0;
new Alphabet[36][2] = {"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9"}; // You can added other character, but make sure you increase the size of the array
main()
{
    if ( FirstRun() )
    {
        SetActiveFlag("player1", false);
        CallFunction("_menulib", false, "ableMenu", "n", false); //disable HUD in latest version of _menulib, does nothing in older version
        SetString("SIGN1", 0, "Hello ~, how are you"); // Just a sign to show you that it worked
    }
    if ( !isActive("player1") )
    {
        if (UpKey())
        {
            SetUpKey(false);
            MoveSelection( 10, false );
        }
        else if (DownKey())
        {
            SetDownKey(false);
            MoveSelection( 10, true );
        }
        else if (LeftKey())
        {
            SetLeftKey(false);
            MoveSelection( 1, false );
        }
        else if (RightKey())
        {
            SetRightKey(false);
            MoveSelection( 1, true );
        }

        if (AKey())
        {
            SetAKey(false);
            SetLetter( Current, Selected );
        }
        else if (SKey())
        {
            SetSKey(false);
            MoveCurrent( false );
        }

        if (EnterKey())
        {
            SetEnterKey(false);
            SetString("player1", 2, player_name);
            SetActiveFlag("player1", true);
            CallFunction("_menulib", false, "ableMenu", "n", true); //re-enable HUD in latest version of _menulib, does nothing in older version
        }
        DisplayAlpha();
        DisplayName();
    }

}

SetLetter ( character, letter )
{
    new temp = Alphabet[letter][0];

    player_name[character] = temp;
    MoveCurrent( true );
}

MoveCurrent( foward )
{
    if (foward)
    {
        if ( Current + 1 < 7 )
        {
            Current += 1;
        }
    }
    else
    {
        if ( Current - 1 >= 0)
        {
            Current -= 1;
        }
    }
}
MoveSelection( Amount, foward )
{
    if (foward)
    {
        if ( Selected + Amount < 36 )
        {
            Selected += Amount;
        }
    }
    else
    {
        if ( Selected - Amount >= 0)
        {
            Selected -= Amount;
        }
    }
}
DisplayName()
{
    new x = 40;
    for ( new n = 0; n < 7; n++)
    {
        x += 16;
        if ( Current == n )
            DrawBitmapText(player_name[n], x, 200, 1, 255, 0, 0);
        else
            DrawBitmapText(player_name[n], x, 200, 1);
    }
}

DisplayAlpha()
{
    new x = 40;
    new y = 300;
    for ( new n = 0; n < 36; n++)
    {
        if ( n == 10 || n == 20 || n == 30)
        {
            y += 18;
            x = 40;
        }
        x += 18;

        if ( Selected == n )
            DrawBitmapText(Alphabet[n], x, y, 1, 255, 0, 0);
        else
            DrawBitmapText(Alphabet[n], x, y, 1);
    }
}


darkworld chest game

Submitted by KingOfHeart - [ancado@netzero.com]

Main » Code Snipplets (Online Version)

This is for the darkworld chest game where your allowed to open two chests. Name the npc "chestguy" and make sure he's below all of the chests. Name the chests "gamechest1" to "gamechest15" and it should work fine.

Code

#include <entity>
#include <general>
#include <counter>
#include <core>
new paid = false;
new chest[15][20]={"gamechest1","gamechest2","gamechest3","gamechest4","gamechest5", "gamechest6","gamechest7","gamechest8","gamechest9","gamechest10","gamechest11","gamechest12", "gamechest13","gamechest14","gamechest15"};
new open[15]={false,false,false,false,false,false, false,false,false,false,false,false,false,false,false};
new opencount = 0;
new rand = 0;

main()
{

    SetString("chesthouse1a", 0, "chesthouse1");
    if(GetCounterValue("rupees")>= 10 && GetLastAnswer()== 2 && FinishedReading())
    {
        MessageMap("chestguy", 3, "Ok you can open two chests",false,3);
        for(new c = 0; c < 15; c++)
        {
        SetOpenFlag(chest[c],false);
        open[c]= false;
        }
        IncCounterTarget("rupees",-10);
        opencount = 0;
        paid = true;
        rand = random(100);
        RandomItem();
    }
    else if(GetCounterValue("rupees")< 10 && GetLastAnswer()== 2 && FinishedReading())
    {
        MessageMap("chestguy", 3, "Sorry you do not have enough rupees.",false,0);
        PlaySound("_error.wav",240);
    }
    if(paid == false)
    {
    MessageMap("chestguy", 0, "Want to play the chest game for 10 rupees? `|Tell me about the prizes`|no   |sure", true, 1, 2,3);
    MessageMap("chestguy", 1, "The prizes that you can get the following rupees:green,blue,red,purple, and gold. You can also get arrows,bombs,magic and if very lucky a heart piece.",false,0);
    MessageMap("chestguy", 2, "Come back anytime.",false,0);
        if(GetY("player1")< GetY("chestguy"))
        {
            SetQKey(false);
        }
    }
    if(paid == true)
    {
        for(new c = 0; c < 15; c++)
        {
            if(isOpen(chest[c])&& open[c]== false)
            {
            opencount++;
            open[c]= true;
            }
        }
        if(opencount >= 2)
        {
            if(GetPauseLevel()== 0)
            {
            SetValue("chestguy",3,0);
            paid = false;
            }
        }
    }
    if(isOpen(chest[3])&& rand >= 75)
    SetGlobal(6,1);

}

RandomItem()
{
    if(rand < 25)
    {
        SetItem(chest[0],"_itemrupeeb");
        SetItem(chest[1],"_itemmagics");
        SetItem(chest[2],"_itemrupeer");
        SetItem(chest[3],"_itembomb2");
        SetItem(chest[4],"_itemarrow3");
        SetItem(chest[5],"_itemrupeeg");
        SetItem(chest[6],"_itemmagicl");
        SetItem(chest[7],"_itemrupeeg");
        SetItem(chest[8],"_itembomb1");
        SetItem(chest[9],"_itemrupeeg");
        SetItem(chest[10],"_itemarrow1");
        SetItem(chest[11],"_itemrupeeg");
        SetItem(chest[12],"_itembomb3");
        SetItem(chest[13],"_itemmagicl");
        SetItem(chest[14],"_itemrupeep");
    }
    else if(rand < 50)
    {
        SetItem(chest[3],"_itemrupeeb");
        SetItem(chest[6],"_itemmagics");
        SetItem(chest[8],"_itemrupeer");
        SetItem(chest[0],"_itembomb2");
        SetItem(chest[11],"_itemarrow3");
        SetItem(chest[14],"_itemrupeeg");
        SetItem(chest[9],"_itemmagicl");
        SetItem(chest[13],"_itemrupeeg");
        SetItem(chest[2],"_itembomb1");
        SetItem(chest[10],"_itemrupeeg");
        SetItem(chest[7],"_itemarrow1");
        SetItem(chest[5],"_itemrupeer");
        SetItem(chest[12],"_itembomb3");
        SetItem(chest[1],"_itemmagicl");
        SetItem(chest[4],"_itemrupeep");
    }
    else if(rand < 75)
    {
        SetItem(chest[8],"_itemrupeeb");
        SetItem(chest[7],"_itemmagics");
        SetItem(chest[4],"_itemrupeeg");
        SetItem(chest[0],"_itembomb2");
        SetItem(chest[3],"_itemarrow3");
        SetItem(chest[11],"_itemrupeeg");
        SetItem(chest[6],"_itemmagicl");
        SetItem(chest[5],"_itemrupeeg");
        SetItem(chest[13],"_itembomb1");
        SetItem(chest[1],"_itemrupeep");
        SetItem(chest[9],"_itemarrow1");
        SetItem(chest[12],"_itemrupeer");
        SetItem(chest[10],"_itembomb3");
        SetItem(chest[14],"_itemmagicl");
        SetItem(chest[2],"_itemrupeeg");
    }
    else
    {
        SetItem(chest[2],"_itemrupeeb");
        SetItem(chest[11],"_itemmagics");
        SetItem(chest[7],"_itemrupeer");
        SetItem(chest[14],"_itembomb2");
        SetItem(chest[13],"_itemarrow3");
        SetItem(chest[0],"_itemrupeeg");
        SetItem(chest[9],"_itemmagicl");
        if(GetGlobal(6)== 0)
        SetItem(chest[3],"_heartpiece");
        else
        SetItem(chest[3],"_itemrupeer");
        SetItem(chest[8],"_itembomb1");
        SetItem(chest[10],"_itemrupeeg");
        SetItem(chest[5],"_itemarrow1");
        SetItem(chest[12],"_itemrupeeg");
        SetItem(chest[4],"_itembomb3");
        SetItem(chest[1],"_itemmagicl");
        SetItem(chest[6],"_itemrupeep");
    }

}


Door Closes behind you

Submitted by lukex

Main » Code Snipplets (Online Version)

Just something simple, might not work due to door scripts.

a minor change to _doorlib, find [script]// Set the position on the player to the other door[/script] and add after
[script] SetInteractingFlag(TargetDoor, true);
SetOpenFlag(TargetDoor, true);[/script]

Code

if ( !isInteracting("DOOR") ) /* Door scripts set the door Interacting to true when the player1 is on it. */
{
    CallFunction("DOOR", false, "Close", "NULL"); /* Play Animation before closing the door */
    /* or */
    SetOpenFlag("DOOR", false); /* Closes the door straight away */
}


Custom HUDs

Submitted by lukex

Main » Code Snipplets (Online Version)

Replace DrawHUD() with one below in the main script.
feel free to add your version of DrawHUD() via the comment system.

Code

/* HUD from OZ quest pack - march 2004 release */
DrawHUD()
{
   new hudY = 10;
   new string[16];
   new i = 0;
   new max = GetMaxHealth("player1") / 50;
   new hp = GetHealth("player1") / 50;
   new x = 0;
   new y = 0;
   new heartstart = 400;
   new Entity[20];
   new Buffer[20];
   new counterColourMax = 255;

   SetTextSize(10);

   // Draw the Ruppee Counter
   DrawImage("__rup01", 80, hudY);
   ToString(GetCounterValue("rupees"), string);
   DrawBitmapText(string, 85, hudY + 24, 1, 255, counterColourMax, counterColourMax);

   // Draw the number of bombs
   DrawImage("_bombhud", 120, hudY);
   ToString(GetCounterValue("bombs"), string);
   DrawBitmapText(string, 125, hudY + 24, 1, 255, counterColourMax, counterColourMax);

   // Draw the number of Arrows
   DrawImage("_arrowhud", 160, hudY);
   ToString(GetCounterValue("arrows"), string);
   DrawBitmapText(string, 165, hudY + 24, 1, 255, counterColourMax, counterColourMax);

   GetString("player1", 0, Entity);
   GetImage(Entity, Buffer);
   DrawImage("_itemhud", 44, hudY + 8, 255, 255, 255, 255, 0, 200);
   if ( strlen(Buffer) > 2 )
       DrawImage(Buffer, 48, hudY + 10, 255, 255, 255, 255, 0, 200);
   else
       DrawImage("_menuA", 54, hudY + 16, 255, 255, 255, 255, 0, 200);
   Buffer = "";
   GetString("player1", 1, Entity);
   GetImage(Entity, Buffer);
   DrawImage("_itemhud", 596, hudY + 8, 255, 255, 255, 255, 0, 200);
   if ( strlen(Buffer) > 2 )
       DrawImage(Buffer, 600, hudY + 10, 255, 255, 255, 255, 0, 200);
   else
       DrawImage("_menuB", 604, hudY + 16, 255, 255, 255, 255, 0, 200);

   if( GetValue("_maplib", 0) > 0 )
   {
      DrawImage("_keyhud", 200, hudY);
      ToString(GetCounterValue("smallKeys"), string);
      DrawBitmapText(string, 205, hudY + 24, 1, 255, 255, 255);
   }

   // Draw the magic meter
   DrawImage("_magichud1", 10, hudY, 255, 255, 255, 255, 0, 200);
   DrawImage("_magichud2", 10, hudY + 16, 255, 255, 255, 255, 0, 200);
   DrawImage("_magichud2", 10, hudY + 32, 255, 255, 255, 255, 0, 200);
   DrawImage("_magichud3", 10, hudY + 48, 255, 255, 255, 255, 0, 200);
   DrawRectangle( 10, ((44 - ( GetCounterValue("magicMeter") ))) + hudY + 6, 28, 64, 0, 180, 0);

   // Draw life meter
   DrawImage("__life1", 440, hudY);

   // Draw hearts
   while( i < max )
   {
      if( i < hp - 1 )
         string = "_heart1";
      else if( i == hp - 1 )
         string = "_heart3";
      else
         string = "_heart2";

      DrawImage( string, heartstart + x * 16, 30 + ( y * 16 ) );
      x++;
      if( x >= 10 )
      {
         y++;
         x = 0;
      }
      i+=2;
   }
}


Custom Menu's

Submitted by lukex

Main » Code Snipplets (Online Version)

Replace DrawMenu() with one below in the _menulib script.
feel free to add your version of DrawMenu() via the comment system.

[b]Added Yellow Borders[/b]
Replace Lines 359-361 with [script] new sprites[24][20] = { "_menu1", "_menu2", "_menu3", "_menu4", "_menu5", "_menu6", \
"_menu7", "_menu8", "_menu10", "_menu11", "_menu12", "_menu13", \
"_menu14", "_menu15", "_menu16", "_menu17", "_menu18", "_menu19", \
"_menu20", "_menu21", "_menu22", "_menu23", "_menu24", "_menu25" };[/script]
Sprites need to created on _MiscSheet for it to be displayed

Code

/* HUD from OZ quest pack - march 2004 release */
DrawMenu()
{
    new itemx;
    new itemy;
    new n;
    new Adj = ypos - MaxYPos;
    new suit[4][20] = { "NULL", "playersuit1", "playersuit2", "playersuit3"  };
    new glove[4][20] = { "NULL", "_powerglove1", "_lunarglove1", "_titanmitt1"  };
    new suit_num;
    new string[16];
    new hour = GetHourCount();
    new minute = GetMinuteCount();
    new day = GetDayCount();
    new Dungeon = GetValue("_maplib", 0);

    if ( MenuGoingDown || MenuGoingUp )
        MoveMenu();

    //DrawBorder( x, y, width, height, color )
    // color 0 green; color 8 red; color 16 yellow;
    DrawBorder( 10, 10 + Adj, 200, 80, 0 );
    DrawBorder( 220, 10 + Adj, 200, 80, 0 );
    DrawBorder( 430, 10 + Adj, 200, 80, 0 );
    DrawBorder( 10, 100 + Adj, 408, 364, 8 );
    DrawBorder( 430, 100 + Adj, 200, 200, 8 );
    DrawBorder( 430, 310 + Adj, 200, 154, 16 );

    DrawImage("_menuA", 20, 20 + Adj, 255, 255, 255, 255, 0, 200);
    DrawImage("_menuB", 232, 22 + Adj, 255, 255, 255, 255, 0, 200);

    // Go through each item in the menu and draw them
    for (n = 0; n < NumItems; n++)
        DrawImage( ItemSprites[n], ItemX[n], ItemY[n] + Adj, 255, 255, 255, 255, 0, 200 );

    DrawSelectedItems();
    HandleSelection();

    suit_num = CallFunction("player1", true, "GetPlayerSuit", "NULL");
    DrawImage("_menuequip", 460, 320 + Adj, 255, 255, 255, 255, 0, 200);
    DrawImage(suit[suit_num], 450, 350 + Adj, 255, 255, 255, 255, 0, 200);
    DrawImage(glove[suit_num], 480, 350 + Adj, 255, 255, 255, 255, 0, 200);

    if ( Dungeon > 0) {
        if (GetCounterValue("masterKey") == 1)
            DrawImage("_itemkeym", 480, 420 + Adj, 255, 255, 255, 255, 0, 200 );
        if (GetValue("_maplib", (Dungeon * 2) - 1))
            DrawImage("_mapitem", 520, 420 + Adj, 255, 255, 255, 255, 0, 200 );
        if (GetValue("_maplib", (Dungeon * 2)))
            DrawImage("_compassitem", 560, 420 + Adj, 255, 255, 255, 255, 0, 200 );
        DrawImage("_menudungeon", 480, 390 + Adj, 255, 255, 255, 255, 0, 200);

    } else {

        if (GetCounterValue("HeartPieces") == 1)
            DrawImage("heart14", 520, 420 + Adj, 255, 255, 255, 255, 0, 200 );
        else if (GetCounterValue("HeartPieces") == 2)
            DrawImage("heart24", 520, 420 + Adj, 255, 255, 255, 255, 0, 200 );
        else if (GetCounterValue("HeartPieces") == 3)
            DrawImage("heart34", 520, 420 + Adj, 255, 255, 255, 255, 0, 200 );
        else
            DrawImage("heartempty", 520, 420 + Adj, 255, 255, 255, 255, 0, 200 );
    }

    ToString(hour, string);
    DrawBitmapText(string, 450, 30 + Adj);
    ToString(minute, string);
    if ( strlen(string) == 1 )
    {
        DrawBitmapText("0", 490, 30 + Adj);
        DrawBitmapText(string, 502, 30 + Adj);
    }
    else
        DrawBitmapText(string, 490, 30 + Adj);

    ToString(day, string);
    DrawBitmapText("Day:", 450, 50 + Adj, 2, 255, 0, 0);
    DrawBitmapText(string, 506, 50 + Adj );
}
/* END */
/* HUD from OZ quest pack - with Fade Effect (minus the borders) */
DrawMenu()
{
    new itemx;
    new itemy;
    new n;
    new Adj = ypos - MaxYPos;
    new suit[4][20] = { "NULL", "playersuit1", "playersuit2", "playersuit3"  };
    new glove[4][20] = { "NULL", "_powerglove1", "_lunarglove1", "_titanmitt1"  };
    new suit_num;
    new string[16];
    new hour = GetHourCount();
    new minute = GetMinuteCount();
    new day = GetDayCount();
    new Dungeon = GetValue("_maplib", 0);

    if ( MenuGoingDown || MenuGoingUp )
        MoveMenu();

    //DrawBorder( x, y, width, height, color )
    // color 0 green; color 8 red; color 16 yellow;
    DrawBorder( 10, 10 , 200, 80, 0 );
    DrawBorder( 220, 10 , 200, 80, 0 );
    DrawBorder( 430, 10 , 200, 80, 0 );
    DrawBorder( 10, 100 , 408, 364, 8 );
    DrawBorder( 430, 100 , 200, 200, 8 );
    DrawBorder( 430, 310, 200, 154, 16 );

    DrawImage("_menuA", 20, 20, 255, 255, 255, Adj, 0, 200);
    DrawImage("_menuB", 232, 22, 255, 255, 255, Adj, 0, 200);

    // Go through each item in the menu and draw them
    for (n = 0; n < NumItems; n++)
        DrawImage( ItemSprites[n], ItemX[n], ItemY[n], 255, 255, 255, Adj, 0, 200 );

    DrawSelectedItems();
    HandleSelection();

    suit_num = CallFunction("player1", true, "GetPlayerSuit", "NULL");
    DrawImage("_menuequip", 460, 320, 255, 255, 255, Adj, 0, 200);
    DrawImage(suit[suit_num], 450, 350, 255, 255, 255, Adj, 0, 200);
    DrawImage(glove[suit_num], 480, 350, 255, 255, 255, Adj, 0, 200);

    if ( Dungeon > 0) {
        if (GetCounterValue("masterKey") == 1)
            DrawImage("_itemkeym", 480, 420, 255, 255, 255, Adj, 0, 200 );
        if (GetValue("_maplib", (Dungeon * 2) - 1))
            DrawImage("_mapitem", 520, 420, 255, 255, 255, Adj, 0, 200 );
        if (GetValue("_maplib", (Dungeon * 2)))
            DrawImage("_compassitem", 560, 420, 255, 255, 255, Adj, 0, 200 );
        DrawImage("_menudungeon", 480, 390, 255, 255, 255, Adj, 0, 200);

    } else {

        if (GetCounterValue("HeartPieces") == 1)
            DrawImage("heart14", 520, 420, 255, 255, 255, Adj, 0, 200 );
        else if (GetCounterValue("HeartPieces") == 2)
            DrawImage("heart24", 520, 420, 255, 255, 255, Adj, 0, 200 );
        else if (GetCounterValue("HeartPieces") == 3)
            DrawImage("heart34", 520, 420, 255, 255, 255, Adj, 0, 200 );
        else
            DrawImage("heartempty", 520, 420, 255, 255, 255, Adj, 0, 200 );
    }

    ToString(hour, string);
    DrawBitmapText(string, 450, 30 , 1, 255, 255, 255, Adj);
    ToString(minute, string);
    if ( strlen(string) == 1 )
    {
        DrawBitmapText("0", 490, 30 , 1, 255, 255, 255, Adj);
        DrawBitmapText(string, 502, 30 , 1, 255, 255, 255, Adj);
    }
    else
        DrawBitmapText(string, 490, 30 , 1, 255, 255, 255, Adj);

    ToString(day, string);
    DrawBitmapText("Day:", 450, 50 + Adj, 2, 255, 0, 0, Adj);
    DrawBitmapText(string, 506, 50 , 1, 255, 255, 255, Adj);
}
/* END */


Simple Quest Intro with Enter Players Name (unfinished)

Submitted by lukex

Main » Code Snipplets (Online Version)

Merge Version of [url=/help/script/704]Simple Quest Intro[/url] and [url=/help/script/715]Enter Players Name[/url]. Can be easier change to password system instead of player name.
note: player name is pointless since the default entities don't support it.

Code

#include <entity>
#include <general>
#include <float>
#include <core>

CONST HardMode = 1; // Use to Set a global later on, change the value if you want to use another global value
CONST TextIntroLength = 4; //Stores how many Text Intro screen the script has

new float: introCount = 0.00;
new TextCount; // Stores what stage the intro in.

/*  This is for the temporary string for name entering */
new player_name[8] = "";
new Current = 0;
new Selected = 0;
new Alphabet[36][2] = {"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9"};

main()
{
    if ( FirstRun() )
    {
        CallFunction("_menulib", false, "ableMenu", "n", false); // On newer _menulib this disables the hud, menu & mape
        SetPauseLevel(1); // pauses game
        PlaySound( "title.it", 128); // Plays Music
        SetActiveFlag("player1", false); // disables Player Script
        SetTextSize( 12 ); // Set
    }
    if (TextCount == TextIntroLength) /* Text Intro has finished display the name input screen */
    {
        EnterName();
        return;
    }
    /* See if User has pressed enter */
    if (EnterKey() && introCount < 160)
    {
        SetEnterKey(false);
        /* if Title hasn't finished, make it do so. Else Start the game  */
        if ( introCount < 128 )
        {
            introCount = 128.00;
            drawtitle();
        }
        else
        {
            TextCount = 4;
                 EnterName();
    }
    }
    else if ( introCount >= 160 )
    {
        /* Title has finished for a while, Start Story  */
        introCount = 160.00;
        if (FinishedReading()) {
            TextCount++;
        }
        switch( TextCount )
        {

        case 0:
            drawintro("Text","Image");
        case 1:
            drawintro("Text","Image");
        case 2:
            drawintro("Text","Image");
        case 3:
            drawintro("Text","Image");
        case 4:
            EnterName();
        }
    } else {
        if (introCount < 160)
            drawtitle();

        introCount += 8.00 * GetTimeDelta();
    }

}

startgame()
{
    /* Set Game to 12 o'clock */
    SetHourCount( 12 );
    SetMinuteCount( 00 );

    CallFunction("_menulib", false, "ableMenu", "n", true); //On newer _menulib this disables the hud, menu & map
    SetActiveFlag("player1", true); // Make Player Active again
    SetPosition("player1", 64, 3000);  //Moves player to starting screen
    SetPauseLevel(0); // Un-pauses
}

drawtitle() {
    /* Insert you own DrawImage/PutSprite here*/
    /* You can use floatround(introCount) here to change RGBA & scale */
}

/* This Functions draw the LTTP like text intro */
drawintro(text[], image[])
{
    DrawImage(image, 320 - (GetWidth(image)/2), 240 - (GetHeight(image)/2));
    InitTextBox(text, 300, false);
}

EnterName()
{
    if (UpKey())
    {
        SetUpKey(false);
        MoveSelection( 20, false );
    }
    else if (DownKey())
    {
        SetDownKey(false);
        MoveSelection( 20, true );
    }
    else if (LeftKey())
    {
        SetLeftKey(false);
       MoveSelection( 1, false );
        }
    else if (RightKey())
    {
        SetRightKey(false);
       MoveSelection( 1, true );
    }

    if (AKey())
    {
        SetAKey(false);
       SetLetter( Current, Selected );
    }
    else if (SKey())
    {
        SetSKey(false);
        MoveCurrent( false );
    }

    if (EnterKey())
    {
        SetEnterKey(false);
        if ( strlen(player_name) > 1 )
        {
        /* if your name is zelda, Global "HardMode" will eq. 1  */
            if ( !strcmp("zelda", player_name) )
        {
                SetGlobal(HardMode, 1);
        }
        SetString("player1", 2, player_name); /* Sets Player name from the temp string
            startgame();
        }
    }
    DisplayAlpha();
    DisplayName();

}
/* These functions just handle the Text Input & Name Display */
SetLetter ( character, letter )
{
    new temp = Alphabet[letter][0];

    player_name[character] = temp;
    MoveCurrent( true );
}

MoveCurrent( foward )
{
    if (foward)
    {
        if ( Current + 1 < 7 )
        {
            Current += 1;
        }
    }
    else
    {
        if ( Current - 1 >= 0)
        {
            Current -= 1;
        }
    }
}
MoveSelection( Amount, foward )
{
    if (foward)
    {
        if ( Selected + Amount < 36 )
        {
            Selected += Amount;
        }
    }
    else
    {
        if ( Selected - Amount >= 0)
        {
            Selected -= Amount;
        }
    }
}
DisplayName()
{
    new x = 40;
    for ( new n = 0; n < 7; n++)
    {
        x += 16;
        if ( Current == n )
            DrawBitmapText(player_name[n], x, 200, 1, 255, 0, 0);
        else
            DrawBitmapText(player_name[n], x, 200, 1);
    }
}

DisplayAlpha()
{
    new x = 40;
    new y = 300;
    for ( new n = 0; n < 36; n++)
    {
        if ( n / 20)
        {
            y += 18;
            x = 40;
        }
        x += 18;

        if ( Selected == n )
            DrawBitmapText(Alphabet[n], x, y, 1, 255, 0, 0);
        else
            DrawBitmapText(Alphabet[n], x, y, 1);
    }
}