User Tag List

Results 1 to 1 of 1

Thread: [Tutorial] ZScripting 'Hello, world of Hyrule!'

  1. #1
    Octorok Asuna Yuuki Nagato's Avatar
    Join Date
    Jan 2024
    Posts
    491
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    vBActivity - Stats
    Points
    43
    Level
    2
    vBActivity - Bars
    Lv. Percent
    37.83%

    [Tutorial] ZScripting 'Hello, world of Hyrule!'

    Today we will making ZScript print "Hello, world of hyrule!" on the screen

    1. File->New
    2. ZScript->Compile ZScript...
    3. Click 'Edit' button
    4. Copy the following into the 'Edit ZScript' window (be careful; an #include is already there):

    Code:
    #include "std.zh"
    
    global script Init
    {
    	void run()
    	{
    		int layer = 1;
    		int x = 0;
    		int y = 0;
    		int font = 0;
    		int color = 1;
    		int format = 0;
    		int bg_color = 0;
    		char32 str = "Hello, world of hyrule!";
    		int opacity = OP_OPAQUE;
    		Screen->DrawString(layer, x, y, font, color, format, bg_color, str, opacity);
    	}
    }
    5. Press Esc
    6. Click 'Yes' to save changes to buffer
    7. Click 'Compile'; ZScript compiler should return code 0 for success
    8. Click 'OK' to dismiss ZScript Parser window
    9. Click 'OK' to dismiss Assign Compiled Script window
    10. Click 'Close' to dismiss "Slots Assigned" msgbox (it should say "ZScripts successfully loaded into script slots")
    11. Click 'OK' to dismiss "Init Script Changed" msgbox
    12. Quest->Test; save quest as "zscript_hello_world_tut.qst"; click 'OK' to dismiss "ZC Editor" window
    13. Click 'Test' in Test Quest window
    14. Observe "Hello, world of hyrule!" briefly appears below the subscreen during iris transition

  2. #2
    Octorok Asuna Yuuki Nagato's Avatar
    Join Date
    Jan 2024
    Posts
    491
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    vBActivity - Stats
    Points
    43
    Level
    2
    vBActivity - Bars
    Lv. Percent
    37.83%
    The problem with the above example is that the text quickly disappears. Now we will be fixing that. First go back to the 'Edit ZScript' window and change the name of the script from "Init" to "HelloWorld":

    Code:
    global script HelloWorld
    Also make sure DrawString is called in a loop:

    Code:
    		while(true) {
    			Screen->DrawString(layer, x, y, font, color, format, bg_color, str, opacity);
    			Waitframe();
    		}
    Now recompile. Then in the Assign Compiled Script window, in the Global tab:

    1. Select "Active:" in the left listbox
    2. Select "HelloWorld" in the right listbox
    3. Click '<<'
    4. Click 'OK' - the script should be successfully loaded into the slot
    5. Test again; the text should stay underneath the subscreen now

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
About us
Armageddon Games is a game development group founded in 1997. We are extremely passionate about our work and our inspirations are mostly drawn from games of the 8-bit and 16-bit era.
Social