Fortress Forever

Go Back   Fortress Forever > Editing > Mapping > Lua

Reply
 
Thread Tools Display Modes
Old 01-30-2009, 03:26 AM   #1
Bridget
Banned
 
Bridget's Avatar
 
Join Date: Sep 2008
Class/Position: Soldier
Gametype: AVD
Affiliations: TALOS
Posts Rated Helpful 5 Times
Deleting an info_ff_script?

I have multiple instances of the same script in my map. When the player touches one of them, that specific one should disappear (get removed). How do I delete the info_ff_script? RemoveEntity(self) doesn't work and OutputEvent("","Kill") would require I make a different script for each instance in the map (50+).

Code:
a_special_script = info_ff_script:new({
	name = "A script!"
	touchflags = {AllowFlags.kOnlyPlayers,AllowFlags.kYellow},
	model = "models/items/ball/ball.mdl"
})

function a_special_script:touch(touch_entity)
	if IsPlayer(touch_entity) then
		-- remove the specific script touched here.
	end
end

Last edited by Bridget; 01-30-2009 at 04:18 AM.
Bridget is offline   Reply With Quote


Old 01-30-2009, 07:12 AM   #2
squeek.
Stuff Do-er
Lua Team
Wiki Team
Fortress Forever Staff
 
squeek.'s Avatar
 
Join Date: Mar 2007
Location: Northern California
Class/Position: Rallygun Shooter
Gametype: Conc tag (you just wait)
Affiliations: Mustache Brigade
Posts Rated Helpful 352 Times
Send a message via AIM to squeek.
Code:
local flag = GetInfoScriptByName( "name" )
if flag then
	flag:Remove()
end
Straight from base_id.
__________________
#FF.Pickup ¤ Fortress-Forever pickups

My Non-official Maps
Released FF_DM_Squeek - FF_2Mesa3_Classic - FF_Siege_Classic
Beta FF_Myth - FF_Redlight_Greenlight

Sick of the people on the internet, always moanin'. They just moan.
- Karl Pilkington
squeek. is offline   Reply With Quote


Old 01-30-2009, 09:21 AM   #3
Bridget
Banned
 
Bridget's Avatar
 
Join Date: Sep 2008
Class/Position: Soldier
Gametype: AVD
Affiliations: TALOS
Posts Rated Helpful 5 Times
This won't work, because I need the function to remove the specific entity that has been triggered, while ignoring the other scripts that are exactly the same. Instead, the code you offered freaks out because it realizes, oh shit there is more than one a_special_script on the map. Then, it just removes the first one it can find (not the specific one you touch) and touching further a_special_scripts does nothing. I don't think there's a way to achieve what I'm looking for. In order to do it the way I want, I'd have to make like x+ (number depends on how many I need in my map) scripts each with their own :touch() function that finds them specifically and removes them. That's a really beginner-desperation way of doing things, so I guess I'm out of luck. RemoveEntity(self) should remove the specific entity that the touch() function was called on in real time, not in code (Oh, remove this specific script? Not any or every script that happens to be of this kind. Sure.), even if there are a dozen entities of the same type, name, and whatever. If it doesn't make sense to use RemoveEntity(x), a new lua function should be added that allows this.
Bridget is offline   Reply With Quote


Old 01-30-2009, 06:00 PM   #4
squeek.
Stuff Do-er
Lua Team
Wiki Team
Fortress Forever Staff
 
squeek.'s Avatar
 
Join Date: Mar 2007
Location: Northern California
Class/Position: Rallygun Shooter
Gametype: Conc tag (you just wait)
Affiliations: Mustache Brigade
Posts Rated Helpful 352 Times
Send a message via AIM to squeek.
This is in base_id_flag: ontouch()

Code:
local flag = CastToInfoScript(entity)
Might be worth a shot. The entity variable is just... there. It's not defined in the function or passed when the function is called.

Code:
function a_special_script:touch(touch_entity)
	if IsPlayer(touch_entity) then
		local flag = CastToInfoScript(entity)
		if flag then
			flag:Remove()
		end
	end
end
Also, is this for pacman?
__________________
#FF.Pickup ¤ Fortress-Forever pickups

My Non-official Maps
Released FF_DM_Squeek - FF_2Mesa3_Classic - FF_Siege_Classic
Beta FF_Myth - FF_Redlight_Greenlight

Sick of the people on the internet, always moanin'. They just moan.
- Karl Pilkington
squeek. is offline   Reply With Quote


Old 01-30-2009, 09:39 PM   #5
Bridget
Banned
 
Bridget's Avatar
 
Join Date: Sep 2008
Class/Position: Soldier
Gametype: AVD
Affiliations: TALOS
Posts Rated Helpful 5 Times
Yes! That works. Thanks ;D

Quote:
Also, is this for pacman?
... Damn you.
Bridget is offline   Reply With Quote


Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 10:47 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.