01-30-2009, 04:26 AM | #1 |
Banned
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 05:18 AM. |
|
01-30-2009, 08:12 AM | #2 |
Stuff Do-er
Lua Team
Wiki Team Fortress Forever Staff |
Code:
local flag = GetInfoScriptByName( "name" ) if flag then flag:Remove() end
__________________
#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 |
|
01-30-2009, 10:21 AM | #3 |
Banned
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.
|
|
01-30-2009, 07:00 PM | #4 |
Stuff Do-er
Lua Team
Wiki Team Fortress Forever Staff |
This is in base_id_flag: ontouch()
Code:
local flag = CastToInfoScript(entity) 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
__________________
#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 |
|
01-30-2009, 10:39 PM | #5 | |
Banned
Join Date: Sep 2008
Class/Position: Soldier Gametype: AVD Affiliations: TALOS Posts Rated Helpful 5 Times
|
Yes! That works. Thanks ;D
Quote:
|
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
|
|