Global interaction (for achievements)

Avatar
Brainstone
401 Posts
Posted Oct 09, 2012
(The most competent person to know this is probably Chicken.)
so here is my problem: I will submit a whole mod mappack out of 25 maps to the steam workshop, and as we all know, you can play every workshop map without having completed any others.
This actually is okay to me, because it gets possible to frustrated players to skip my ridicously hard maps. But:
At the end of the whole thing, I want some kind of achievement chamber, where you walk around and see your achievements on the walls. Basic achievement is "complete all chambers". Other achievemnts would include speedrunning certain levels, or finding all ratman's dens, shooting a minimum of Portals and so on. You know. The classic stuff.
Therefore, what I need, is some kind of global interaction between my maps, which can be packed into .bsp and can be used for my goal. This can include scripts.

Thank you. :thumbup:

Advertisement
Registered users don’t see ads! Register now!
Avatar
CamBen
973 Posts
Posted Oct 09, 2012
Replied 33 minutes later
Can you use logic branches with a global entity name? I'm pretty sure somewhere it said that a global entity name was preserved through maps, but I am not sure.
Avatar
262LetsPlay
51 Posts
Posted Oct 09, 2012
Replied 2 minutes later
Probably out of intention, but how about not submitting in the workshop at all? Just create a dummy with a link to this database and you can do it the good old env_global way without worrying about that things.
Avatar
FelixGriffin
2,680 Posts
Posted Oct 09, 2012
Replied 26 minutes later
Unfortunately, I don't think so. Global entity names should be preserved across maps, in theory, and the same with env_globals...but only when a trigger_iforgetthename changes the level to the next one, within the same save file.
Avatar
ChickenMobile
2,460 Posts
Posted Oct 09, 2012
Replied 6 hours later

The workshop works differently to of that of a normal map. In fact: the only way in order to save variables from a previous map is with a trigger_transition and and env_global - as used in HL2. The workshop runs each map through the 'map' command and therefore cannot transition and save previous data.
Portal 2 never used these entities because you never had to backtrack or take anything with you between loading screens.

The only way I can see to get round this:
In your description of each map and collection: tell players to download the whole lot and then start at map #1. Then you can use the trigger_transition and env_globals to change your level while still keeping saved achievements.
If I remember clearly, maps uploaded through the portal2publish.exe will keep the relevant map the same when they are played, therefore you could still use a transition on the workshop.
Put in the necessary voting entities needed, but don't activate them otherwise you won't be able to upload it to the workshop - use the transition.

Here's a good post on transitions.

post65289.html?#p65289
Here's an example map of using an env_global

post62215.html#p62215

The only other problem I can see faced is if the player leaves and quits portal without saving it (can you even save a game in the workshop? not quicksave) and then starts the relevant map they were up to again through the workshop (i.e. map mapname command). It would reset all global variables and the achievements would be cleared.

I hope this clarifies some things.

Avatar
ChickenMobile
2,460 Posts
Posted Oct 10, 2012
Replied 2 hours later

Just wanted to write some info on env_global's in portal 2.

  • Env_global only has an On or Off state
  • In order to read a global's state, you need to set the read state in a logic_auto to the name of your global state.- The logic_auto will only trigger its outputs if the wanted global state is set to **On**. This is the only way you can grabbed the save state of the env_global.
    • Env_globals are only saved when in conjunction with a trigger_changelevel. Otherwise it will not save and keep the state of your globals.
  • Global states will continually be present even if the map transitions.
  • With a logic_auto and using the *global state to read*, you can reference any global state saved from any previous transition- Landmark destinations and global states will not be saved if the **map *mapname*** command is used to load a level from the previous one.- Saving your game through the menu or quicksaving will also save global states.
  • - You can change the state of a global any time by creating another env_global with the same named global state and use an output to turn it either on or off.
    • The counter keyvalue and outputs do not work. Even if the counter does save over to the next map in transition, you cannot grab the value of the counter to use.
    Avatar
    josepezdj
    2,386 Posts
    Posted Oct 10, 2012
    Replied 3 hours later
    Very useful information Chicken. Many thanks! :thumbup:
    Avatar
    FelixGriffin
    2,680 Posts
    Posted Oct 10, 2012
    Replied 3 hours later
    Now, does the Global Entity Name stuff work the same way? It's always sounded really useful in theory, but I've never gotten it to work right.
    Avatar
    ChickenMobile
    2,460 Posts
    Posted Oct 10, 2012
    Replied 2 hours later

    FelixGriffin wrote:
    Now, does the Global Entity Name stuff work the same way? It's always sounded really useful in theory, but I've never gotten it to work right.

    ?

    Avatar
    FelixGriffin
    2,680 Posts
    Posted Oct 10, 2012
    Replied 7 hours later
    Entities have a Global Entity Name field that's supposed to make them remain the same across maps?
    Advertisement
    Registered users don’t see ads! Register now!
    Avatar
    ChickenMobile
    2,460 Posts
    Posted Oct 10, 2012
    Replied 3 hours later

    http://twhl.info/articulator.php?art=60

    I'm gonna try it out. Lets see if Portal 2 will let me.

    EDIT: -- Ooooooo... Global entity naming be awesome

    Notes on Global Naming

    • If you state an object to be Global Named and copy over this entity to the next map in transition, it will copy over the object's behaviours to the next level.
  • If the Global object is in a different position to that of the previous Global named object, it will move it to the correct position based on the landmark.- Outputs of the same Global Name will also transfer to the relative entity.
    • By giving an entity a Global Name, it will not transition to the next level through a tigger_transition.
  • Any entity that can be saved and brought to the next map while in a trigger_transition will be if it isn't Global Named- Global Named objects will stay relative to where their previous instance of it was, even if it is a static entity and you moved it to the other side of the room. - That's why its better to copy the transition area from the previous map and build around your landmark.- Path_tracks seem to dislike me and won't be saved in the trigger_transition, but when copied the tracktrain worked perfectly.
    • Global Named objects do not have to look the same if they are a brush entity. The shape and texture (although now black) of the entity could be changed but it will still have the same behaviours.
  • You cannot change a Global Named prop_weighted_cube to suddenly be a sphere. I tried.
    • If an entity doesn't have the Global Entity Name field in it, you can add the keyvalue manually by deselecting Smart Edit and adding the keyvalue globalname name.
      Here's an example of how to use env_global, transitions and Global Names
    env_global.zip

    I bet you can do some pretty neat stuff if you could just channel previous entities over from the last map.

    Attachments
    env_global.zip
    0.04 MB 58 downloads