playMaker

Author Topic: Deleting parts of an array  (Read 2196 times)

Drahgoone

  • Playmaker Newbie
  • *
  • Posts: 10
Deleting parts of an array
« on: June 29, 2018, 08:36:52 PM »
Hello, In my scene I have two rooms, with an array that holds a list of who is in what room. When a user leaves one of the rooms, I am using array delete at to remove their name from the list, however it seems to quite oddly delete everything in the array once this is done rather than the specific item I wish to delete. Just wondering if anyone has any ideas on how to get around this. I am using "array contains" to find the index of the users name, then array delete at to remove the users name from the list, which is for some reason causing all the items in the array to delete rather than the one I want to delete. The arrays are added with "array add". Thanks in advance if anyone knows what I am doing to screw this up :P

verybinary

  • Junior Playmaker
  • **
  • Posts: 81
    • The Museum of Digital
Re: Deleting parts of an array
« Reply #1 on: June 29, 2018, 09:12:37 PM »
What about setting the index to 0. When you search for Paul, it'll return false?
What about setting Paul to 0 and Ben to 1.
Paul == rooma or roomb
Ben == rooma or roomb
If 0 = rooma, display on "room a" ui

Drahgoone

  • Playmaker Newbie
  • *
  • Posts: 10
Re: Deleting parts of an array
« Reply #2 on: June 29, 2018, 09:29:47 PM »
What about setting the index to 0. When you search for Paul, it'll return false?
What about setting Paul to 0 and Ben to 1.
Paul == rooma or roomb
Ben == rooma or roomb
If 0 = rooma, display on "room a" ui

problem is i've got an unlimited number of people who can be in the same room, so I assume no one can share the same index?

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: Deleting parts of an array
« Reply #3 on: June 30, 2018, 12:54:32 PM »
Hi.
Maybe you should use hash tables instead of arrays.

then you can add each player as a key and then give a value for the room (for example an int (1,2,3) or a string (Room 1,Room 2, Room 3)

You can get it on the Arraymaker package from the Ecosystem

Here is a video about HashTables :


or work with 2 arrays , 1st array holding the players (for example as a gameobject)
and a 2nd array holding the room value.

If Ben is on index 1, check its room on the 2nd array @ index 1

Drahgoone

  • Playmaker Newbie
  • *
  • Posts: 10
Re: Deleting parts of an array
« Reply #4 on: June 30, 2018, 01:02:42 PM »
Is the "delete at" issue a play maker bug then? or am I just doing something way wrong?

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: Deleting parts of an array
« Reply #5 on: June 30, 2018, 01:22:54 PM »
Hi.
There is probably something wrong :)

Can you show your setup?

I do think in this case it would be better to change your system not deleting every time you change room.

Drahgoone

  • Playmaker Newbie
  • *
  • Posts: 10
Re: Deleting parts of an array
« Reply #6 on: June 30, 2018, 02:03:00 PM »
Hi.
There is probably something wrong :)

Can you show your setup?

I do think in this case it would be better to change your system not deleting every time you change room.

ya ill probably just have to redo this list system like you said.

Currently it is just four different states for the deleting portion.

state 1.) just downloads the list from easysave
state 2.) i use "array contains" to search for the users name, and collect the index id
state 3.) i delete the index id that was collected above with "array delete at"
state 4.) i re-upload the array to easysave