Readymade 'SwitchCharacter' function and command
sonic102
20 May 2012, 06:08NOTE: I am doing this because I do not know how to make a library!
This is a readymade 'switching character' function and command. You can use this to switch between characters.
NOTE:You go in an order. I will update this so it'll show a menu(I'm too lazy now.)
Function
Command
NOTE:Change your changeable character's names to 'c1' 'c2' etc. or it will not work! You can make what the player sees as the alias. If you have less than six characters then remove the needful. If you have more than six characters then learn from the code!
If you want you can copy your game's code and paste it into this file and continue creation after doing the desirable changes. You also can give me credit(Optional):
This is a readymade 'switching character' function and command. You can use this to switch between characters.
NOTE:You go in an order. I will update this so it'll show a menu(I'm too lazy now.)
Function
if (player.character = "Character 1") {
msg ("You are playing as the second character.")
player.character = "Character 2"
c1.scenery = false
c2.scenery = true
MoveObject (player, c2.parent)
}
else if (player.character = "Character 2") {
msg ("You are playing as the third character.")
player.character = "Character 3"
c2.scenery = false
c3.scenery = true
MoveObject (player, c3.parent)
}
else if (player.character = "Character 3") {
msg ("You are playing as the fourth character.")
player.character = "Character 4"
c3.scenery = false
c4.scenery = true
MoveObject (player, c4.parent)
}
else if (player.character = "Character 4") {
msg ("You are playing as the fifth character.")
player.character = "Character 5"
c4.scenery = false
c5.scenery = true
MoveObject (player, c5.parent)
}
else if (player.character = "Character 5") {
if (GetBoolean(c6, "locked")) {
msg ("You are playing as the first character.")
player.character = "Character 1"
c5.scenery = false
c1.scenery = true
MoveObject (player, c1.parent)
}
else {
msg ("You are playing as the sixth character.")
player.character = "Character 6"
c5.scenery = false
c6.scenery = true
MoveObject (player, c6.parent)
}
}
else if (player.character = "Character 6") {
msg ("You are playing as the first character.")
player.character = "Character 1"
c6.scenery = false
c1.scenery = true
MoveObject (player, c1.parent)
}
}
</function>
Command
<command name="switch">
<pattern>switch</pattern>
<script>
SwitchCharacter
</script>
</command>
NOTE:Change your changeable character's names to 'c1' 'c2' etc. or it will not work! You can make what the player sees as the alias. If you have less than six characters then remove the needful. If you have more than six characters then learn from the code!
If you want you can copy your game's code and paste it into this file and continue creation after doing the desirable changes. You also can give me credit(Optional):
sgreig
20 May 2012, 13:04That's an interesting little script there, but I'm wondering if there's something missing?
At the moment, all it seems to do is modify the boolean value of c(x).scenery (not sure what this does?) and then move the player to the same room as another character object. I'm not sure how this is making you switch to another character though.
At the moment, all it seems to do is modify the boolean value of c(x).scenery (not sure what this does?) and then move the player to the same room as another character object. I'm not sure how this is making you switch to another character though.
sonic102
21 May 2012, 07:10Hey sgreig, why don't you try that? It just 'fakes' the switching. If you type switch, c1 will be visible and c2 will not be. So to the player it will appear as if it changed.
You can also check if the player is a certain character. Just see if player.character = "Character X" where X is the number of your character.
You can also change the attiribute player.character to an integer.(number). I made it string for status attirbute properties.
Have fun with my code-cum-library!
You can also check if the player is a certain character. Just see if player.character = "Character X" where X is the number of your character.
You can also change the attiribute player.character to an integer.(number). I made it string for status attirbute properties.
Have fun with my code-cum-library!
