Script: Remove ScriptGo, ScriptCounter, goto and the ScriptN callbacks

No scenario uses them, and ScheduleCall provides an alternative.
rope
Günther Brammer 2011-09-19 21:33:05 +02:00
parent 6f1057c69f
commit 9f180dffee
21 changed files with 4 additions and 240 deletions

View File

@ -80,14 +80,7 @@
{
<funclink>Log</funclink>(&quot;Hello&quot;);
<funclink>CreateObject</funclink>(WindGenerator,250,200);
<funclink>ScriptGo</funclink>(1);
}</code>
<text>Sequential scripting: at the start of a round the internal script counter is set to 0. If sequential scripting has been started with ScriptGo, the counter is increased by one every ten frames and the corresponding script function is called in the scenario script, if defined.</text>
<code>func Script26()
{
<funclink>Log</funclink>(&quot;This function is executed after 260 frames.&quot;);
}</code>
<text>The script counter can also be manually adjusted using <funclink>goto</funclink>() to jump to certain counter positions.</text>
<text>After joining a new player the engine calls the function InitializePlayer in the scenario script for that player. This function is called after the basic player objects as defined in Scenario.txt have been placed, so a preliminary starting position has been selected and the player's crew and starting material and buildings are present. In this function, you can now perform more special initial placement.</text>
<code>func InitializePlayer(int player)
{

View File

@ -15,7 +15,6 @@
<text>Ends the game if it has been running for more than 5 minutes.</text>
</example>
</examples>
<related><funclink>ScriptCounter</funclink></related>
</func>
<author>Sven2</author><date>2002-04</date>
</funcs>

View File

@ -1,23 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<!DOCTYPE funcs
SYSTEM '../../../clonk.dtd'>
<?xml-stylesheet type="text/xsl" href="../../../clonk.xsl"?>
<funcs>
<func>
<title>ScriptCounter</title>
<category>Script</category>
<version>5.1 OC</version>
<syntax><rtype>int</rtype></syntax>
<desc>Prints the current value of the scenario script counter.</desc>
<examples>
<example>
<text>See <funclink>goto</funclink>().</text>
</example>
</examples>
<related>
<funclink>ScriptGo</funclink>
<funclink>goto</funclink>
</related>
</func>
<author>Sven2</author><date>2002-08</date>
</funcs>

View File

@ -1,32 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<!DOCTYPE funcs
SYSTEM '../../../clonk.dtd'>
<?xml-stylesheet type="text/xsl" href="../../../clonk.xsl"?>
<funcs>
<func>
<title>ScriptGo</title>
<category>Script</category>
<version>5.1 OC</version>
<syntax>
<rtype>bool</rtype>
<params>
<param>
<type>bool</type>
<name>start</name>
<desc>Whether to start or stop the counter.</desc>
</param>
</params>
</syntax>
<desc>Starts or stops the scenario script counter.</desc>
<examples>
<example>
<text>See <funclink>goto</funclink>().</text>
</example>
</examples>
<related>
<funclink>goto</funclink>
<funclink>ScriptCounter</funclink>
</related>
</func>
<author>Sven2</author><date>2002-08</date>
</funcs>

View File

@ -1,45 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<!DOCTYPE funcs
SYSTEM '../../../clonk.dtd'>
<?xml-stylesheet type="text/xsl" href="../../../clonk.xsl"?>
<funcs>
<func>
<title>goto</title>
<category>Script</category>
<version>5.1 OC</version>
<syntax>
<rtype>void</rtype>
<params>
<param>
<type>int</type>
<name>counter</name>
<desc>New value for the script counter. The next scenario script function called will be ScriptXXX.</desc>
</param>
</params>
</syntax>
<desc>Sets the script counter for scenario scripts to the specified value. The script counter is responsible for calling the ScriptXXX functions in a scenario script. This does not apply to object scripts - those should be using TimerCall or ActMaps with StartCall/PhaseCall/EndCall.</desc>
<examples>
<example>
<code>
func Initialize()
{
// Start script counter
<funclink>ScriptGo</funclink>(1);
}
func Script10()
{
// Create firestones
<funclink>CastObjects</funclink>(Firestone,10,200, <funclink>Random</funclink>(<funclink>LandscapeWidth</funclink>()), 20);
goto(0);
}</code>
<text>A scenario script: a typical flint rain. Every 100 Frames 10 flints are created.</text>
</example>
</examples>
<related>
<funclink>ScriptGo</funclink>
<funclink>ScriptCounter</funclink>
</related>
</func>
<author>jwk</author><date>2002-04</date>
</funcs>

View File

@ -684,7 +684,6 @@ C4ST_NEW(PlayersStat, "C4Game::Execute Players.Execute")
C4ST_NEW(LandscapeStat, "C4Game::Execute Landscape.Execute")
C4ST_NEW(MusicSystemStat, "C4Game::Execute MusicSystem.Execute")
C4ST_NEW(MessagesStat, "C4Game::Execute Messages.Execute")
C4ST_NEW(ScriptStat, "C4Game::Execute ::GameScript.Execute")
#define EXEC_S(Expressions, Stat) \
{ C4ST_START(Stat) Expressions C4ST_STOP(Stat) }
@ -744,7 +743,6 @@ bool C4Game::Execute() // Returns true if the game is over
//FIXME: C4Application::Execute should do this, but what about the stats?
EXEC_S_DR( Application.MusicSystem.Execute();, MusicSystemStat , "Music")
EXEC_S_DR( ::Messages.Execute(); , MessagesStat , "MsgEx")
EXEC_S_DR( ::GameScript.Execute(iTick10); , ScriptStat , "Scrpt")
EXEC_DR( MouseControl.Execute(); , "Input")
@ -1652,7 +1650,6 @@ void C4Game::CompileFunc(StdCompiler *pComp, CompileSettings comp, C4ValueNumber
pComp->Name("Script");
if (!comp.fScenarioSection)
{
pComp->Value(::GameScript);
pComp->Value(mkParAdapt(ScriptEngine, numbers));
}
pComp->Value(mkParAdapt(mkNamingPtrAdapt(pGlobalEffects, "Effects"), numbers));

View File

@ -57,7 +57,6 @@ C4Console::C4Console(): C4ConsoleGUI()
{
Active = false;
Editing = true;
ScriptCounter=0;
FrameCounter=0;
fGameOpen=false;
@ -142,14 +141,6 @@ void C4Console::UpdateStatusBars()
str.Format("Frame: %i",FrameCounter);
C4ConsoleGUI::DisplayInfoText(CONSOLE_FrameCounter, str);
}
// Script counter
if (::GameScript.Counter!=ScriptCounter)
{
ScriptCounter=::GameScript.Counter;
StdStrBuf str;
str.Format("Script: %i",ScriptCounter);
C4ConsoleGUI::DisplayInfoText(CONSOLE_ScriptCounter, str);
}
// Time & FPS
if ((Game.Time!=Time) || (Game.FPS!=FPS))
{

View File

@ -99,7 +99,6 @@ public:
C4ObjectListDlg ObjectListDlg;
C4EditCursor EditCursor;
int ScriptCounter;
int FrameCounter;
int Time,FPS;
#if defined(USE_X11) && !defined(WITH_DEVELOPER_MODE)

View File

@ -99,9 +99,6 @@ void C4ConsoleGUI::DisplayInfoText(C4ConsoleGUI::InfoTextType type, StdStrBuf& t
case CONSOLE_FrameCounter:
label = ctrler(this).frameLabel;
break;
case CONSOLE_ScriptCounter:
label = ctrler(this).scriptLabel;
break;
case CONSOLE_TimeFPS:
label = ctrler(this).timeLabel;
break;
@ -460,4 +457,4 @@ bool C4ConsoleGUI::UpdateModeCtrls(int iMode)
}
#define CONSOLEGUICOMMONINCLUDE
#include "C4ConsoleGUICommon.h"
#include "C4ConsoleGUICommon.h"

View File

@ -146,7 +146,6 @@ public:
GtkWidget* lblCursor;
GtkWidget* lblFrame;
GtkWidget* lblScript;
GtkWidget* lblTime;
GtkWidget* propertydlg;
@ -374,20 +373,15 @@ void C4ConsoleGUI::State::InitGUI()
gtk_container_add(GTK_CONTAINER(status_frame), statusbar);
lblFrame = gtk_label_new("Frame: 0");
lblScript = gtk_label_new("Script: 0");
lblTime = gtk_label_new("00:00:00 (0 FPS)");
gtk_misc_set_alignment(GTK_MISC(lblFrame), 0.0, 0.5);
gtk_misc_set_alignment(GTK_MISC(lblScript), 0.0, 0.5);
gtk_misc_set_alignment(GTK_MISC(lblTime), 0.0, 0.5);
GtkWidget* sep1 = gtk_vseparator_new();
GtkWidget* sep2 = gtk_vseparator_new();
gtk_box_pack_start(GTK_BOX(statusbar), lblFrame, true, true, 0);
gtk_box_pack_start(GTK_BOX(statusbar), sep1, false, false, 0);
gtk_box_pack_start(GTK_BOX(statusbar), lblScript, true, true, 0);
gtk_box_pack_start(GTK_BOX(statusbar), sep2, false, false, 0);
gtk_box_pack_start(GTK_BOX(statusbar), lblTime, true, true, 0);
// ------------ Log view and script entry ---------------------
@ -551,7 +545,6 @@ void C4ConsoleGUI::State::Clear()
lblCursor = NULL;
lblFrame = NULL;
lblScript = NULL;
lblTime = NULL;
handlerDestroy = 0;
@ -577,9 +570,6 @@ void C4ConsoleGUI::DisplayInfoText(InfoTextType type, StdStrBuf& text)
case CONSOLE_FrameCounter:
label = state->lblFrame;
break;
case CONSOLE_ScriptCounter:
label = state->lblScript;
break;
case CONSOLE_TimeFPS:
label = state->lblTime;
}

View File

@ -61,7 +61,6 @@ public:
{
CONSOLE_Cursor,
CONSOLE_FrameCounter,
CONSOLE_ScriptCounter,
CONSOLE_TimeFPS
};

View File

@ -742,9 +742,6 @@ void C4ConsoleGUI::DisplayInfoText(C4ConsoleGUI::InfoTextType type, StdStrBuf& t
case CONSOLE_FrameCounter:
dialog_item = IDC_STATICFRAME;
break;
case CONSOLE_ScriptCounter:
dialog_item = IDC_STATICSCRIPT;
break;
case CONSOLE_TimeFPS:
dialog_item = IDC_STATICTIME;
break;

View File

@ -52,13 +52,6 @@
#include <C4Weather.h>
#include <C4Viewport.h>
static C4Void Fn_goto(C4AulContext *cthr, long iCounter)
{
::GameScript.Counter=iCounter;
return C4Void();
}
static bool FnIncinerateLandscape(C4AulContext *cthr, long iX, long iY)
{
if (cthr->Obj) { iX += cthr->Obj->GetX(); iY += cthr->Obj->GetY(); }
@ -540,12 +533,6 @@ static C4Value FnAddMessage_C4V(C4AulContext *cthr, C4Value *c4vMessage, C4Value
return C4VBool(true);
}
static bool FnScriptGo(C4AulContext *cthr, bool go)
{
::GameScript.Go=!!go;
return true;
}
static long FnMaterial(C4AulContext *cthr, C4String *mat_name)
{
return ::MaterialMap.Get(FnStringPar(mat_name));
@ -1193,11 +1180,6 @@ static bool FnOnMessageBoardAnswer(C4AulContext *cthr, C4Object *pObj, long iFor
return !!scr->Call(PSF_InputCallback, pObj, &C4AulParSet(C4VString(FnStringPar(szAnswerString)), C4VInt(iForPlr)));
}
static long FnScriptCounter(C4AulContext *cthr)
{
return ::GameScript.Counter;
}
static C4Void FnSetFoW(C4AulContext *cthr, bool fEnabled, long iPlr)
{
// safety
@ -2428,7 +2410,6 @@ void InitGameFunctionMap(C4AulScriptEngine *pEngine)
AddFunc(pEngine, "PlaceVegetation", FnPlaceVegetation);
AddFunc(pEngine, "PlaceAnimal", FnPlaceAnimal);
AddFunc(pEngine, "GameOver", FnGameOver);
AddFunc(pEngine, "ScriptGo", FnScriptGo);
AddFunc(pEngine, "GetHiRank", FnGetHiRank);
AddFunc(pEngine, "GetCrew", FnGetCrew);
AddFunc(pEngine, "GetCrewCount", FnGetCrewCount);
@ -2470,7 +2451,6 @@ void InitGameFunctionMap(C4AulScriptEngine *pEngine)
AddFunc(pEngine, "CallMessageBoard", FnCallMessageBoard, false);
AddFunc(pEngine, "AbortMessageBoard", FnAbortMessageBoard, false);
AddFunc(pEngine, "OnMessageBoardAnswer", FnOnMessageBoardAnswer, false);
AddFunc(pEngine, "ScriptCounter", FnScriptCounter);
AddFunc(pEngine, "SetFoW", FnSetFoW);
AddFunc(pEngine, "SetMaxPlayer", FnSetMaxPlayer);
AddFunc(pEngine, "ActivateGameGoalMenu", FnActivateGameGoalMenu);
@ -2539,7 +2519,6 @@ void InitGameFunctionMap(C4AulScriptEngine *pEngine)
AddFunc(pEngine, "SetPlayerControlEnabled", FnSetPlayerControlEnabled);
AddFunc(pEngine, "GetPlayerControlEnabled", FnGetPlayerControlEnabled);
AddFunc(pEngine, "goto", Fn_goto);
AddFunc(pEngine, "IncinerateLandscape", FnIncinerateLandscape);
AddFunc(pEngine, "GetGravity", FnGetGravity);
AddFunc(pEngine, "SetGravity", FnSetGravity);

View File

@ -73,7 +73,6 @@ bool C4ValueToMatrix(const C4ValueArray& array, StdMeshMatrix* matrix);
/* Engine-Calls */
#define PSF_Script "~Script%i"
#define PSF_Initialize "~Initialize"
#define PSF_Construction "~Construction"
#define PSF_Destruction "~Destruction"

View File

@ -30,7 +30,6 @@
IBOutlet NSPopUpButton* materialsPopup;
IBOutlet NSPopUpButton* texturesPopup;
IBOutlet NSTextField* frameLabel;
IBOutlet NSTextField* scriptLabel;
IBOutlet NSTextField* timeLabel;
IBOutlet NSTextView* objectPropertiesText;
IBOutlet NSScrollView* outputScrollView;
@ -41,7 +40,6 @@
IBOutlet NSSegmentedControl* modeSelector;
}
@property(readonly) NSTextField* frameLabel;
@property(readonly) NSTextField* scriptLabel;
@property(readonly) NSTextField* timeLabel;
@property(readonly) NSTextView* outputTextView;
@property(readonly) NSTextView* objectPropertiesText;

View File

@ -29,7 +29,7 @@
@implementation ConsoleWindowController
@synthesize
frameLabel, scriptLabel, timeLabel, outputTextView, objectPropertiesText,
frameLabel, timeLabel, outputTextView, objectPropertiesText,
materialsPopup, texturesPopup, outputScrollView, previewView,
objectsPanel, toolsPanel, toolSelector, modeSelector, objectCombo, consoleCombo;
@ -166,4 +166,4 @@ int indexFromSender(id sender)
@end
#endif
#endif

View File

@ -339,22 +339,6 @@
</object>
</object>
</object>
<object class="NSTextField" id="586873942">
<reference key="NSNextResponder" ref="768161391"/>
<int key="NSvFlags">292</int>
<string key="NSFrame">{{137, 0}, {141, 17}}</string>
<reference key="NSSuperview" ref="768161391"/>
<bool key="NSEnabled">YES</bool>
<object class="NSTextFieldCell" key="NSCell" id="564808166">
<int key="NSCellFlags">68288064</int>
<int key="NSCellFlags2">272630784</int>
<string key="NSContents">Script</string>
<reference key="NSSupport" ref="805367209"/>
<reference key="NSControlView" ref="586873942"/>
<reference key="NSBackgroundColor" ref="43692000"/>
<reference key="NSTextColor" ref="169813348"/>
</object>
</object>
<object class="NSTextField" id="977182517">
<reference key="NSNextResponder" ref="768161391"/>
<int key="NSvFlags">290</int>
@ -1256,14 +1240,6 @@
</object>
<int key="connectionID">107</int>
</object>
<object class="IBConnectionRecord">
<object class="IBOutletConnection" key="connection">
<string key="label">scriptLabel</string>
<reference key="source" ref="1001"/>
<reference key="destination" ref="586873942"/>
</object>
<int key="connectionID">108</int>
</object>
<object class="IBConnectionRecord">
<object class="IBOutletConnection" key="connection">
<string key="label">timeLabel</string>
@ -1514,7 +1490,6 @@
<object class="NSMutableArray" key="children">
<bool key="EncodedWithXMLCoder">YES</bool>
<reference ref="738226569"/>
<reference ref="586873942"/>
<reference ref="977182517"/>
<reference ref="587786245"/>
</object>
@ -1549,20 +1524,6 @@
<reference key="object" ref="926896742"/>
<reference key="parent" ref="738226569"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">101</int>
<reference key="object" ref="586873942"/>
<object class="NSMutableArray" key="children">
<bool key="EncodedWithXMLCoder">YES</bool>
<reference ref="564808166"/>
</object>
<reference key="parent" ref="768161391"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">102</int>
<reference key="object" ref="564808166"/>
<reference key="parent" ref="586873942"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">103</int>
<reference key="object" ref="977182517"/>
@ -2312,7 +2273,6 @@
<string>outputScrollView</string>
<string>outputTextView</string>
<string>previewView</string>
<string>scriptLabel</string>
<string>texturesPopup</string>
<string>timeLabel</string>
<string>toolSelector</string>
@ -2351,7 +2311,6 @@
<string>outputScrollView</string>
<string>outputTextView</string>
<string>previewView</string>
<string>scriptLabel</string>
<string>texturesPopup</string>
<string>timeLabel</string>
<string>toolSelector</string>
@ -2399,10 +2358,6 @@
<string key="name">previewView</string>
<string key="candidateClassName">IKImageView</string>
</object>
<object class="IBToOneOutletInfo">
<string key="name">scriptLabel</string>
<string key="candidateClassName">NSTextField</string>
</object>
<object class="IBToOneOutletInfo">
<string key="name">texturesPopup</string>
<string key="candidateClassName">NSPopUpButton</string>

View File

@ -106,8 +106,6 @@ BEGIN
WS_EX_TRANSPARENT | WS_EX_STATICEDGE
PUSHBUTTON "P",IDC_BUTTONMODEEDIT,217,14,13,12,BS_BITMAP | WS_GROUP
PUSHBUTTON "P",IDC_BUTTONMODEDRAW,217,27,13,12,BS_BITMAP | WS_GROUP
LTEXT "Script: 0",IDC_STATICSCRIPT,55,100,46,11,SS_CENTERIMAGE,
WS_EX_STATICEDGE
LTEXT "0:00:00 (0 FPS)",IDC_STATICTIME,145,100,85,11,
SS_CENTERIMAGE,WS_EX_STATICEDGE
PUSHBUTTON "P",IDC_BUTTONMODEPLAY,217,1,13,12,BS_BITMAP | WS_GROUP

View File

@ -51,7 +51,6 @@
#define IDC_STATICCURSOR 2023
#define IDC_STATICFRAME 2024
#define IDC_STATICMATERIAL 2025
#define IDC_STATICSCRIPT 2026
#define IDC_STATICTEXTURE 2027
#define IDC_STATICTIME 2028
#define IDD_COMPONENT 3000

View File

@ -129,19 +129,9 @@ void C4DefScriptHost::AfterLink()
/*--- C4GameScriptHost ---*/
C4GameScriptHost::C4GameScriptHost(): Counter(0), Go(false) { }
C4GameScriptHost::C4GameScriptHost() { }
C4GameScriptHost::~C4GameScriptHost() { }
bool C4GameScriptHost::Execute(int iTick10)
{
if (!Script) return false;
if (Go && !iTick10)
{
return !! Call(FormatString(PSF_Script,Counter++).getData());
}
return false;
}
C4Value C4GameScriptHost::GRBroadcast(const char *szFunction, C4AulParSet *pPars, bool fPassError, bool fRejectTest)
{
// call objects first - scenario script might overwrite hostility, etc...
@ -152,10 +142,4 @@ C4Value C4GameScriptHost::GRBroadcast(const char *szFunction, C4AulParSet *pPars
return Call(szFunction, 0, pPars, fPassError);
}
void C4GameScriptHost::CompileFunc(StdCompiler *pComp)
{
pComp->Value(mkNamingAdapt(Go, "Go", false));
pComp->Value(mkNamingAdapt(Counter, "Counter", 0));
}
C4GameScriptHost GameScript;

View File

@ -77,16 +77,6 @@ public:
~C4GameScriptHost();
bool Delete() { return false; } // do NOT delete this - it's a global!
C4Value GRBroadcast(const char *szFunction, C4AulParSet *pPars = 0, bool fPassError=false, bool fRejectTest=false); // call function in scenario script and all goals/rules/environment objects
// Global script data
int32_t Counter;
bool Go;
bool Execute(int);
void Clear() { Counter = 0; Go = false; C4ScriptHost::Clear(); }
// Compile scenario script data
void CompileFunc(StdCompiler *pComp);
};
extern C4GameScriptHost GameScript;