Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
Tags

Delete terminal after use?

A topic by Scruffy86 created 34 days ago Views: 107 Replies: 4
Viewing posts 1 to 2

is there a way to delete terminals after they have been pressed once? I have a computer panel that when activated by  a script, spawns some enemies. If the player keeps pressing it, it will keep spawning enemies each time. I'd like for this to only occur once. 

You could create a map variable that holds on to the current number of enemies you've spawned and the maximum you want and then check if the current number is greater than the maximum then just do map return instead of doing anything

Thanks for the reply. I took a look at the variable section of the manual, but it is confusing without a complete example. If you could help me figure this out at your convenience I'd really appreciate it. I'm about to make a really neat gameplay mechanic which is a pushable button panel that can open doors but also spawn enemies. The last bug in this mechanic is getting it to only work once or at least only spawn enemies once, when used. 

So far, the way it works is I created a 3d model of a wall which is half the width of a standard EFPSE Cube, and put a raised "button" on it with red color. With my terminal script, I have it swap the model with a "pushed in button" version of this wall, with the button now green. The script will also unlock a door and also spawn 2 turret enemies behind the player at specific grid coordinates. I want it to be so that the terminal script will no longer open the door and spawn the turrets once it has already been activated. I tried to take your advice, and also read about variables in the manual. 

So far I have this: 

______________________________________________________________

MedBaySwitch1.script

map.SpawnedTurrets=0

if $SpawnedTurrets == 1 {

map return 

}

entity delete 14 12 1

entity spawnat SwitchWall1OnNorth 14 12 1

sound PullLeverFast.wav Sounds/PullLeverFast.wav

play sound PullLeverFast.wav

entity spawnat PortableTurret 17 9 1 

entity spawnat PortableTurret 13 9 1

$SpawnedTurrets=1

timeout .2

door unlock 14 17 2

door open 14 17 2 1

map quickreturn

____________________________________________________________

With the above script, the game does not crash, but the turrets still spawn when I use the terminal again

(1 edit)

Hello Scruffy86! I think I might know where the problem is:

Line 11 that reads "$SpawnedTurrets=1" should instead be "SpawnedTurrets=1"

You only need to use the "$" before a variable name if it is part of an if statement, or if it is being used as a value in another statement, for example "if $global.maxHP >= 120" or "player setmaxhp $global.maxHP". When setting a variable (or when modifying it) you do NOT use the "$" symbol!

Also, you have two variables with the same name for some reason? One is a local variable called "SpawnedTurrets" and the other is a map variable called "map.SpawnedTurrets". This might not be a problem, but I would change one of those variables so that they aren't so similar. It will almost surely lead to confusion later!

Thank you so much! It worked, the terminal no longer works after I press it once, and I got rid of the map variable. I better understand it now, thanks. And now I have a cool pushable button panel mechanic that can open locked doors and spawn ambushes. This is going to create some really fun gameplay.