ID:157525
 
I have been trying for 3 days to work out a macro system for clicking. This is coded by myself but it never worked out. I got confused by the logic. And posting is going slowly in design philosophy, not that I dont apreciate them trying to help, I just feel the help may be more of what I'm looking for here.

mob/player/var/last_clicked


obj
skillcards

Click()
var/mob/player/p=usr
p.last_clicked=src
usr << "you clicked skillcard"
switch(input("Select a key to set this macro to", "Macro", text) in list ("1","2","Nevermind"))
if("1")
// macroinput = 1
winset(usr,"macro1","parent=macro;name=1;command=[p]")
if("2")
// macroinput = 2
winset(usr,"macro1","parent=macro;name=2;command=[p]")


Bed
icon = 'bed.dmi'
icon_state = "emptybed"
Click()
src = "Test1"
usr << "you clicked Bed"
verb
Test1()
usr << "Test"


What I want this to do: When I click on an object under skillcards it prompts me to macro it, then that object that I clicked on has a vvariable that is set for the command.

What it does: Nothing...
Don't know if this is a problem or not. I don't use input much but
input(Usr=usr,Message,Title,Default) as Type in List
You have
input("Select a key to set this macro to", "Macro", text) in list ("1","2","Nevermind")

it appears you are missing usr: input(usr, "Select...

Also, I believe parameters need to be in quotes, like [Edit: I just looked in the skin reference and it shows an example without quotes, os I may be mistaken on this one. It's worth a try though :)]
winset(usr,"macro1","parent=macro;name=1;command=[p]")
would be
winset(usr,"macro1","parent=\"macro\";name=\"1\";command=\"[ p]\"") // \" means it will be written " in the message

lastly, to see if it's working properly, why not replace all instances of usr with p? Just to make sure that P is really the usr and keep it consistent.
usr << "you clicked skillcard" -> p << "you clicked skillcard"



Also, as a note, the people that helped you in the design philosophy forum are the same as those that would help you here.
That would likely be because you are setting the command to p, which is the player, which most likely is not a valid command.
In response to Garthor
lol, I didn't even look at that :)
under obj/skillcards/Click() says var/mob/player/p = usr
it shouldn't be a variable it should be /mob/player/p = usr
obj
skillcards

Click()
/mob/player/p=usr

also, if you want to use input like that, do this
mob/var/macro //create a useless variable to input

usr.macro=input("Select a key to set this macro to",
"Macro",
usr.macro) in list("1","2","Nevermind")
if(usr.macro=="1")
//macro 1 stuff goes here
if(usr.macro=="2")
//macro 2 stuff goes here
if(usr.macro=="Nevermind")
return


In response to Redslash
Ok. Well.... this doesnt do anything! It only sends me the message under the Bed obj.

/var/last_clicked


obj
skillcards

Click()
// var/mob/player/p=usr
// p.last_clicked=src
src << "you clicked skillcard"
switch(input(usr, "Select a key to set this macro to", "Macro", text) in list ("1","2","Nevermind"))
if("1")
// macroinput = 1
winset(usr,"macro1","parent=macro;name=1;command=[last_clicked]")
if("2")
// macroinput = 2
winset(usr,"macro1","parent=macro;name=2;command=[last_clicked]")


Bed
icon = 'bed.dmi'
icon_state = "emptybed"
Click()
last_clicked = "TestOBJ"
src << "you clicked Bed"
verb
TestOBJ()
set hidden = 1
usr << "Testing obj"
mob
verb
TestMOB()
set hidden = 1
usr << "Testing mob"

mob
verb
givebed()
new/obj/skillcards/Bed(src)
In response to Darkjohn66
try mine
XD
In response to Kokomo0020
? its like incompatable now. I didn't really want to use that player stuff... confused <---
In response to Kokomo0020
This advice is wrong, on both counts. "/mob/player/p=usr" would just throw an error, and a switch() statement is exactly as valid as an if-else chain there (though you just had a string of if() statements, which is slightly worse). Of course, you also mucked it up with mob/var/macro, which is wrong right there and wrong if it were placed somewhere else where it would compile properly. Local variables are good, not bad.

Technically, for the second case, there doesn't need to be any if() statements at all (well, one for cancel), as they only differ by one character in one string, so they might as well be:

var/input = input() as null|anything in list()
if(input)
winset(usr, "blah", "name=[blah]")
In response to Darkjohn66
The Bed's Click() is going to override the Click() from obj/skillcards. You either need to remove it entirely, or you need to call the parent (..()) from the Bed's Click() proc.
In response to Garthor
Ahah! Remember a while ago when I asked how ..() and . worked.... guess I never got the message.........
In response to Kokomo0020
Kokomo0020 wrote:
under obj/skillcards/Click() says var/mob/player/p = usr
it shouldn't be a variable it should be /mob/player/p = usr
> obj
> skillcards
>
> Click()
> /mob/player/p=usr
>

You are quite the good programmer. Before you post help you should test out what you are doing. This wouldn't even compile.

The help link should help you see how to define a type as a variable to use within procedures. Here is an exert.

var/mob/Player/movementceased = 0

proc/Proc1()
var/mob/Player/M = new
if(M.movementceased) //Now, if the mob in question didn't have that variable,
//it would come up as a compile-time error. Compile time errors are
//normally much easier to fix than run-time errors.

proc/Proc1(mob/Player/M)
if(M.movementceased)

mob/Click()
var/mob/Player/M = usr
src.HP--
M.movementceased = 1
In response to Ulterior Motives
Thanks so much everybody for your help.