Some quick notes I made after my first day with SLIC(preying that it will format correctily ):
Beginners intro to SLIC
With my first SLIC code done, I went into CTP, and what did I see? Nothing. So here I present to you
“How to get your code to work”
For this I will describe two things.
1. Events that only appear at the start.
2. Events that appear every turn.
1. To get an event to appear only once is simple once you know how. Here it is.
First create your ‘handle’ (Just a name for each bit of code)
The priority of the handler can be either pre or post. A "pre" handler runs before the in-game code, a "post" handler runs afterwards.
Now I will explain how to get a message box with your name in it to appear!
Where I have written ‘//Your code here’ replace with
where name, is an variable name you please.
Now for sanity’s sake (since in large scenarios there are hundreds of messages) you can put your message descriptions in another SLIC file.
Call it ‘msg.slc’
To use this file in your program, on the very last line of your scenario.slc write
Now how do we define what we say in our message?
Well this describes a basic message box, that only has an exit button.
First you open up your ‘msg.slc’
Then type in the following
Don’t worry if this looks confusing at first I will explain. In the first line, replace ‘name’ with the name you used in ‘scenario.slc’. The first line is telling the game this is that particulare message box.
The 3rd line says Show (). This should be self-explanatory; you don’t want a hidden message box. The next line is a bit more confusing. It the title of the message box, and the title will be in the string Title. Where is this string held?
Look in your scen000 dir. Then create a new directory called english, and then a new directory in that called gamedata. Then create a text file called scen_str. That is where the string Title is held. Open it up.
Type like this
Now you should understand up to line 6 in the code.
Lines 7-10 are easy to expain:
Button(ID_EXIT), is like title and text. In your scen_str file you should write
Line 9 means, that when you click on that button the message box disappears. Simple, huh? Now since this is the messagebox we only want to appear on the first turn we do this next
This means that from now on this will not run.
Next we want a message box that appears each turn and shows you the turn no.
Here is how:
Create another handle.
Then we create the message box:
Then we edit the ‘msg.slc’ file to make the msg appear
Also update scen_str
All that is new here is g.year, which accesses what year it is up to in the game. Now since we want it every turn we don’t do DisableTrigger. That is it.
Appendix A.
Here are my completed files with there variable names
scenario.slc
msg.slc
scen_str.txt
Beginners intro to SLIC
With my first SLIC code done, I went into CTP, and what did I see? Nothing. So here I present to you
“How to get your code to work”
For this I will describe two things.
1. Events that only appear at the start.
2. Events that appear every turn.
1. To get an event to appear only once is simple once you know how. Here it is.
First create your ‘handle’ (Just a name for each bit of code)
Code:
HandleEvent(EventName) 'HandlerName' [pre | post] { // Your code here }
Now I will explain how to get a message box with your name in it to appear!
Where I have written ‘//Your code here’ replace with
Code:
Message (g.player, 'Name');
Now for sanity’s sake (since in large scenarios there are hundreds of messages) you can put your message descriptions in another SLIC file.
Call it ‘msg.slc’
To use this file in your program, on the very last line of your scenario.slc write
Code:
#include “msg.slc”;
Well this describes a basic message box, that only has an exit button.
First you open up your ‘msg.slc’
Then type in the following
Code:
messagebox 'Name' { Show(); Title(ID_TITLE); Text(ID_TEXT); Button(ID_EXIT) { Kill(); } }
The 3rd line says Show (). This should be self-explanatory; you don’t want a hidden message box. The next line is a bit more confusing. It the title of the message box, and the title will be in the string Title. Where is this string held?
Look in your scen000 dir. Then create a new directory called english, and then a new directory in that called gamedata. Then create a text file called scen_str. That is where the string Title is held. Open it up.
Type like this
Code:
TITLE "Title of your message box here" TEXT "Text of your message box here”
Lines 7-10 are easy to expain:
Button(ID_EXIT), is like title and text. In your scen_str file you should write
Code:
EXIT “Exit”
Code:
DisableTrigger('HandlerName');
Next we want a message box that appears each turn and shows you the turn no.
Here is how:
Code:
HandleEvent(EventName) 'Name' [pre | post]
Then we create the message box:
Code:
Message (g.player, ‘msgtype’);
Code:
messagebox 'EveryTurn' { Show(); Title(ID_DROUGHT_TITLE); Text(ID_DROUGHT_TEXT); Button(ID_EXIT) { Kill(); } }
Code:
DROUGHT_TITLE "Turn # DROUGHT_TEXT "Turn {g.year}"
Appendix A.
Here are my completed files with there variable names
scenario.slc
Code:
///////////////////////// // Do At the beginning // ///////////////////////// HandleEvent(BeginTurn) 'DStart_F' pre { Message (g.player, 'AGStartA'); DisableTrigger('DStart_F'); } ////////////////////////// // Do Every Turn // ////////////////////////// HandleEvent(BeginTurn) 'D_EveryTurn' pre { Message (g.player, 'EveryTurn'); } #include "msg.slc"
Code:
messagebox 'AGStartA' { Show(); Title(ID_AG_START_TITLE); Text(ID_AG_START_A); Button(ID_EXIT) { Kill(); } } messagebox 'EveryTurn' { Show(); Title(ID_DROUGHT_TITLE); Text(ID_DROUGHT_TEXT); Button(ID_EXIT) { Kill(); } }
Code:
EXIT "Exit" AG_START_TITLE "Natural Disasters" AG_START_A "Made by heardie" DROUGHT_TITLE "Drought strikes your Civ!" DROUGHT_TEXT "Year {g.year}"
Comment