Scripts / Set Player position.

Author
Message
duramin
8
Years of Service
User Offline
Joined: 25th May 2015
Location:
Posted: 4th Jun 2015 12:25 Edited at: 4th Jun 2015 12:57
Hello,

short question, is there the posibility to set a players position? i know of the g_PlayerPosX/Y/Z but they seem to be read only...(or maybe i am to stupid )
PM
!nullptr
Forum Support
9
Years of Service
User Offline
Joined: 27th Mar 2015
Location: Australia
Posted: 4th Jun 2015 14:05 Edited at: 4th Jun 2015 14:07
The easiest way off the top of my head is use TransportToIfUsed(e)

Current entity has destination entity in "If Used" field and when used will transport you. eg: a teleport decal or similar. "Destination" entity needs to be named the same as the If Used field in the "departure" entity.

I have no idea if that even makes sense.

It's late here in Australia - I'm off to bed - so I'll revisit this in the morning to see if it worked

Guten nacht.
AKA SisterMatic (Steam)
Development/ Gaming Rigs
Sys 1: i7-4770 (3.5)/16Gb/128 SSD/3Tb/970gtx/2 x 23, 1 x 27 LCD - Sys 2: i7/8Gb/670gtx/1.5Tb/1 x 23 LCD - Sys 3: Amd Quad/8Gb/645gtx/1Tb/30" LCD
PM
duramin
8
Years of Service
User Offline
Joined: 25th May 2015
Location:
Posted: 4th Jun 2015 14:11
Guten Tag (as its bright daylight here in Berlin (sunny, btw...getting summer...)

thanks for the idea, but it won't work in this case. i need this without interaction (something like entering a zone then get teleportet to another position...)
Maybe another idea? if not: sleep well , my friend and Dankeschön
PM
smallg
Community Leader
18
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 4th Jun 2015 18:13
why wont that work? you just place the entity and transport/teleport to it - you can move the entity anywhere you like before you teleport to it with SetPosition(#,x,y,z)
life\'s one big game

windows vista ultimate

i5 @3.3ghz, 4gb ram, geforce gtx460, directx 11
duramin
8
Years of Service
User Offline
Joined: 25th May 2015
Location:
Posted: 4th Jun 2015 19:58 Edited at: 4th Jun 2015 21:27
Thanks, figured out that i need two entitys, so that will do Now i struggle with SetPosition: How do i get the entity number of the target entity, wich i would like to move?
At the moment i do a

g_Target_e=e

in the init of the target entity
and in the main script from the "activation entity" (sorry, didn't find a better name ..erm..)

SetPosition(g_Target_e,x,y,z)

.. is ther a more... elegant way to achive this?
if not..well..hell, it works ^^
PM
3com
9
Years of Service
User Offline
Joined: 18th May 2014
Location: Catalonia
Posted: 4th Jun 2015 21:24
Quote: "How do i get the entity number of the target entity, wich i would like to move?"

When you move mouse over an entity you get their id (number) bottom of the editor, some like: Mybox: 2{700002} or somethink like that, so in this case Mybox number (ID) is = 2; so, g_Target_e=2.

hth

3com
Laptop: Lenovo - Intel(R) Celeron(R) CPU 1005M @ 1.90GHz

OS: Windows 8.1 (64) - Ram: 4 gb - Hd: 283 gb - Video card: Intel(R) HD Graphics

PM
duramin
8
Years of Service
User Offline
Joined: 25th May 2015
Location:
Posted: 4th Jun 2015 21:30 Edited at: 4th Jun 2015 21:30
Ay, thank you very much.. forgotten to clarify: i want to solve it completely programatically..so, i would like to reuse it without the necessarity of altering the code. (errrrr... sorry, no native english speaker ^^ so, i hope it make sense)
PM
!nullptr
Forum Support
9
Years of Service
User Offline
Joined: 27th Mar 2015
Location: Australia
Posted: 4th Jun 2015 22:41 Edited at: 4th Jun 2015 22:43
Duramin

I'm not sure of your skills in LUA but there is a feature where the "name" of an entity can be captured so you have a dynamic referencing solution.

Create an array holding "name". A building might be named "My House" or "Fire Station" in properties. You can then search the array to find "My House" or "Fire Station" and the array index will be the "e" you require. Clearly this will only work properly where building names do not share the same name. You could end up at either one.

The init function MUST have the _name extension.

Here's an example of how you reference the name.
AKA SisterMatic (Steam)
Development/ Gaming Rigs
Sys 1: i7-4770 (3.5)/16Gb/128 SSD/3Tb/970gtx/2 x 23, 1 x 27 LCD - Sys 2: i7/8Gb/670gtx/1.5Tb/1 x 23 LCD - Sys 3: Amd Quad/8Gb/645gtx/1Tb/30" LCD
PM
duramin
8
Years of Service
User Offline
Joined: 25th May 2015
Location:
Posted: 4th Jun 2015 23:13 Edited at: 4th Jun 2015 23:14
Ay, i knew there is a more elegant way

To my expoerience with Lua...well....written a WoW addon "nearly 100 years ago"..does that count ..??..no??.. erm, now you know about my lua skills, learnd not much and forgotten twice of it *cough*

thanks for the reference, i will look after it..tomorrow.. its getting late here all dark

to speak with the words of a whise man:

"It's late here in Australia Germany- I'm off to bed - so I'll revisit this in the morning to see if it worked

Guten nacht. "

all in all, thanks a lot for your help, mate
PM
!nullptr
Forum Support
9
Years of Service
User Offline
Joined: 27th Mar 2015
Location: Australia
Posted: 4th Jun 2015 23:17
Quote: ""It's late here in Australia Germany- I'm off to bed - so I'll revisit this in the morning to see if it worked

Guten nacht. "
"


And in the words of another wise man

Guten Tag (as its bright daylight miserably cloudy here in Berlin Australia (sunny foggy, btw...getting summer winter...)


AKA SisterMatic (Steam)
Development/ Gaming Rigs
Sys 1: i7-4770 (3.5)/16Gb/128 SSD/3Tb/970gtx/2 x 23, 1 x 27 LCD - Sys 2: i7/8Gb/670gtx/1.5Tb/1 x 23 LCD - Sys 3: Amd Quad/8Gb/645gtx/1Tb/30" LCD
PM
duramin
8
Years of Service
User Offline
Joined: 25th May 2015
Location:
Posted: 5th Jun 2015 12:40 Edited at: 5th Jun 2015 12:59
Helllooooooo Sunny Germany errr...^^

So, serious.ly: Yes, i CAN index all together in one big array, and this is really helpfull and elegant, but (don't be mad with me ^^) i stick with my solution as i use up only one global and everything is fine

maybe (even after i do my best to hurt your feelings by NOT using your solution.....naaaah, you 're australian, you can handel this ...just kiddin') you can help me with something different that came up: after doing a setposition (bind to a key, in this case "j") if i try to walk with the arrow keys, it repeats the SetPosition/ TransportToIfUsed instead of walking.. if i use any other key (wasd or space ect) everything is fine again and after pressing only one key, i can reuse the arrowkeys..(man, is that hard to try to explain something in a language, i learned about 30 years ago......hope you can understand my "rabbelbabbel" *lol*

to clarify the part of the script:



is it a bug? a feature? does gameguru dislike me? am i to stupid? do i need more beer??? ... ;
PM
!nullptr
Forum Support
9
Years of Service
User Offline
Joined: 27th Mar 2015
Location: Australia
Posted: 5th Jun 2015 13:13
Hahahaha.... Not using my solution is your problem not mine. I see your code with hardcoded jump co-ordinates and I smile. You'll get why an array might be... cough... a better solution

As for the other issue..... Hmmmm.....

It doesn't look right to me for several reasons but without starting up my editor and GG at such a *late* hour I'm not going to be able to test a solution for you. Initially the 2 x SetPositions AND the TransportToIfUsed can't be right. The other is no prevention of the "j" from triggering multiple times.

(when you press a key, if you don't set a flag to check the keypress ie: pressed = 0 then it will get multiple reads.)

Alas Northern Hemisphere Person, these are my only clues until

1) It is "Guten Tag" for me or
2) You understand what I'm saying or
3) Someone else takes it up.

Stay Well.
Guten Nacht.

PS: If no-one else does it beforehand, and I don't die tonight, I'll look at this tomorrow for you.
AKA SisterMatic (Steam)
Development/ Gaming Rigs
Sys 1: i7-4770 (3.5)/16Gb/128 SSD/3Tb/970gtx/2 x 23, 1 x 27 LCD - Sys 2: i7/8Gb/670gtx/1.5Tb/1 x 23 LCD - Sys 3: Amd Quad/8Gb/645gtx/1Tb/30" LCD
PM
duramin
8
Years of Service
User Offline
Joined: 25th May 2015
Location:
Posted: 5th Jun 2015 13:24 Edited at: 5th Jun 2015 13:25
You are allowed to smile ^^ this is only a short test i made up, i dont use hardcoded coordinates normaly, and no, the 2.nd SetPosition doesn't change anything ( was my stupid old brain, thinking it "may collide somehow with the entity" ..wich is stupid, i know...so i threw it in AFTER i noticed this arrow key thingy)

the wait for release key thingy i really have to try (but why would it be an issue only with the arrow keys, not the wasd..? )

Well, as it is a forum, and other people may read it, i will catch every clue i can get , not only yours

Sleep well, dream well, and don't let the bed-bugs bite. i will play arround with it a little more
PM
!nullptr
Forum Support
9
Years of Service
User Offline
Joined: 27th Mar 2015
Location: Australia
Posted: 5th Jun 2015 13:33
Quote: "the wait for release key thingy i really have to try (but why would it be an issue only with the arrow keys, not the wasd..? )"

A quick response to this... I don't know. I always use scancodes rather then g_Inkey from habit because some keys weren't reading properly (or at all) from memory.

I will look at this tomorrow, I promise. You have now created curiosity, a bad condition for programmers to sleep by. The night will be restless.
AKA SisterMatic (Steam)
Development/ Gaming Rigs
Sys 1: i7-4770 (3.5)/16Gb/128 SSD/3Tb/970gtx/2 x 23, 1 x 27 LCD - Sys 2: i7/8Gb/670gtx/1.5Tb/1 x 23 LCD - Sys 3: Amd Quad/8Gb/645gtx/1Tb/30" LCD
PM
!nullptr
Forum Support
9
Years of Service
User Offline
Joined: 27th Mar 2015
Location: Australia
Posted: 6th Jun 2015 03:09
I had a look at this and found a couple of things a bit strange but had no issue with arrow keys reading incorrectly.

This bit of code was used to test and "j" always caused the jump correctly with no other keys causing interference.

I did find some irregularity with SetPosition and ResetPosition - see my comments in the code. I used barrels as entities. Barrel 1 had this code assigned and If Used was pointed to Barrel 2 which had no code assigned except for an empty default.lua

If Barrel 2 static was YES, myself and Barrel 2 moved to new coordinates but only with ResetPosition(). If Barrel 2 static was NO, I moved to the co-ordinates but with no barrel.

With SetPosition, I moved to where the barrel was, not the co-ordinates I required?! (The co-ordinates listed are not Barrel 2's starting position).

I've run out of time to keep testing but it is certainly not as I expected. (It could be my code, I haven't tested every possibility here).

Hopefully the answer you seek is within. If not, you may have to escalate the arrow key issue as a bug if you can replicate it readily. As for the odd jump behaviour, I need to keep experimenting with it.

AKA SisterMatic (Steam)
Development/ Gaming Rigs
Sys 1: i7-4770 (3.5)/16Gb/128 SSD/3Tb/970gtx/2 x 23, 1 x 27 LCD - Sys 2: i7/8Gb/670gtx/1.5Tb/1 x 23 LCD - Sys 3: Amd Quad/8Gb/645gtx/1Tb/30" LCD
PM
duramin
8
Years of Service
User Offline
Joined: 25th May 2015
Location:
Posted: 6th Jun 2015 10:03 Edited at: 6th Jun 2015 11:28
Thanks for your detailed answer, much appreciated. Unfortunately this has to wait for a moment as i do have some family business to do (couldn't do anything yesterday...hrmpf...) . At last, thanks to prove that i am not a completely idiot (er..more or less ^^ as you state that it isn't working as you expected)
For the arrow key issue: maybe i do something wrong before i use the code or even my machine is stupid ^^( wich it will only do to match up with its user )

yes, you are right, its hard to leave it alone and do different things such as sleeping, family business, eating......

MANY, MANY THANKS for all your help!

EDIT:

Did a Quick test with your (and ONLY your code ^^ nothing left from me, no dlls included i am working on ect..) made a testlevel with the following specs:

1st barrel:
name=lilstinker (for the lulz)
IfUsed=barrel2
script=jump.lua (your script)
nothing else changed

2nd barrel
name=barrel2
nothing else changed

placed a player startmarker
started the level and first moved a bit around, everything is fine.
pressed j=>it jumped (with your described..strange behavior)
pressed any arrowkey directly after pressing j (to be as clear as possible: released the "j" key, didn't touch the mouse or anything else, counting "twetyone...twentytwo" then pressed the "up"-arrow)... it jumped again , pressed any arrowkey after that all repeats the jumps... pressed one time the "w" (no jump) and then the up-arrow, then it worked like expected... so, i guess its my machine
Got Win 8.1 pro 64 Bits on an AMD Phenom II X4 3,1 (i know, old one, but do the work ^^), 16GB Ram , AMD R9 270 GFX and a OCZ 500 GB ssd as specs. (everything is updated, drivers brand new)

and yes, it also did..strange things beside of that (wich my script didn't so i dont bother ^^)
If you got no clue, i call it a "feature" and leave it alone for the moment, as it isn't the BIG issue .. sure, something i have to come back later on but not now ^^

and thanks for your patience!

For all others, reading this: If You have any idea or can confirm my problem (maybe someone with a pc with similar specs and enough time to do a test) feel free to fire your ideas

if not..well, i do come back later to this issue after some updates
PM
smallg
Community Leader
18
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 6th Jun 2015 15:12 Edited at: 6th Jun 2015 15:17
confirmed the jumping/teleport for non InKeys presses (it's also 'home', 'page up' etc)
i used Prompt(g_InKey) and you can see it resend the "j" press on the arrows etc so that's why it's jumping again (definitely a bug)
you can add
and GetScancode() < 198
to the jump check and that should clear it up
i'll attach the scancodes here so you can see the numbers
life\'s one big game

windows vista ultimate

i5 @3.3ghz, 4gb ram, geforce gtx460, directx 11

Attachments

Login to view attachments
J_C
16
Years of Service
User Offline
Joined: 9th Nov 2007
Location:
Posted: 6th Jun 2015 16:28
Wait a minute guys...

surely you can't just reset the pressed variable to zero in the the jump code...

you need to check the g_InKey == 0 then reset the pressed variable to zero...

I have not checked this but that's what it looks like to me..
PM
smallg
Community Leader
18
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 6th Jun 2015 17:12
Quote: "Wait a minute guys...

surely you can't just reset the pressed variable to zero in the the jump code...

you need to check the g_InKey == 0 then reset the pressed variable to zero...

I have not checked this but that's what it looks like to me.."


i thought so too but it still does the same
life\'s one big game

windows vista ultimate

i5 @3.3ghz, 4gb ram, geforce gtx460, directx 11
J_C
16
Years of Service
User Offline
Joined: 9th Nov 2007
Location:
Posted: 6th Jun 2015 17:49
I just had to try it...
the test should be g_InKey == ""
not g_InKey == 0 like I put above...

but you are correct it is still called when the
arrow keys/pageup/down/home/end block keys
where used after the j key... very strange..

GG must not be resetting the g_InKey value until it has another character key..?
good find...

PM
duramin
8
Years of Service
User Offline
Joined: 25th May 2015
Location:
Posted: 6th Jun 2015 18:08
Yay, so much help

First of all: thank you for your time and testing.
So its not only my machine and i can relax. So now the ultimative Noob question (jaiks) : how do i do a propper bug report here, or is it fine as is (as one of the mod team knows already all about...who is hopefully sleeping well at the moment ) ?

PM
3com
9
Years of Service
User Offline
Joined: 18th May 2014
Location: Catalonia
Posted: 6th Jun 2015 23:27
Quote: "how do i do a propper bug report here"

There is a bug sub-forum. Goto forum home.

It looks like GG does not handle fine when get/return key focus to/from windows.
Sometime I should press many times the "R" key in editor, in order to rotate some item.

3com
Laptop: Lenovo - Intel(R) Celeron(R) CPU 1005M @ 1.90GHz

OS: Windows 8.1 (64) - Ram: 4 gb - Hd: 283 gb - Video card: Intel(R) HD Graphics

PM

Login to post a reply

Server time is: 2024-05-03 05:17:58
Your offset time is: 2024-05-03 05:17:58