This forum is locked and will eventually go offline. If you have feedback to share you can find us in our Discord channel "MythoLogic Interactive" https://discord.gg/nECKnbT7gk

Forum rules

Scripting 16 - Fire

A smaller forum with a few tutorials how to get started with the ScriptAPI.
Forum rules
By using the forum you agree to the following rules.
Locked
User avatar
Gurt
Lead Programmer
Lead Programmer
Posts: 1887
Joined: Sun Feb 28, 2016 3:22 pm
Title: Lead programmer
Started SFD: Made it!
Location: Sweden
Gender:
Age: 36

Scripting 16 - Fire

Post by Gurt » Sun Aug 11, 2019 1:14 pm

Scripting 16 - Fire

Scripting in SFD assumes you have a fair knowledge of C#.

The following code demonstrates how to read and remove fire. Available in v.1.3.1.

This is a limited instruction set. All you can do is to read a limited set of data from current fire nodes and remove individual fire nodes in the game. The fire system is old and this is what can easily be done in the API without refactoring a huge set of code.

Code: Select all

// Example how to create a "no-fire zone" around the middle of the map
public void OnStartup()
{
	Events.UpdateCallback.Start(OnUpdate, 0);
}
	
public void OnUpdate(float ms)
{	
	// No fire zone
	Area area = new Area(new Vector2(-32f, -32f), new Vector2(32f, 32f));
	
	Game.DrawArea(area, Color.Yellow);

	FireNode[] fireNodes = Game.GetFireNodes(area);
	foreach(FireNode fireNode in fireNodes)
	{
		if (fireNode.AttachedToObjectID != 0)
		{
			Game.EndFireNode(fireNode.InstanceID);
		}
	}
	foreach(IObject obj in Game.GetBurningObjects())
	{
		if (area.Contains(obj.GetWorldPosition()))
		{
			obj.ClearFire();
		}
	}
}
ScriptAPI Implementation
► Show Spoiler
2 x
Gurt

NearHuscarl
Superfighter
Superfighter
Posts: 97
Joined: Thu Feb 07, 2019 4:36 am

Post by NearHuscarl » Mon Aug 12, 2019 2:38 am

Since you add FireNode. IGame.SpawnFireNode() and IGame.SpawnFireNodes() should return FireNode and FireNode[] respectively instead of void
2 x
Image

User avatar
Gurt
Lead Programmer
Lead Programmer
Posts: 1887
Joined: Sun Feb 28, 2016 3:22 pm
Title: Lead programmer
Started SFD: Made it!
Location: Sweden
Gender:
Age: 36

Post by Gurt » Mon Aug 12, 2019 12:10 pm

NearHuscarl wrote:
Mon Aug 12, 2019 2:38 am
Since you add FireNode. IGame.SpawnFireNode() and IGame.SpawnFireNodes() should return FireNode and FireNode[] respectively instead of void
Good idea! Adding it to the next update.
1 x
Gurt

Locked