libscratchcpp
A library for C++ based Scratch project players
Loading...
Searching...
No Matches
libscratchcpp::Script Class Reference

The Script class represents a compiled Scratch script. More...

#include <scratchcpp/script.h>

Public Member Functions

 Script (Target *target, Block *topBlock, IEngine *engine)
 
 Script (const Script &)=delete
 
Targettarget () const
 
BlocktopBlock () const
 
ExecutableCodecode () const
 
void setCode (std::shared_ptr< ExecutableCode > code)
 
ExecutableCodehatPredicateCode () const
 
void setHatPredicateCode (std::shared_ptr< ExecutableCode > code)
 
bool runHatPredicate (Target *target)
 
std::shared_ptr< Threadstart ()
 
std::shared_ptr< Threadstart (Target *target)
 

Detailed Description

The Script class represents a compiled Scratch script.

Constructor & Destructor Documentation

◆ Script() [1/2]

Script::Script ( Target * target,
Block * topBlock,
IEngine * engine )

Constructs Script.

◆ Script() [2/2]

libscratchcpp::Script::Script ( const Script & )
delete

Member Function Documentation

◆ code()

ExecutableCode * Script::code ( ) const

Returns the executable code of the script.

◆ hatPredicateCode()

ExecutableCode * Script::hatPredicateCode ( ) const

Returns the executable code of the hat predicate.

◆ runHatPredicate()

bool Script::runHatPredicate ( Target * target)

Runs the edge-activated hat predicate as the given target and returns the reported value.

Note
If there isn't any predicate, nothing will happen and the returned value will be false.

◆ setCode()

void Script::setCode ( std::shared_ptr< ExecutableCode > code)

Sets the executable code of the script.

◆ setHatPredicateCode()

void Script::setHatPredicateCode ( std::shared_ptr< ExecutableCode > code)

Sets the executable code of the hat predicate.

◆ start() [1/2]

std::shared_ptr< Thread > Script::start ( )

Starts the script (creates a thread).

◆ start() [2/2]

std::shared_ptr< Thread > Script::start ( Target * target)

Starts the script (creates a thread) as the given target (might be a clone).

◆ target()

Target * Script::target ( ) const

Returns the Target.

◆ topBlock()

Block * Script::topBlock ( ) const

Returns the first block (usually hat) of the script.


The documentation for this class was generated from the following files: