ID:178317
 
Is there a way to make a player click on something as input? If so, what is the syntax?

An example would be something like: click on either door #1 or door #2 to choose your path.
obj/Door
Click()
set src in oview(1)
src.Open = 1 - src.Open //Toggles Open between 1 and 0
src.density = 1 - src.density
if(Open == 1)
src.icon_state = "Open"
else
src.icon_state = "Closed
In response to Garthor
ok . . . I know about click() by itself . . .


Here's a better example. You can click on a switch all day long and nothing will happen. Then, for whatever reason, an input prompt comes up and tells you to click on the switch. Now if you click on the switch, the switch is sent to the input as an argument, and things begin to happen. Is there any way to do that?


what I don't need something like:

obj/whatever/click()
if (var == whatever)
[do somehting]
else
[do nothing]


I need to know how to pass the thing you click to input as an argument.
In response to Gakumerasara
Gakumerasara wrote:
ok . . . I know about click() by itself . . .


Here's a better example. You can click on a switch all day long and nothing will happen. Then, for whatever reason, an input prompt comes up and tells you to click on the switch. Now if you click on the switch, the switch is sent to the input as an argument, and things begin to happen. Is there any way to do that?

Well, you would need a toggle variable (Open/Close), but also another variable that lets the object know if the switch will do anything.

It is a bit hard to understand what you are trying to do here, but I hope what I said helped. :)

- Malver
In response to Malver
here's another way of looking at it:



you can say

var/M = (input("","",) in [some_random_list])

to choose one thing from within the list to output as M



Let's say the list consists of a few things sitting in front of you on the map. The input menu comes up and asks you to select one of the objects in the example above. What I need to know is how to just be able to click on one of the objects to return it as M. I don't think it can be part of the click() proc because the code before and after the required input will always vary.
You'll need use the atom's Click() proc to trap the action, then test the Click() usr to see if it is allowed to click this option yet.

Here is an example of one way to do this, including an alert window that refuses to go away until the player clicks on one of the doors. You can not choose a door until you have activated the prompt with the force2choose verb.
turf
door
icon = 'door.dmi'
// door.dmi has icon states for each number.
// Use the map editor to place each icon state
// you want on the map.
Click()
usr.Select(icon_state)

mob
var/obj/inputobj/Prompt
verb
force2choose()
if(Prompt)
src << "Already waiting for a choice."
return
Prompt = new()
Prompt.owner = src
Prompt.activate()
proc
Select(n)
// can't select until you are asked to
if(!Prompt) return

src << "You chose door number [n]."
del(Prompt) // close the prompt

obj/inputobj
// this obj just maintains the alert window until
// it's time to delete it
var/mob/owner

verb
activate()
while(1) // repeat until the obj is deleted
alert(owner, "Choose a door!")