<object name="Room1">
<inherit name="editor_room" />
<listchildren />
<description type="string"></description>
<enter type="script">
if (Trap1.parent = Room1) {
if (IsSwitchedOn(Trap1)) {
msg ("Boom (Random Place, Lose All Items)")
}
}
if (Trap2.parent = Room1) {
if (IsSwitchedOn(Trap2)) {
msg ("Boom (Random Place, Lose All Items)")
}
}
if (Trap2.parent = Room1) {
if (IsSwitchedOn(Trap2)) {
msg ("Boom (Random Place, Lose All Items)")
}
}
if (Trap3.parent = Room1) {
if (IsSwitchedOn(Trap3)) {
msg ("Boom (Random Place, Lose All Items)")
}
}
if (Trap4.parent = Room1) {
if (IsSwitchedOn(Trap4)) {
msg ("Boom (Random Place, Lose All Items)")
}
}
if (Trap5.parent = Room1) {
if (IsSwitchedOn(Trap5)) {
msg ("Boom (Random Place, Lose All Items)")
}
}
if (Trap6.parent = Room1) {
if (IsSwitchedOn(Trap6)) {
msg ("Boom (Random Place, Lose All Items)")
}
}
if (Trap7.parent = Room1) {
if (IsSwitchedOn(Trap7)) {
msg ("Boom (Random Place, Lose All Items)")
}
}
if (Trap8.parent = Room1) {
if (IsSwitchedOn(Trap8)) {
msg ("Boom (Random Place, Lose All Items)")
}
}
if (Trap9.parent = Room1) {
if (IsSwitchedOn(Trap9)) {
msg ("Boom (Random Place, Lose All Items)")
}
}
</enter>
if (player.opponent = "Op1") {
msg ("Your Target (" + player.opponent + ") is in Room" + Op1.parent)
}
if (player.opponent = "Op2") {
msg ("Your Target (" + player.opponent + ") is in Room" + Op2.parent)
}
if (player.opponent = "Op3") {
msg ("Your Target (" + player.opponent + ") is in Room" + Op3.parent)
}
if (player.opponent = "Op4") {
msg ("Your Target (" + player.opponent + ") is in Room" + Op4.parent)
}
if (player.opponent = "Op5") {
msg ("Your Target (" + player.opponent + ") is in Room" + Op5.parent)
}
if (player.opponent = "Op6") {
msg ("Your Target (" + player.opponent + ") is in Room" + Op6.parent)
}
if (player.opponent = "Op7") {
msg ("Your Target (" + player.opponent + ") is in Room" + Op7.parent)
}
if (player.opponent = "Op8") {
msg ("Your Target (" + player.opponent + ") is in Room" + Op8.parent)
}
if (player.opponent = "Op9") {
msg ("Your Target (" + player.opponent + ") is in Room" + Op9.parent)
}
dgparryuk wrote:Is there an easier way of doing this than i've just done?
I have 502 rooms - i don't really want to repeat that that many times....
for (i, 1, 9) {
o = GetObject("Trap" + i)
if (o.parent = player.parent) {
if (IsSwitchedOn(o)) {
msg ("Boom (Random Place, Lose All Items)")
}
}
}
dgparryuk wrote:and a second bit of BAD code from me....if (player.opponent = "Op1") {
msg ("Your Target (" + player.opponent + ") is in Room" + Op1.parent)
}
if (player.opponent = "Op2") {
msg ("Your Target (" + player.opponent + ") is in Room" + Op2.parent)
}
if (player.opponent = "Op3") {
msg ("Your Target (" + player.opponent + ") is in Room" + Op3.parent)
}
if (player.opponent = "Op4") {
msg ("Your Target (" + player.opponent + ") is in Room" + Op4.parent)
}
if (player.opponent = "Op5") {
msg ("Your Target (" + player.opponent + ") is in Room" + Op5.parent)
}
if (player.opponent = "Op6") {
msg ("Your Target (" + player.opponent + ") is in Room" + Op6.parent)
}
if (player.opponent = "Op7") {
msg ("Your Target (" + player.opponent + ") is in Room" + Op7.parent)
}
if (player.opponent = "Op8") {
msg ("Your Target (" + player.opponent + ") is in Room" + Op8.parent)
}
if (player.opponent = "Op9") {
msg ("Your Target (" + player.opponent + ") is in Room" + Op9.parent)
}
again an easier way of doing it?
a neater way? and the output is "Object : Room213" is there anyway of changing that to just Room213 or even the Alias
ie Room7 is "Access Road" (one of about 20 rooms called Access Road) or am i doing it wrong?
msg ("Your Target (" + GetDisplayAlias(player.opponent) + ") is in Room" + GetDisplayAlias(player.opponent.parent))
The Pixie wrote:"dgparryuk"
Is there an easier way of doing this than i've just done?
I have 502 rooms - i don't really want to repeat that that many times....
Do you want this same code to run when the player enters every room? Go to the Script tab of the game object, and put the script in the "Script when entering a room" bit.
Code (untested!):for (i, 1, 9) {
o = GetObject("Trap" + i)
if (o.parent = player.parent) {
if (IsSwitchedOn(o)) {
msg ("Boom (Random Place, Lose All Items)")
}
}
}
The Pixie wrote:
This should do all that (GetDisplayAlias will grab the alias if it has one, and the name otherwise):msg ("Your Target (" + GetDisplayAlias(player.opponent) + ") is in Room" + GetDisplayAlias(player.opponent.parent))
Error running script: Error compiling expression '"Your Target (" + GetDisplayAlias(player.opponent) + ") is in Room" + GetDisplayAlias(player.opponent.parent)': Object reference not set to an instance of an object.
msg ("Op9 is worth : " + Op9.prize)
show menu ("Choose Your Opponent?", Split ("Op1;Op2;Op3;Op4;Op5;Op6;Op7;Op8;Op9", ";"), false) {
player.opponent = GetObject(result)
msg ("Your Opponent is : " + player.opponent.name)
}
}
else {
tmp_opponent = GetRandomInt(1,9)
player.opponent = GetObject("Op" + tmp_opponent)
msg ("Your Opponent is : " + player.opponent.name)
}
}