Page 1 of 1

Teleporter Issues

Posted: Sun Oct 14, 2012 12:35 am
by sirK2005
Hi,

I have crossed upon yet another problem. I have created an item that, on use, leads to the spawning of a teleporter at exactly the point where the party is standing.

Not always, but sometimes, the game crashes on me. This is my code for teleporter creation:

Code: Select all

		spawn("teleporter", party.level, party.x, party.y, 0, "returnTeleporter")
		returnTeleporter:setTriggeredByMonster(false)
		returnTeleporter:setTriggeredByItem(false)
		returnTeleporter:setTeleportTarget(15,15,0,1)
and at level 1 position 15,15 there is a plate that immidiatley destroys the teleporter again.

When testing I found out that when spawning the teleporter at a different location (everywhere but where the party is standing) and the party goes through everything works smoothely.
So I suspect that the fact that I first spawn the teleporter and then define where it is teleporting to sometimes leads to the teleporter porting the party to a not yet specified location and that crashes the game.

So, my Question: Is there a way to "set up" the teleporter (or any other object) first and then spawn it?

Re: Teleporter Issues

Posted: Sun Oct 14, 2012 1:32 am
by Shroom
Create the object first

Then activate it.

Code: Select all

Teleporter = spawn("teleporter", party.level, party.x, party.y, party.facing, "teleporter_1")
Teleporter:setInvisible(true)
Teleporter:setTriggeredByParty(true)
Teleporter:setTeleportTarget(15, 15, 0, 1)      
Teleporter:activate()

Re: Teleporter Issues

Posted: Sun Oct 14, 2012 2:19 am
by Komag
you also might need to delay destroying the teleporter - have the plate link to a timer set to 0.1sec which then destroys the teleporter

Re: Teleporter Issues

Posted: Sun Oct 14, 2012 7:59 am
by sirK2005
@Shroom:
Yeah, I tried something like that already, but sadly

Code: Select all

Teleporter = spawn("teleporter", party.level, party.x, party.y, party.facing, "teleporter_1")
already spawns the actual telelporter for me within the level, since the teleporter does not start in a deactivated state.

@Komag:
Good hint, I've done that know. My prblem has indeed not accured anymore sonce I uncluded a timer to delay the destruction of the teleporter. But further testing is needed if this solution is stable.

So, maybe the problem was not the setup of the teleporter after all? I will simply test further.

Re: Teleporter Issues

Posted: Sun Oct 14, 2012 3:23 pm
by Shroom
I have used this in a dungeon and it works - however, what i didn't write is that at the 'landing' site is a hidden pressure plate which i used to destroy the teleporter after its work is done. (I also had a teleport counter that made sure each was unique, just to be sure)

You are probably running into a problem with the order in which things are run - ie it finishes your script before engaging the code that would make the party interact with the teleporter and hence it appears deactivated to you.