• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
abrken

Adding script to already built script code

4 posts in this topic

Hello, I don't know how to make this : 1/ I got some script that are built using engine->AddScriptSection() then engine->Build(..) . The script is made of different functions (engine->AddScriptSection). 2/ When I want one function to execute, I call engine->GetFunctionIDByName() then context->Prepare() and context->Execute(). The Problem : A function call can result in a new script. The resulting script can call function(s) that have been built in 1/ . What I have tried : Using the same module name, I call engine->AddScriptSection() then engine->build() result in only new ScriptSection added that could be used. The other functions that have been build in 1/ are deleted (Reset()). Using another module name, I'm doing the same and the result is the same. Question: How can I make it ? Does the module implementation that's been discussed in thread "Call into a Module" (module::function) is being developped ? Thank's for any suggestion. AbrKen
0

Share this post


Link to post
Share on other sites
I don't think that what you want is currently possible. You might be able to do it using ExecuteString().

What exactly do you need the script to generate another script? It might be possible to change you method to not use this.
0

Share this post


Link to post
Share on other sites
What I'm doing is a kind of browser where there is no Internet.

You navigate in an Xml defined tree. To Navigate you define some hot spots (or hot keys) that when clicked (or pushed) execute some scripts (that can result in navigation) or just navigate.

Those scripts could result in database access to generate new pages or just picture grabbing that have hot spot dynamically defined, and of course the resulting hot spot action can be just navigate or execute some script.

Those dinamicaly generated scripts can use global functions defined in the global Xml tree.

sample :

<XPNTree>
<TIMEOUT Elapse=30000/>
<COMMON>
<CODE Name="GLOBAL">
<!--
bool AddCharToCode(bstr &in_bStrChar) {
bool bRet = false;
CLuaXmlPresenter *xmlPresenter;
bstr bstrCodeActif;
int iTextActif;

Navigator.ResetTimeoutTimer();

xmlPresenter = getReferencedPresenter("XPNPresenter");
bstrCodeActif = GetReferencedVarCString("CODE ACTIF");
iTextActif = GetReferencedVarInt("TEXT ACTIF");

if (xmlPresenter != 0) {
CLuaXmlPresenterElementText *xmlText = xmlPresenter->GetText(iTextActif);
CLuaXmlPresenterElementText *xmlTextMsg = xmlPresenter->GetText(70);
if (xmlText != 0 && xmlTextMsg != 0) {
CString textString;
int iLen;

xmlTextMsg->SetText(textString);
textString = GetReferencedVarCString(bstrCodeActif);
iLen = textString.GetLength();
if (iLen < 4) {
CString csTextEchoed;
textString += in_bStrChar;
iLen++;
UpdReferencedVar(bstrCodeActif, textString);
while (iLen > 0) {
csTextEchoed += "*";
iLen--;
}
xmlText->SetText(csTextEchoed);
xmlText->Display(0, true);
bRet = true;
if (textString.GetLength() == 4) {
if (iTextActif == 50) {
csTextEchoed = "CODE2";
iTextActif = 60;
UpdReferencedVar("CODE ACTIF", csTextEchoed);
UpdReferencedVar("TEXT ACTIF", iTextActif);
csTextEchoed = "Saisissez à nouveau votre code.";
xmlTextMsg->SetText(csTextEchoed);
}
}
}
else {
MessageBeep(0);
}
xmlTextMsg->Display(0, true);
}
}
return bRet;
}

bool DelLastCharToCode() {
bool bRet = false;
CLuaXmlPresenter *xmlPresenter;
bstr bstrCodeActif;
int iTextActif;

Navigator.ResetTimeoutTimer();

PrintTrace("Retour Arrière");

xmlPresenter = getReferencedPresenter("XPNPresenter");
bstrCodeActif = GetReferencedVarCString("CODE ACTIF");
iTextActif = GetReferencedVarInt("TEXT ACTIF");

if (xmlPresenter != 0) {
CLuaXmlPresenterElementText *xmlText = xmlPresenter->GetText(iTextActif);
if (xmlText != 0) {
CString textString;
int iLen;
textString = GetReferencedVarCString(bstrCodeActif);
iLen = textString.GetLength();

if (iLen == 0 && iTextActif == 60) {
textString = "CODE1";
iTextActif = 50;
UpdReferencedVar("CODE ACTIF", textString);
UpdReferencedVar("TEXT ACTIF", iTextActif);
bstrCodeActif = textString;
textString = GetReferencedVarCString(bstrCodeActif);
iLen = textString.GetLength();
xmlText = xmlPresenter->GetText(iTextActif);
}

if (xmlText != 0 && iLen > 0) {
CString csTextEchoed;
iLen--;
textString.Delete(iLen, 1);
UpdReferencedVar(bstrCodeActif, textString);
while (iLen > 0) {
csTextEchoed += "*";
iLen--;
}
xmlText->SetText(csTextEchoed);
xmlText->Display(0, true);
bRet = true;
}
else {
MessageBeep(0);
}
}
}

return bRet;
}

bool ValidateCode() {
bool bRet = false;
CLuaXmlPresenter *xmlPresenter;
int iTextActif;

Navigator.ResetTimeoutTimer();
PrintTrace("Validation");

xmlPresenter = getReferencedPresenter("XPNPresenter");
iTextActif = GetReferencedVarInt("TEXT ACTIF");
if (xmlPresenter != 0) {
CLuaXmlPresenterElementText *xmlTextMsg = xmlPresenter->GetText(70);
if (xmlTextMsg != 0) {
CString csCode1, csCode2;
csCode1 = GetReferencedVarCString("CODE1");
csCode2 = GetReferencedVarCString("CODE2");
if (csCode1.GetLength() == 4 &&
csCode1 == csCode2) {
csCode1 = "CBAboTmpFra";
bRet = Navigator.AskForNavigate(csCode1);
}
else {
csCode1 = "Votre saisie est incorrecte! Saisir 4 chiffres.";
xmlTextMsg->SetText(csCode1);
xmlTextMsg->Display(0, true);
}
}
}
return bRet;
}
-->
</CODE>
<CODE Name="TheOtherCode">
<!--
bstr bstrTmp;
string strTmp;
CString csTmp;
CLuaXmlPresenter *xmlPresenter;

xmlPresenter = getReferencedPresenter("XPNPresenter");

if (xmlPresenter != 0) {
CXmlParameter xmlParam;
CXmlNode *pSubNode = 0;
bool bFound;

xmlParam.m_strName = "Id";
xmlParam.m_strValue = "10";

strTmp = "BITMAP";

bFound = xmlPresenter->findSubNode(strTmp, xmlParam, pSubNode);

if (bFound == true) {
strTmp = "DST_X";
bFound = pSubNode->getParameterValue(strTmp, xmlParam);
if (bFound == true) {
xmlParam.m_strValue = "10";
pSubNode->updXmlParameter(xmlParam);
}

strTmp = "DST_Y";
bFound = pSubNode->getParameterValue(strTmp, xmlParam);
if (bFound == true) {
xmlParam.m_strValue = "10";
pSubNode->updXmlParameter(xmlParam);
}

strTmp = "DST_CX";
bFound = pSubNode->getParameterValue(strTmp, xmlParam);
if (bFound == true) {
xmlParam.m_strValue = "100";
pSubNode->updXmlParameter(xmlParam);
}

strTmp = "DST_CY";
bFound = pSubNode->getParameterValue(strTmp, xmlParam);
if (bFound == true) {
xmlParam.m_strValue = "100";
pSubNode->updXmlParameter(xmlParam);
}
}
}
-->
</CODE>
<CODE Name="FlipImage">
<!--
bstr bstrTmp;
string strTmp;
CLuaXmlPresenter *xmlPresenter;

xmlPresenter = getReferencedPresenter("XPNPresenter");

if (xmlPresenter != 0) {
CLuaXmlPresenterElementBitmap *xmlBitmap;
xmlBitmap = xmlPresenter->GetBitmap(10);
if (xmlBitmap != 0) {
CImage *imageBitmap;
imageBitmap = xmlBitmap->GetImageBitmap();
if (imageBitmap != 0) {
imageBitmap->Flip();
xmlBitmap->Display(0, true);
}
}
}
-->
</CODE>
</COMMON>
<PAGE Name="AcceuilFra" File="Acceuil.xml" Default=1>
<TIMEOUT Elapse=0/>
<MOUSE>
<RECT Coord="0183,0012,0225,0041">
<NAV Name="AcceuilEng"/>
</RECT>
<RECT Coord="0289,0012,0328,0041">
<EXEC>
<!--FlipImage();-->
</EXEC>
</RECT>
<CIRC Coord="0024,0441,0074,0471">
<NAV Name="DispoFra"/>
</CIRC>
<CIRC Coord="0570,0441,0620,0471">
<NAV Name="EntreeFra"/>
</CIRC>
</MOUSE>
<OnBeforeParse>
<!--TheOtherCode();-->
</OnBeforeParse>
</PAGE>
<PAGE Name="AcceuilEng" File="Acceuil.xml">
<MOUSE>
<RECT Coord="0183,0012,0225,0042">
<NAV Name="AcceuilFra"/>
</RECT>
<POLY Coord="0235,0060,0260,0060,0228,0081,0228,0097,0244,0097,0222,0113,0205,0099,0220,0097,0220,0075,0235,0061">
<EXEC>
<!--FlipImage();-->
</EXEC>
</POLY>
</MOUSE>
<OnBeforeParse>
<!--TheOtherCode();-->
</OnBeforeParse>
</PAGE>
<PAGE Name="DispoFra" File="Disponibilite.xml">
<MOUSE>
<CIRC Coord="0024,0441,0074,0471">
<NAV Name="AcceuilFra"/>
</CIRC>
</MOUSE>
</PAGE>
<PAGE Name="EntreeFra" File="MenuPrincipal.xml">
<MOUSE>
<CIRC Coord="0024,0441,0074,0471">
<NAV Name="AcceuilFra"/>
</CIRC>
<CIRC Coord="0435,0131,0485,0161">
<NAV Name="AbonneFra"/>
</CIRC>
<CIRC Coord="0437,0199,0487,0229">
<NAV Name="AboTmpFra"/>
</CIRC>
<CIRC Coord="0437,0262,0487,0292">
<NAV Name="AcceuilFra"/>
</CIRC>
<CIRC Coord="0437,0325,0487,0355">
<NAV Name="AcceuilFra"/>
</CIRC>
</MOUSE>
</PAGE>
<PAGE Name="AbonneFra" File="AccesAbonne.xml">
<MOUSE>
<CIRC Coord="0024,0441,0074,0471">
<NAV Name="EntreeFra"/>
</CIRC>
<CIRC Coord="0570,0441,0620,0471">
<NAV Name="AcceuilFra"/>
</CIRC>
</MOUSE>
</PAGE>
<PAGE Name="AboTmpFra" File="AccesAboTmp.xml">
<MOUSE>
<CIRC Coord="0024,0441,0074,0471">
<NAV Name="EntreeFra"/>
</CIRC>
<CIRC Coord="0570,0441,0620,0471">
<NAV Name="SaisieCodeAboTmpFra"/>
</CIRC>
</MOUSE>
</PAGE>
<PAGE Name="SaisieCodeAboTmpFra" File="SaisieCodeAboTmp.xml">
<TIMEOUT Elapse=5000>
<NAV Name="EntreeFra"/>
</TIMEOUT>
<OnBeforeStart>
<!--
CString textString;
int iTextZone;
ReferenceVar("CODE1", textString);
ReferenceVar("CODE2", textString);
ReferenceVar("CODE ACTIF", textString);
ReferenceVar("TEXT ACTIF", iTextZone);
textString.Empty();
UpdReferencedVar("CODE1", textString);
UpdReferencedVar("CODE2", textString);
textString = "CODE1";
UpdReferencedVar("CODE ACTIF", textString);
iTextZone = 50;
UpdReferencedVar("TEXT ACTIF", iTextZone);
-->
</OnBeforeStart>

<MOUSE>
<CIRC Coord="0024,0441,0074,0471">
<NAV Name="EntreeFra"/>
</CIRC>
<CIRC Coord="0344,0117,0400,0148">
<EXEC>
<!--
AddCharToCode("1");
-->
</EXEC>
</CIRC>
<CIRC Coord="0424,0117,0480,0148">
<EXEC>
<!--
AddCharToCode("2");
-->
</EXEC>
</CIRC>
<CIRC Coord="0502,0117,0558,0148">
<EXEC>
<!--
AddCharToCode("3");
-->
</EXEC>
</CIRC>
<CIRC Coord="0346,0318,0402,0374">
<EXEC>
<!--
DelLastCharToCode();
-->
</EXEC>
</CIRC>
<CIRC Coord="0504,0318,0560,0374">
<EXEC>
<!--
ValidateCode();
-->
</EXEC>
</CIRC>
</MOUSE>
<KEYBOARD>
<KEY Name="VK_0"><EXEC><!--if (Navigator.m_bKeyDown) AddCharToCode("0");--></EXEC></KEY>
<KEY Name="VK_1"><EXEC><!--if (Navigator.m_bKeyDown) AddCharToCode("1");--></EXEC></KEY>
<KEY Name="VK_2"><EXEC><!--if (Navigator.m_bKeyDown) AddCharToCode("2");--></EXEC></KEY>
<KEY Name="VK_3"><EXEC><!--if (Navigator.m_bKeyDown) AddCharToCode("3");--></EXEC></KEY>
<KEY Name="VK_4"><EXEC><!--if (Navigator.m_bKeyDown) AddCharToCode("4");--></EXEC></KEY>
<KEY Name="VK_5"><EXEC><!--if (Navigator.m_bKeyDown) AddCharToCode("5");--></EXEC></KEY>
<KEY Name="VK_6"><EXEC><!--if (Navigator.m_bKeyDown) AddCharToCode("6");--></EXEC></KEY>
<KEY Name="VK_7"><EXEC><!--if (Navigator.m_bKeyDown) AddCharToCode("7");--></EXEC></KEY>
<KEY Name="VK_8"><EXEC><!--if (Navigator.m_bKeyDown) AddCharToCode("8");--></EXEC></KEY>
<KEY Name="VK_9"><EXEC><!--if (Navigator.m_bKeyDown) AddCharToCode("9");--></EXEC></KEY>
<KEY Name="VK_NUMPAD0"><EXEC><!--if (Navigator.m_bKeyDown) AddCharToCode("0");--></EXEC></KEY>
<KEY Name="VK_NUMPAD1"><EXEC><!--if (Navigator.m_bKeyDown) AddCharToCode("1");--></EXEC></KEY>
<KEY Name="VK_NUMPAD2"><EXEC><!--if (Navigator.m_bKeyDown) AddCharToCode("2");--></EXEC></KEY>
<KEY Name="VK_NUMPAD3"><EXEC><!--if (Navigator.m_bKeyDown) AddCharToCode("3");--></EXEC></KEY>
<KEY Name="VK_NUMPAD4"><EXEC><!--if (Navigator.m_bKeyDown) AddCharToCode("4");--></EXEC></KEY>
<KEY Name="VK_NUMPAD5"><EXEC><!--if (Navigator.m_bKeyDown) AddCharToCode("5");--></EXEC></KEY>
<KEY Name="VK_NUMPAD6"><EXEC><!--if (Navigator.m_bKeyDown) AddCharToCode("6");--></EXEC></KEY>
<KEY Name="VK_NUMPAD7"><EXEC><!--if (Navigator.m_bKeyDown) AddCharToCode("7");--></EXEC></KEY>
<KEY Name="VK_NUMPAD8"><EXEC><!--if (Navigator.m_bKeyDown) AddCharToCode("8");--></EXEC></KEY>
<KEY Name="VK_NUMPAD9"><EXEC><!--if (Navigator.m_bKeyDown) AddCharToCode("9");--></EXEC></KEY>
<KEY Name="VK_RETURN"><EXEC><!--if (Navigator.m_bKeyDown) ValidateCode();--></EXEC></KEY>
<KEY Name="VK_BACK"><EXEC><!--if (Navigator.m_bKeyDown) DelLastCharToCode();--></EXEC></KEY>
</KEYBOARD>
</PAGE>
<PAGE Name="CBAboTmpFra" File="CBAboTmpFra.xml">
<TIMEOUT Elapse=30000>
<NAV Name="EntreeFra"/>
</TIMEOUT>
<MOUSE>
<CIRC Coord="0024,0441,0074,0471">
<NAV Name="EntreeFra"/>
</CIRC>
</MOUSE>
</PAGE>
</XPNTree>



In this sample you can see in XPNTree.COMMON a tag named CODE with name="GLOBAL". There you can find some AngelScript Global Functions that are used somewhere else (see near the end of the xml the AddCharToCode function call).

0

Share this post


Link to post
Share on other sites
It is not yet possible to make calls between modules. This is coming in a near future. Can't say exactly when, but hopefully with version 1.9.0.

The current recommendation is to concatenate the scripts and rebuild them all. That is, call AddScriptSection() with the global scripts again, then AddScriptSection() with the new scripts, then Build(). You'll need to do this each time any part of the script changes.

0

Share this post


Link to post
Share on other sites
Thank's for the replies.

Quote:
This is coming in a near future.


I'm going to wait for 1.9.x, until then Global script functions wont be callable by added script.
0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0