"sectionstart" ? [Solved]

Started by H.Randt, Sun 03/02/2013 16:25:59

Previous topic - Next topic

H.Randt

I was reading the Demo Quest 3-1's scripting when I saw a piece of code I didn't understand:

Code: AGS
//===================================================================
// Interaction Handler Functions
//-------------------------------------------------------------------
#sectionstart room_a  // DO NOT EDIT OR REMOVE THIS LINE
function room_a() {
	// script for room: Player enters screen (before fadein)

	// Set graphic according to Ags Terminal selection
	oCrack.Graphic = AgsTerm[AgsTermId[0]].CrackSpr;

	// Setup Help GUI
	gHelpTitle.Text = "Crack In Wall";
	gHelpDescription.Text = "This room demonstartes the use of global variables and custom data types to coordinate actions between multiple rooms.";
	gHelpReference.Text = "Manual Reference:[ global variable, struct, custom data type, import, export";    
}
#sectionend room_a  // DO NOT EDIT OR REMOVE THIS LINE

#sectionstart hotspot1_b  // DO NOT EDIT OR REMOVE THIS LINE
function hotspot1_b() {
	// script for hotspot1: Look at hotspot
	Display("It's that wall with a crack."); 
}
#sectionend hotspot1_b  // DO NOT EDIT OR REMOVE THIS LINE


What is the meaning of "#sectionstart/end" and why use it? o.o"

Ghost

#1
#sectionstart and #sectionend are IDE commands to create a, well, section of code. These sections can be collapsed so that groups of code can be created and "hidden" to make the script easier to read. It's a handy command if you're dealing with long scripts.

Currently AGS doesn't support the command at all, as it seems, but IIRC it's implemented in the "Drakonian Edition" (one of several in-development versions of AGS).

[edit]
Demo Quest was made with AGS 2.something I think; at least it's from a pretty old version. It's safe to delete these lines- they are used in OLD versions of AGS and don't do anything. The comment says you must "not edit or delete this line", but I've been assured AND I have checked that this isn't actually true.

H.Randt

Thanks Ghost!

I have a new doubt then. I don't know why use "function room_a()" o.o Besides... it's needed put #sectionstar room_a to use "function room_a()"? Because the room's name isn't "room_a"... @.@

Crimson Wizard

#3
That's common function names used by older AGS versions. Probably event handlers were not customizable back then, and used predefined names, like "room_a" for "room load" event, "room_b" for "after fade-in" and sort of that.

I think "sectionstart" and "sectionend" were used by editor to distinguish parts of code. AGS 2.72 had a way to display only certain parts of script in text editor.

Oldschool AGS users will correct me if I am wrong.

Khris

Yes, this is from a time when you had to use the interaction editor, even if all you did was add a RunScript action. If you chose to edit a RunScript action's commands you'd only see the lines of the room script in between the corresponding #sectionstart and #sectionend lines.
As of AGS 3, functions are named room_Load, room_AfterFadein, etc. by default, you can change the function's name if you want, and you always see the entire room script in "edit mode" (which eliminated the need for #section lines).

room_a() doesn't refer to a specific room; each room's first RunScript action created room_a(), the next created room_b(), etc. AGS would also use the #section lines to remove a function from the script if you deleted a RunScript action in the Interaction Editor.

Long story short, the #section lines are not used any longer and can be deleted.

H.Randt

OOohm! Thanks! I think I understand it better now : )

SMF spam blocked by CleanTalk