ID:1906339
 
(See the best response by Kaiochao.)
Howdy folks, I am sorry if I have burden this site with lots of unneeded questions and such that would seem easy to anyone else. Today I come with a question, I have tried to make it so when you press Fly() you will first have a hovering icon_state, but when you move the icon_state will switch to that of you actually flying, sorta looks like superman. I realize I should not have both icon_states right on each other,but I was just trying stuff to put inbetween it and was NOT I repeat NOT trying to run it like that.
Code:
verb
Fly()
if(Fly==0)
icon = 'Base.dmi'
icon_state = "Hover"
icon_state = "Flying"
density = 0
usr.Fly=1
else
icon_state = "Male"
density=1
usr.Fly=0


Problem description:

Best response
1. Double click your Flying state's name (below the image) and check Movement State.
2. Rename your Hover state to Flying.
3. Set your icon_state to "Flying".
When you move, the Movement State version of your current icon_state will play. When you stop moving, the non-Movement State will play.
You want to go into the icon editor, and right click on the "Flying" state, and select "Edit State". Click on the box that says: "Movement State".

Change the name of "Hover" to "Flying".

Movement states are icon_states that are animated on the mob when it is actually moving. If you have two states with the same name, the first one will be used by default. However, if one of them is marked as a movement state, it will be used while you are actually moving. Also, if you only have a single icon, but mark it as a movement state, only the first frame will be shown when you aren't moving.

EDIT:

Hey guys it worked perfectly, but do you guys know a way so that I can only have the verb under certain conditions.

like I have it where usr.Fly=0 so u can fly, but if it equal 1 you can't. So can I have it where if FlyVerb=0 then you dont have it but if it equals 1 you do?

or should I just do the whole

src.verbs+=new/mob/verb/Fly()
Actually, a really interesting way to handle it would be to define the verb as a proc. Personally, I hate clickable verbs though, so I'd never use this approach myself.

mob
proc
Fly()
if(!canFly)
verbs -= /mob/proc/Fly
return
if(!flying)
icon_state = "Flying"
density = 0
flying = 1
verbs += /mob/proc/Land
verbs -= /mob/proc/Fly

Land()
if(flying)
icon_state = ""
density = 1
flying = 0
verbs += /mob/proc/Fly
verbs -= /mob/proc/Land


When the player gains the ability to fly, just add the fly proc to the verbs list. Verbs and procs are actually the same thing, it's just that verbs are procs that are handled in a special way. Under the hood, they are the same, though.
So it would be like exactly adding "src.verbs+=new/mob/verb/Fly()" just using proc? What's the diffrence and if you don't use clickable verbs what do you use.
So it would be like exactly adding "src.verbs+=new/mob/verb/Fly()" just using proc?

You actually don't need to create the verb using new like that. You can just add the type. You only initialize a verb when you want to be able to change the name or settings of the verb on the fly. (I don't recall, but settings may be able to be changed, may not be. Requires experimentation. It's been years since I fiddled with verbs.)

Anyway, the difference between making it a verb and a proc, is that the proc doesn't show up in the verbs list unless you TELL it to be there. So if you want to add a verb based on gaining an ability, procs are actually a decent way to do that. Also, creating an object and stuffing it into the client's contents and using "set src in usr" is another way to do that. But I don't like the object approach that much for various reasons. Mostly because usr is typecast to /mob, which is problematic. usr is easily one of the worst designed aspects of DM as a language, and has led to some of the most longstanding misunderstandings of how to write code in DM. It's indirectly responsible for how horribly designed and buggy the vast majority of BYOND games are.

you don't use clickable verbs what do you use.

I use keybinds and Mouse interaction.

I have two main verbs in my projects, MoveKey, and BindKey.

MoveKey handles the primary directional movement keys (WASD, Arrow pad, or numpad), and BindKey handles everything else.

client
verb
MoveKey(dir as num,state as num)
set hidden = 1
if(state)
//handle keypress
else
//handle keyrelease

BindKey(bind as num,state as num)
set hidden = 1
switch(bind)
if(1)
if(state)
//bind 1 keypress
else
//bind 1 keyrelease
if(2)
if(state)
//bind 2 keypress
//this one doesn't need a keyrelease


But yeah, there's a lot of work I've done to heavily customize how BYOND works behind the scenes. The way my projects are structure is... Well, you wouldn't recognize it.
I see, hey Ter if I have more questions should I ask on this post?
For archival purposes, it's best to keep unrelated questions in separate threads. Part of the purpose of Developer Help is to be a searchable archive of problems and solutions.

Throw Kaio's first post your vote and I'll see you in another thread for unrelated problems/questions, or in this one for questions related to movement states and icon states.
I do have one more about this. I used an obj to teleport a person and it takes them to the tile I set, but it like weridly puts them at like a diffrent part of the tile. Like upper left hand corner of that one tile making them off center
I do have one more about this.

That's wildly unrelated to the current topic, but I'll bite.

Are you using pixel movement? Show me the code that you are using.
usr.Freeze=1
usr.dir=SOUTH
usr.overlays += /obj/overlay/TimeHelmet
icon_state = "TimeHelmetOffTable"
usr << sound('Link.wav', volume=100)
sleep (60)
usr << sound('Link2.wav', volume=100)
sleep (40)
usr.overlays -= /obj/overlay/TimeHelmet
usr.loc=locate(62,90,1)
usr.TimeHelmet=1
usr.Freeze=1 is right above usr.dir=SOUTH it's not actually indented
Show me the whole proc please, and answer my question: Are you using pixel movement? You need to do a better job of reading what other people ask/say. I may be verbose, but I'm not in the habit of writing things without reason.

It's hard to go on parts of procedures, because there's a lot of context left out. I need to be able to understand the scope that we're in, and what src is, what usr is, and whatnot. Just seeing a short bit of a proc/verb doesn't tell me any of these things, so I'm likely to give you bad advice because I can't know things that you don't show me.
No and this is all I got.
obj
TimeHelmetOnTable
icon = 'TimeHelmet.dmi'
icon_state = "TimeHelmetOnTable"
density=1
verb
Time_Travel()
set src in view(1)
set category = "TimeHelmet"
if(usr.TimeHelmet==0)
usr.Freeze=1
usr.dir=SOUTH
usr.overlays += /obj/overlay/TimeHelmet
icon_state = "TimeHelmetOffTable"
usr << sound('Link.wav', volume=100)
sleep (60)
usr << sound('Link2.wav', volume=100)
sleep (40)
usr.overlays -= /obj/overlay/TimeHelmet
usr.loc=locate(62,90,1)
usr.TimeHelmet=1
No and this is all I got.

If you aren't using pixel movement, your mob should be showing up in the tile that they are supposed to. Are you 100% certain that you aren't using pixel movement?
Screenshots might also help.
Ok I looked and I am
obj
TimeHelmetOnTable
icon = 'TimeHelmet.dmi'
icon_state = "TimeHelmetOnTable"
density=1
verb
Time_Travel()
set src in view(1)
set category = "TimeHelmet"
if(usr.TimeHelmet==0)
usr.Freeze=1
usr.dir=SOUTH
usr.overlays += /obj/overlay/TimeHelmet
icon_state = "TimeHelmetOffTable"
usr << sound('Link.wav', volume=100)
sleep (60)
usr << sound('Link2.wav', volume=100)
sleep (40)
usr.overlays -= /obj/overlay/TimeHelmet
usr.loc=locate(62,90,1)
var/matrix/m = usr.transform
usr << "DEBUG: ([usr.x]:[usr.step_x]+[usr.pixel_x]+[m.c],[usr.y]:[usr.step_y]+[usr.pixel_y]+[m.f],[usr.z]+[usr.pixel_z])"
usr.TimeHelmet=1


Give that a run and let me know what it prints after the teleport.
:185:error: inconsistent indentation

I got that for the usr<< "Debug line
Page: 1 2