❔ ✅ get unknown range of list to display?
this information is generated into a string like
string evidence = "EMF 5, Spirit Box, Ghost Writing";
. Knowing that it's not the same evidence every time, how can I cut off the last piece of evidence and display the first two?33 Replies
split the string on
,
and drop the last item?like this?
ugh, no
well this is how it's generated into a string....
well if you already have it as an array, isnt it better to just use the array then?
why convert to string, remove the last item, then convert back into array, to then convert to string again?
that seems insanely convoluted
😄
idk that's why I asked. This isn't python so it's confusing.....sorry. I don't mean to disappoint
so, this is an X Y problem
you're trying to solve X, your attempted solution is Y, so you're asking about Y
I need you to tell me about X
what is the actual problem you are trying to solve here?
ok you said it's already an array
ghost.Evidence
is, last time we talked
so if you have access to that, its much easier to work with that directlyso I should be able to do something like this then, right?
rather than the string version
uhm.. what do you think
string.Join
does?joins an array to a string
that's why I'm trying to index the array
right. and
ghost.Evidence
is an array, that we agree on
what is ghost.Evidence[0]
thou?
is that also an array?in the ghost model, it is done as an array.
then it's stored to the json file like so. When I pull it from the json file,
I do so like this to get it into a string that looks like
"EMF 5, Spirit Box, Ghost Writing"
so it's easier to print to the screen. I'm just trying to figure out how to drop the last item in the stringbut why in the string?
isnt the string literally just a display interpretation of the array?
you shouldn't be modifying the string, you should be modifying the array
and honestly, at that point, it shouldn't be an array, it should be a list
you're still focused on Y
tell me about X. why do you want to drop the last item from the string?
because it's part of the game?
explain
for what? It's part of the game. I just need to know the most efficient way to drop the last item from that string, or from the array.....
What i've gathered about your project so far is that its a guessing game right
you get some info on a ghost and you're supposed to identify it
I'm assuming Phasmophobia or similar? You go around the map and discover certain pieces of evidence then mark them in your notebook as discovered evidence to identify what type of ghost it is
it's just part of the games difficulty level.
there we go
THATS what X is
I don't understand why the reason I'm wanting to drop the last item in the list is relevant to learning how to do it
you want a way to "hide" evidence from the player to increase difficulty
it's just dropping one item from teh list
Look, I either help you my way, or I don't help you.
Pick one.
me not wanting to release details about my game that I'm developing that I haven't told anyone about at all has nothing to do with receiving assistance in learning how to drop an item from a list. But alright, your pride. your way. thanks for the help
$xy
The XY Problem
Asking about your attempted solution rather than your actual problem
read this, and perhaps you'll understand
if not, best of luck with your your programs
yea I'm good. I figured it out by myself
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.