Jump to content
Sign in to follow this  
sakura_chan

remove number from array with multiple instances

Recommended Posts

if I have an array like

_array = [1,2,3,4,1,2,3,4];

how can I remove just one of the numbers? I would like it to return

_array == [2,3,4,1,2,3,4];

basically I am dealing with editor objects that have the format: objectnumber: modelname.p3d

So it might be 122235: toiletbox_f.p3d

I need to remove the numbered part so I just delete everything up until the space which is easy but if there is a "3" in the object number then it ends up as "toiletbox_f.pd"

Share this post


Link to post
Share on other sites

arrayPop function I think? Nope, BIS_fnc_arrayPop would be exactly opposite, drops the last value not the first. BIS_fnc_arrayFindDeep might work, search for and find the first element it finds that match?

Perhaps use arrayFindDeep to locate the space, then BIS_fnc_subSelect to select the rest of it?

Yeah, so this works but it's horrid. :)

bob = player nearobjects 10; 
harry = toArray str(bob select 1); 
zone = [harry, 32] call BIS_fnc_arrayFindDeep; 
nancy = [harry, zone select 0] call BIS_fnc_subSelect; 
hint tostring nancy;

That hints "honeybee.p3d". :) Actually, maybe not, it's being silly now, I think 104 must not be space. It's not! 32 is, that works now.

Edited by kylania

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×