Jump to content
  • 0

save variable between different levels?


zzzornbringer

Question

hi, i've been working on a little project which is inspired by the game void bastards.

 

my current problem is that i basically want to have some sort of currency that i collect throughout a level and back at my hub level i want to spend this.

 

but i don't know how to write a value into a variable that is then also saved and can be accessed after that level is complete, if that is even possible.

 

i tried having like a global script in my wad file that i access through the #include command. this works with regular scripts which is useful, but not so much for global variables, so it seems.

 

any suggestions greatly appreciated.

Edited by zzzornbringer

Share this post


Link to post

3 answers to this question

Recommended Posts

  • 1

When you talk about global scripts, do you mean ACS? I will assume so.

 

My advice would be to use a library and properly scoped world or global variables.

Share this post


Link to post
  • 0

thanks. the scope thing actually works. using the world scope and it works just fine.

 

i was trying to have a custom item/ammo type as band-aid, but couldn't find a way yet to read how much of that item is in my inventory.

 

ultimately a custom item type might be the better solution, because it can be displayed as ammo type on the hud. i think i've done this in the past.

 

the variable things works though, so, i'll see what i can do with that.

Share this post


Link to post
  • 0

just an fyi, i have found a better solution for my problem. although it's certainly nice to know how to save variables between levels.

 

i have simply created a new item via decorate. i check this item via the CheckInventory function. https://zdoom.org/wiki/CheckInventory

 

for testing purposes i use these items as sort of a currency to unlock a door. if used successfully, ie with the correct amount, i take away that amount via the TakeInventory function. https://zdoom.org/wiki/TakeInventory

 

this way i don't have to count the item pickups vie global variables. both would work i guess, but this is much easier and less error prone.

 

Share this post


Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...