PDA

View Full Version : Deleting an info_ff_script?


Bridget
01-30-2009, 03:26 AM
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+).


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

squeek.
01-30-2009, 07:12 AM
local flag = GetInfoScriptByName( "name" )
if flag then
flag:Remove()
end
Straight from base_id.

Bridget
01-30-2009, 09:21 AM
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.

squeek.
01-30-2009, 06:00 PM
This is in base_id_flag: ontouch()


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.


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? :)

Bridget
01-30-2009, 09:39 PM
Yes! That works. Thanks ;D

Also, is this for pacman? :)

... Damn you.