Skip to content
This repository was archived by the owner on Sep 5, 2026. It is now read-only.

2. Basic block scripting

Ercan Akyürek edited this page Feb 16, 2015 · 10 revisions

Important

You have to follow the steps in the wiki entry "Getting Started". You need proper initialized scripting structure.

Introduction

Well guys, this might be the most irritating part of low level NolimitsCoaster scripting. For me, I hated these 1000 lined codes, just for coding the block things for my coasters. So, I separated the whole things and made abstract classes for the blocks. This will reduce your code, well, to few lines of code, if you want basic block scripting. Also complex block scripts will be approachable with less lines of codes. Due NoLimitsFramework has still the beta status, only few block scripts are implemented yet. So lets have an overview of what is possible for getting started with block scripting.

Preparing our Coaster

If you read the wiki entry about how to getting started, you might know that I am gonna use the ExpeditionGeforce term for my coaster as an example.

Create a station, a lift and two brakes and close your circuit. Switch to scripted mode (hint: Coaster Properties, Mode, Operation Mode, scripted).

You need to label your station, your lift and your brakes. Just let us call them

  • Station
  • Lift
  • Brake1
  • Brake2

For label your station, lift, etc. you have to double click on your section in the NoLimits Editor and fill the field Name.

For these section, there are 3 classes available at the moment. You will find an overview of those classes inside com/nolimitsframework/block.

You might noticed the classes we need for our current purposes.

  • BlockRegularStation.nlvm
  • BlockRegularLift.nlvm
  • BlockRegularBrake.nlvm

So we have to add some lines in our coaster script. You remember your skeleton code? We have to initialize our blocks inside the init() method.

Let us initialize a block manager.

BlockManager cBlockManager = new BlockManager();

Well done. But still no visible results. Lets change that. First let us add a new block for the lift. The BlockManager provides setBlock method to, well, setting a new block. setBlock method accepts a block argument.

cBlockManager.setBlock(new BlockRegularStation("Station"));

Did you noticed "Station"? This is the label you gave in the editor for certain sections. Let us add the other blocks and we are done.

cBlockManager.setBlock(new BlockRegularLift("Lift"));
cBlockManager.setBlock(new BlockRegularBrake("Brake1"));
cBlockManager.setBlock(new BlockRegularBrake("Brake2"));

Hint

Don´t forget to import com.nolimitsframework.block.*

Final code

import com.nolimitsframework.*;
import com.nolimitsframework.block.*;

public class ExpeditionGeforce extends FrameworkScript {
	public void init() {
		BlockManager cBlockManager = new BlockManager();

		cBlockManager.setBlock(new BlockRegularStation("Station"));
		cBlockManager.setBlock(new BlockRegularLift("Lift"));
		cBlockManager.setBlock(new BlockRegularBrake("Brake1"));
		cBlockManager.setBlock(new BlockRegularBrake("Brake2"));
	}
}

Example Package

https://github.com/geforcefan/NoLimitsFramework/raw/master/Wiki/2.%20Basic%20block%20scripting/Basic%20block%20scripting.nl2pkg

Clone this wiki locally