Hubs?
Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. This forum is archived - please use this set of forums to ask new questions.
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. This forum is archived - please use this set of forums to ask new questions.
Hubs?
I'm working on a co-op mod which will have many levels. In between each level, I want to warp to a shop level, where you can buy new items. How can I make it so I only have to define one map, and exiting the shop will always proceed to the next level? I was thinking about giving each player a dummy item named map01, map02, and so on, and exiting the shop would check their inventory, before proceeding to the next level, but I thought using a hub would be much simpler. I looked on the wiki, and I'm still a bit confused though.
- XutaWoo
- Posts: 4005
- Joined: Sat Dec 30, 2006 4:25 pm
- Location: beautiful hills of those who are friends
- Contact:
Re: Hubs?
Code: Select all
global int 1:progress
script 8 (void)
{
progress++;
Exit_Normal(0);
}
Code: Select all
global int 1:progress
script 8 (void)
{
switch(proggess)
{
case 1:
ChangeLevel("MAP02", 0, 0, -1);
break;
case 2:
ChangeLevel("MAP02", 0, 0, -1);
break;
case 3:
ChangeLevel("MAP04", 0, 0, -1);
break;
//etc
default:
ChangeLevel("MAP01", 0, 0, -1);
break;
}
}
Re: Hubs?
Not much larger this way, is it?
Code: Select all
global int 1:progress
script 8 (void)
{
progress++;
switch(proggess)
{
case 1:
ChangeLevel("MAP02", 0, 0, -1);
break;
case 2:
ChangeLevel("MAP02", 0, 0, -1);
break;
case 3:
ChangeLevel("MAP04", 0, 0, -1);
break;
//etc
default:
ChangeLevel("MAP01", 0, 0, -1);
break;
}
}
- NeuralStunner
-
- Posts: 12328
- Joined: Tue Jul 21, 2009 12:04 pm
- Preferred Pronouns: No Preference
- Operating System Version (Optional): Windows 11
- Graphics Processor: nVidia with Vulkan support
- Location: capital N, capital S, no space
- Contact:
Re: Hubs?
Tip: Use Switch. It's much more clean and compact than a bunch of Ifs. Plus once the correct choice is found, it breaks out, which from a logical standpoint is more efficient.
Re: Hubs?
Ummm... I still did use Switch. I just didn't use Progress++;. This way I can warp to a map and it won't break everything. It doesn't just add progress whenever I exit ANY level, it sets the progress based off of the information of the level you are in.
- NeuralStunner
-
- Posts: 12328
- Joined: Tue Jul 21, 2009 12:04 pm
- Preferred Pronouns: No Preference
- Operating System Version (Optional): Windows 11
- Graphics Processor: nVidia with Vulkan support
- Location: capital N, capital S, no space
- Contact:
Re: Hubs?
Your example didn't, which is all I had to go on. Joy!P1ayer27 wrote:Ummm... I still did use Switch.
- NeuralStunner
-
- Posts: 12328
- Joined: Tue Jul 21, 2009 12:04 pm
- Preferred Pronouns: No Preference
- Operating System Version (Optional): Windows 11
- Graphics Processor: nVidia with Vulkan support
- Location: capital N, capital S, no space
- Contact:
Re: Hubs?
How does that... What does... Why...
... Uh, I guess this is already solved, anyway. Good luck!
Spoiler:Seriously, I have no idea what you just tried to explain. You said you'd found "an easier way to do it", which to me says that was what you were going to use. And it certainly didn't have any Switch in there.
... Uh, I guess this is already solved, anyway. Good luck!
Re: Hubs?
It's not a smaller or simpler script, so I guess easier wasn't the right word. What I meant was that the other method wouldn't allow you to teleport to a level, without breaking the level flow, but the new script will allow you to do just that. Since the old method never actually set the value of the progress variable, it just added one to it, teleporting to MAP15 and then exiting would bring you to the shop, but when you exited you'd go straight to MAP01. The new way the variable is actually set, not just altered, so jumping around between maps will still keep everything intact. If you still can't understand me, just try not to worry about it too much since, like you already said, it's been solved. 

- NeuralStunner
-
- Posts: 12328
- Joined: Tue Jul 21, 2009 12:04 pm
- Preferred Pronouns: No Preference
- Operating System Version (Optional): Windows 11
- Graphics Processor: nVidia with Vulkan support
- Location: capital N, capital S, no space
- Contact:
Re: Hubs?
There was no problem understanding what the script does. How it does it was, at last revision, to use a lot of Ifs.