ID:279801
 
(See the best response by Popisfizzy.)
Code:
//example of basic turf

turf
title
name = "Title"
icon = 'title1.PNG'
layer = 2
density = 1
opacity = 0

//example of attempted broken code

turf
title
name = "Title"
layer = 2
density = 1
opacity = 0
if(gamemode==1)
icon = 'title1.PNG'
if(gamemode==2)
icon = 'title2.PNG'


Problem description: I have an image for my title screen I would like to change corresponding to certain variables in the world. When the value of the variable changes, the turf will not react.

But with the coding example I show above, I get errors. Such as;

layout.dm:11:error: gamemode: duplicate definition
layout.dm:11:error: "1": duplicate definition
layout.dm:11:error: ==: instruction not allowed here
layout.dm:11:error: : duplicate definition
layout.dm:13:error: gamemode: duplicate definition
layout.dm:13:error: "2": duplicate definition
layout.dm:13:error: ==: instruction not allowed here
layout.dm:13:error: : duplicate definition
layout.dm:12:error: : duplicate definition
layout.dm:14:error: : duplicate definition

Game.dmb - 10 errors, 0 warnings (double-click on an error to jump to it)


Best response
Perhaps, you can try making two separate turfs and removing the gamemode==1,gamemode==2 codes
 turf
title
name = "Title"
icon = 'title1.PNG'
layer = 2
density = 1
opacity = 0
title2
name = "Title2"
icon = 'title2.PNG'
layer = 2
density = 1
opacity = 0
I had already attempted to do that, but when I initiate the verb to change the title screen turf, only the player who initiates the verb (a host or admin) will move to the new turf. Unless there is a way I can change the eye or loc of all players in the world.

Below is my verb to initiate.

mob/host/verb
change_mode()
set name = "Change Mode"
set desc = "Change the game's playing mode."
switch(input("What mode would you like you change to?", "Game Mode") in list ("Mode1", "Mode2", "Mode3"))
if("Mode1")
gamemode = "Mode1"
world<<sound(null)
client.eye=locate(8,7,1)
world<<sound('Sound.ogg', repeat=1)
world<<output("Mode has been changed to <b>Mode1</b>.", "output1")
return
if("Mode2")
gamemode = "Mode2"
world<<sound(null)
client.eye=locate(22,7,1)
world<<sound('Sound.ogg', repeat=1)
world<<output("Mode has been changed to <b>Mode2</b>.", "output1")
return
if("Mode3")
gamemode = "Mode3"
world<<sound(null)
client.eye=locate(8,7,1)
world<<sound('Sound.ogg', repeat=1)
world<<output("Mode has been changed to <b>Mode3</b>.", "output1")
return


My main problem with this code I tried recently is that it will display my first turf, title1, but when Mode2 is selected, the eye will not focus on title2, it just makes the map go black.

I assumed at first you could change the icon of a turf, but I didn't know you can't. My main goal on the other hand is to either move all players in the world onto coord (22,7,1) from (8,7,1), or just the client.eye from (8,7,1) to (22,7,1) when the verb is called.

My default eye is.

var/client
eye = locate(8,7,1)


And upon login I have.

mob/Login()
usr<<output("Welcome!", "output1")
if(gamemode=="Mode1")
client.eye=locate(8,7,1)
usr<<sound('Sound.ogg', repeat=1)
if(gamemode=="Mode2")
client.eye=locate(22,7,1)
usr<<sound('Sound.ogg', repeat=1)
if(gamemode=="Mode3")
client.eye=locate(8,7,1)
usr<<sound('Sound.ogg', repeat=1)


I just cannot seem to get the eye to focus on the turf I placed on the map at the coordinates (22,7,1).
Uhm... first thing, if you are actually using exactly the same sound regardless of the mode, why write it three times?

mob/Login()
usr<<output("Welcome!", "output1")
switch(gamemode)
if("Mode1")
client.eye=locate(8,7,1)
if("Mode2")
client.eye=locate(22,7,1)
if("Mode3")
client.eye=locate(8,7,1)
usr<<sound('Sound.ogg', repeat=1)


(although you probably only need one if since 1 and 3 seem to be identical)
Second thing: is gamemode actually defined anywhere? Where does it take its value at login time?
You cannot set icon for an object conditionally at compile-time (talking about if(), else). What you need is to change the icon of your title screen during runtime.

Example:
/* Not 100% sure if this example works. I haven't touched DM for a while. */

mob/verb/change_game_mode()
var/turf/T = locate(/turf/title_screen) in world
switch(mode)
if(1) T.icon = 'mode1.dmi'
if(2) T.icon = 'mode2.dmi'
if(3) T.icon = 'mode3.dmi'


Also, please do not use usr in procs. Although it compiles, but it will cause runtime errors in some circumstances. For more information, read the usr var section in the reference.
Thank you Hashir I will attempt to try this.

Also Kccmt, I took out all the main values, it's a different sound but I was using 'Sound' as an example. The main basic mode was "Mode1". And since my third title screen is not up yet, I was using the coords for screen1 until I change it.

Anyway, thank you all for the advice. I will come back if I have future problems.