Open Surge Forum

A fun 2D retro platformer inspired by Sonic games and a game creation system

You are not logged in.

Announcement

Our community has moved to Discord! https://discord.gg/w8JqM7m

#1 2011-03-18 14:35:41

KZR
Member
Registered: 2010-07-14
Posts: 1,447
Website

Forcing character switch without giving a name

is it possible? if it is, how? i'm not using the default script to handle it


SD_sml.pngSeD_sml.pngLTot_W_sml.png
https://discord.gg/w8JqM7m ---> Open Surge's Discord server

Offline

#2 2011-03-18 21:09:09

Alexandre
Administrator
From: Brazil
Registered: 2009-01-27
Posts: 3,300
Website

Re: Forcing character switch without giving a name

yes. At a first glance* I can think of two solutions:

1) if you know the names of all characters in your level, you can make an object switch the character according to a value of a global variable

2) if you don't know, you can use the fact that, on the switch_character command, if player_name is not specified, the observed player will become the active character (this is documented in the api reference). Then you can use observe_next_character, for example. ... edit: unless the "forcing" in the title of the thread means force_switch = true... is that what you meant?

* maybe there are other solutions as well.

Offline

#3 2011-03-18 23:47:32

KZR
Member
Registered: 2010-07-14
Posts: 1,447
Website

Re: Forcing character switch without giving a name

yes i mean the force switch. the initial problem leading to the question is solved, because the player is now required to be on the ground to switch. however if by any reason i need to force the switch, just doing this:

observe_next_player
switch_character TRUE

this does not work. as no character name was given before the switch, the engine assumes TRUE as the character's name.
I could give a name-based switching, but this would cause confusion, since in theory, in my mod all characters are available in every level, but according to some conditions, some are hidden at some times. specifying names on switch_character would lead to hidden characters being selectable even if they can't be used.
The current solution does the same, so maybe a variable specifying if the character is available or not could be used to jump to next character if the currently observed one is not available at the moment. but still, if for some reason switching is needed in a situation where the engine does not accept a polite request, i'm stuck neutral


SD_sml.pngSeD_sml.pngLTot_W_sml.png
https://discord.gg/w8JqM7m ---> Open Surge's Discord server

Offline

#4 2011-03-19 01:13:40

Alexandre
Administrator
From: Brazil
Registered: 2009-01-27
Posts: 3,300
Website

Re: Forcing character switch without giving a name

You can use switch_character "" TRUE to force the switch to the observed player, but you'll need revision 555. Without this feature, you can increase the number of states and combine it with on_observed_player. You'll achieve the same thing.

You can also use on_observed_player + observe_next_player in a loop to get the list of available characters in your level. Maybe you won't need it in your mod, but it's good to know.

Offline

Board footer

Powered by FluxBB  hosted by tuxfamily.org