Duke4.net Forums: [Tutorial] Eduke32 CON Setup: Hello, World! - Duke4.net Forums

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

[Tutorial] Eduke32 CON Setup: Hello, World!

User is online   void22790 

#1

0.1.1 Introduction

While old CON tutorials and guides provide good learning material, they often recommend starting by modifying parameters in the game’s three CON files (GAME.CON, USER.CON, and
DEFS.CON).This was a great starting point for many users back in the day, and it’s still useful to read through them to understand how things work. However, I believe this is no longer
the right approach for modern learning and modding with EDuke32. This issue still persists today: most mods you download use obscure methods for installation and launching. This is a
shame, because modern EDuke32 offers a very simple setup pipeline for loading custom files. Let’s look at the easiest way to create and load your first custom CON file, and how to make
your future scripting more efficient.


0.1.2 Quick Start

First, I’ll assume that you have already set up EDuke32 and that Duke Nukem 3D is running smoothly on your computer. Next, choose any text editor you like: Vim, Visual Studio Code,
Notepad, you name it. The only requirement is that your text editor can edit and save plain text files. And just like that, your programming environment is ready to go.

Posted Image
Classic Vim interface.

Before we start scripting, let’s configure a faster game startup. The normal launch sequence takes time by showing port setup parameters, logos, and the main menu. This might sound
unnecessary, but believe me, when you’re programming and testing your mod, every second counts! That’s why it’s crucial to make the startup as fast and convenient as possible. We
can do this by launching the EDuke32 binary with special flags. You can find the full list of flags here. Before using the flags, it’s a good idea to launch EDuke32 at least once to set
your preferred screen resolution and renderer.

To quickly launch and test your mod, we need to use a terminal. Just like with a text editor, it doesn’t matter which terminal you prefer, a basic terminal provided by your OS will work
perfectly. On Windows, press Win + R, type cmd, and press OK. This will open the standard terminal. Next, navigate to your EDuke32 folder by entering:

cd C:\YourEduke32Path


You can either copy the full path from the address bar and paste it, or type it manually. Press Enter to change the directory. On Linux, press Ctrl + Alt + T to open the terminal then proceed
with the same steps. Another convenient option is to open your EDuke32 folder in your file explorer, right-click to open the context menu, and choose “Open in Terminal”. In your terminal,
make sure you are in the directory containing the EDuke32 binary (eduke32.exe on Windows, eduke32 on Linux). Then enter:

eduke32 -nologo -quick -nosetup -map E1L1.map 


and press Enter. This will launch the game and immediately load the Hollywood Holocaust level. You can modify or add more flags, but this is the bare minimum needed for a quick game
start. Flags are very useful and can also be applied when launching Mapster32, the level editor.


0.1.3 Scripting

Now that we are all set and ready, let’s write our first script, which will greet us with “Hello, World!” when the level loads. EDuke32 is designed to be intelligent: upon startup, it
automatically searches for eduke.con in the root directory. This file serves as the primary entry point for any mod, orchestrating the loading of additional scripts as they are developed.
Create a file named eduke.con in the same directory as the EDuke32 binary, and open it using your preferred text editor. Ensure that the file extension is .CON and not any other,
such as .txt. Since we are not developing a standalone game or a total conversion, the first step is to include the default game scripts:

include GAME.CON 
include USER.CON


Try removing include GAME.CON and observe the game’s behavior. You will quickly discover that either the level cannot be entered, or the player will die immediately. This occurs
because eduke.con ignores other scripts unless they are explicitly included, resulting in the loss of essential game logic. At this stage, we can proceed with creating our custom script.
Enter the following lines:

define HELLO_WORLD 125 
definequote HELLO_WORLD Hello, World!


The define <name> <number> command tells the game to replace every occurrence of <name> within the file with <number>. This is useful for defining constants or assigning
meaningful names to numeric values. The definequote command is used to assign the string "Hello, World!" to a unique ID (remember that HELLO_WORLD will be replaced with 125).
After that we need to tell the game when we want to print this string, and we can do it using events. Enter next:

onevent EVENT_ENTERLEVEL
    quote HELLO_WORLD
endevent


This event will trigger only once when the player enters any level, which is perfect for our purposes, unless we want to print endless greetings. The quote command requires a string ID
and displays the associated string both at the top of the screen and in the console. Save your file and use the terminal to launch EDuke32 with the flags we provided earlier. You should
see the quote briefly displayed at the top of the screen. Press ~ to open the console, and you will see the same quote printed there as well.



Postscript

That concludes the minimal setup required to begin writing custom scripts. You may consolidate all content within a single file or distribute it across multiple CON files, just ensure
each additional file is properly referenced in eduke.con. Players will be able to run your mod simply by launching the EDuke32 binary. There is no need to provide extra batch or shell
scripts, as many mod authors do; such additions can be misleading to the typical user and compromise cross-platform compatibility.

Try this:

1. Modify the greeting to display “Hello, Duke!” or a custom name of your choice.
2. Use the quote command with ID 7. What message is displayed?
3. Define an additional quote using a numeric ID and print it. Do you know why custom IDs start at 125?

Solutions:

Exercise 1
Spoiler

Exercise 2
Spoiler

Exercise 3
Spoiler

7

User is offline   stillTodd 

#2

Bravo!

Liking your writing style a lot. I used to author training stuff, and this was a level of quality that was aspired to.
0

User is offline   Reaper_Man 

  • Once and Future King

#3

Your post contains images that appear hosted in a discord URL, which doesn't work as those URLs expire. A few years ago Discord stopped letting people use them as an image/file host for things like this. However you should be able to upload and attach files to your posts, including images.
1

User is offline   Perro Seco 

#4

I guess your post looks good on your screen, but in mine it's filled with random line breaks everywhere, which makes it difficult to read. I hope you can remove them and also continue with more tutorials!
0

User is online   void22790 

#5

Thank you all for your feedback, I really appreciate it and will consider your suggestions in my future articles.
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic


All copyrights and trademarks not owned by Voidpoint, LLC are the sole property of their respective owners. Play Ion Fury! ;) © Voidpoint, LLC

Enter your sign in name and password


Sign in options