Non-threaded

Forums » Advanced Editor Forum » Read Thread

Get help from the experts on variables, scripts, items, and other scary things.

Master Script:

8 years ago

Hi there.  In more advanced programming languages, there exists functions and object oriented programming.

You can define classes that act as entry points to your function.

class BeginStory

def entryFunction

%Dest : = 1

%HP := 10

end def

end class

 

And to execute this bad boy, you can create an object:

$object := new $BeginStory

$object.entryFunction

 

But it doesn't appear that any such behaviors exist in the advanced scripting editor.  So what acts as the entry point for the adventure when it begins?  Do functions exist?

Master Script:

8 years ago

It's pretty basic. We don't even have strings.

Master Script:

8 years ago
There's no functions. Or loops. Or strings. Or Arrays.

You get ints and basic if structures. Math is also only basic four operators (division truncates).

The "entry point" is the first page. Scripts are executed on whatever page/link you put them on (global page/link scripts execute on every page/link execution).

All variables must be declared on the variables page. They cannot be used in scripts otherwise.

Variables are referenced as %VARIABLENAME in scripts. System variables use a $ instead of a %. Special link variables use an @.

You can find more details about the language itself here: Link

Master Script:

8 years ago

It sounds like interactions between HTML are possible.  Does this mean that javascript could be used to handle more advanced behaviors and embed it into the story?

Master Script:

8 years ago
Yep.

Master Script:

8 years ago

Well, I guess that means that I will have to play with it and figure out how I can do that.

Master Script:

8 years ago
What are you trying to do with it?

Master Script:

8 years ago

I want functions that I can save somewhere, then refer back to.

My test cases haven't worked yet. 

<script>

function determine_location() {

// ... logic ...

}

</script>

 

Ah, this discusses the issue:  http://chooseyourstory.com/help/articles/article.aspx?ArticleId=105

Master Script:

8 years ago

Ok.  So to do what I am trying to do, here is what needs to be done:

In the globalPage script you can place this code in there:

----------------------

$PAGETEXT := $PAGETEXT + "
<script>
function testme(){
  document.write('Hello World!!');
}

testme();
</script>"

------------------------------------------

Basically this can act as a stand-in for any of the more complex behavior that you want to run.

So for everyone who offered advice and encouragement on this thread:  Thank you.