How do I edit things on another layout?

0 favourites
  • 12 posts
  • So I'm making this program in which you can write stories. In this program i have a couple of layouts. the one I'm going to be talking about are a layout where you can create the stories, and a layout where you can browse through the already made stories. In the layout where you can create the stories there is a textbox where you can input the title (this is what would be visible in the list on the browsescreen), a textbox in which the story can be written and a save button, that is supposed to upload the title to the list on the browse layout. (btw, the story is saved the same way to an invisible list on the browselayout).

    The problem I have is:

    I can't seem to figure out how to make a story (or title) you created appear on the browsescreenlist.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • How experienced are you with Construct because so far this sounds like you just created some text boxes in a layout? You can push the stories to the back of an array and use array data to limit what is shown in title and story lists.

  • If I understand correctly, you can use a Global Variable to store the title text. Then, when the browselayout start, you can get the text stored inside the Global Var and associate to the textbox you are using.

    You can use arrays or even dictionary to do this.

    Im not a programmer, but I think this solve your problem

  • just to clarify, i want to be able to make as many stories as possible. so when i use a global variable, i will have to make as many variables as the maximum amount of stories. this is not what i want. If there is another way with a global variable to still make it work, i'd really like to know.

    so just to summarize, i simply want to know how to copy the contents of a textbox on "layout 1" to a list in "layout 2". And this should be possible as many times in a row as you'd like. so the list could have infinite stories in it.

    btw, i don't really understand what you mean.

  • angryvel760

    is your plan to store the stories on a server so different devices can access them, or store them in local storage (so only the device that created a story can see it?

    and how long are the stories? are they going to be copy and pasted from other sources? If you want any text formatting it get a lot more complicated...

    Plinkie was suggesting using an Array to store the stories in. Which is a good idea, and makes saving to local storage easier. But the code is tricky to follow for people who have never used arrays before...

  • angryvel760

    is your plan to store the stories on a server so different devices can access them, or store them in local storage (so only the device that created a story can see it?

    and how long are the stories? are they going to be copy and pasted from other sources? If you want any text formatting it get a lot more complicated...

    Plinkie was suggesting using an Array to store the stories in. Which is a good idea, and makes saving to local storage easier. But the code is tricky to follow for people who have never used arrays before...

    Firstly, i want to store it locally (local storage)

    also, the stories are self written in the textbox. It's kinda part of the project.

    And lastly, i have never really used arrays before, but i actually hope i don't have to here.

  • angryvel760 - here is a quick sample... I am not sure how I would approach it without arrays. You have to store the stories in something, and if you want lots of them it could get messy...

    https://www.rieperts.com/games/forum/StoryList.capx

  • You can use a dictionary.

    Key = Story name

    Value = Story content

    Dropdown menu: Key entries of dictionary

    On select dropdown item:

    Set storytextbox.text to dictionary.Get(dropdownitem)

    Set storyname.text to dropdown item

    Store the JSON string of the dictionary object to local storage, then load it whenever needed.

    Per se the dictionary object is global, so you can access it's content from any layout.

  • angryvel760 - here is a quick sample... I am not sure how I would approach it without arrays - Dictionary is a good idea too, very similar to an array, but maybe a little less confusing. You have to store the stories in something, and if you want lots of them it could get messy...

    https://www.rieperts.com/games/forum/StoryList.capx

  • angryvel760 - here is a quick sample... I am not sure how I would approach it without arrays - Dictionary is a good idea too, very similar to an array, but maybe a little less confusing. You have to store the stories in something, and if you want lots of them it could get messy...

    https://www.rieperts.com/games/forum/StoryList.capx

    Thank you! The saving worked! I now have one final question, what do i do if i want to delete one of the stories?

  • angryvel760

    you could just write a new one over it...

    or delete that row out of the array and re-save the array in local storage.

    I updated my sample to do that - I also put in a Delete ALL for my testing purposes... be careful with that because there is no way to get stories back if you delete them!

    https://www.rieperts.com/games/forum/StoryList.capx

    I did add a little error checking - like making sure a story is selected before editing or deleting it. But there is no "Are you sure?" before anything gets deleted!

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)