Product Chat / ActivateMouse() does work in test mode?

Author
Message
3com
10
Years of Service
User Offline
Joined: 18th May 2014
Location: Catalonia
Posted: 6th Jun 2016 06:11
Hi guys
Well, comes the time I need the mouse; I've used below piece of code in "_Init":



Cursor appears at 0,0 of the screen; inmobil/static; do nothing.
It looks like cursor sprite being loaded, at 0,0 because does not set SpritePos, so it use 0,0 as default; but ignoring "ActivateMouse()" command.

Any idea, what I'm doing wrong?
Or it just work in standalone?

Thanks in advance 4 all feedbacks.

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

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

PM
Bored of the Rings
GameGuru Master
19
Years of Service
User Offline
Joined: 25th Feb 2005
Location: Middle Earth
Posted: 6th Jun 2016 06:41
could you elaborate what you are trying to achieve?
Professional Programmer: Languages- SAS (Statistical Analysis Software) , C++, SQL, PL-SQL, JavaScript, HTML, Darkbasic Pro (still love this language), Purebasic, others
Hardware: Dell Precision 490; AMD Radeon HD 7570; LG TFT monitor (widescreen). Wanting a new PC at some point.
Interests: Drumming, Saxophone, Art, Theatre, Music.
Bored of the Rings
GameGuru Master
19
Years of Service
User Offline
Joined: 25th Feb 2005
Location: Middle Earth
Posted: 6th Jun 2016 06:57 Edited at: 6th Jun 2016 07:25
if you were thinking of moving the sprite with the mouse, try this code:



OR THIS:

Professional Programmer: Languages- SAS (Statistical Analysis Software) , C++, SQL, PL-SQL, JavaScript, HTML, Darkbasic Pro (still love this language), Purebasic, others
Hardware: Dell Precision 490; AMD Radeon HD 7570; LG TFT monitor (widescreen). Wanting a new PC at some point.
Interests: Drumming, Saxophone, Art, Theatre, Music.
3com
10
Years of Service
User Offline
Joined: 18th May 2014
Location: Catalonia
Posted: 6th Jun 2016 09:11
@ BOTR
Thanks mate for the tip.

My issue is the mouse cursor do not move from there pos (0,0) as you can see in pic below.



Back to the last example, I've some base sprite, over this sprite, another sprites (fruits) arranged as cols and rows.
Player has to choose the right fruit, but how it does if mouse cursor do not move; how player can point to whatever fruit with the mouse (mouse_over), and how he choose desired fruit (mouse_click), if cursor does not move, is like freeze.

In the pic above, I'm using your second script, if I mouse_click, the Lee sprite goes to a different pos; but that's not the goal,
I need player being able to move mouse cursor araound all the fruits, and choose whatever he want, since I can't know what fruit the player is going to choose, I can't tell " if mouse_click then fruit(?).x = mouse.X".

The meant goal here is getting the mouse cursor moving free araound the fruits, or whatever sprite.

Thanks again for help me.

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

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

PM
smallg
Community Leader
18
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 6th Jun 2016 10:01
You need to reposition the sprite based on the mouse position, activate mouse will not do this for you, it simply stops the mouse from being stuck in the centre of the screen.

Use SetSpritePosition(name,g_MouseX,g_MouseY)
Inside your main(e) to keep it updated.
lua guide for GG
https://steamcommunity.com/sharedfiles/filedetails/?id=398177770
windows 10
i5 @4ghz, 8gb ram, AMD R9 200 series , directx 11
3com
10
Years of Service
User Offline
Joined: 18th May 2014
Location: Catalonia
Posted: 6th Jun 2016 10:56
Ok guys, now I'm a happy boy!!!!!

Thanks a lot for you both.

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

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

PM
Bored of the Rings
GameGuru Master
19
Years of Service
User Offline
Joined: 25th Feb 2005
Location: Middle Earth
Posted: 6th Jun 2016 17:24
yes my 2nd script uses the SetSpritePosition(name,g_MouseX,g_MouseY) but there is no cursor when moving the mouse, not sure if this was intentional or a bug.
Professional Programmer: Languages- SAS (Statistical Analysis Software) , C++, SQL, PL-SQL, JavaScript, HTML, Darkbasic Pro (still love this language), Purebasic, others
Hardware: Dell Precision 490; AMD Radeon HD 7570; LG TFT monitor (widescreen). Wanting a new PC at some point.
Interests: Drumming, Saxophone, Art, Theatre, Music.
3com
10
Years of Service
User Offline
Joined: 18th May 2014
Location: Catalonia
Posted: 6th Jun 2016 19:38
@ BOTR
Do you mean it does not work 4 you?
It so, this the script test I use, and it work ok.



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

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

PM
Bored of the Rings
GameGuru Master
19
Years of Service
User Offline
Joined: 25th Feb 2005
Location: Middle Earth
Posted: 6th Jun 2016 22:05 Edited at: 6th Jun 2016 22:12
@3com-no sorry I meant there is no actual visible mouse arrow cursor from what I could see. My script works fine, is only a test script.
Professional Programmer: Languages- SAS (Statistical Analysis Software) , C++, SQL, PL-SQL, JavaScript, HTML, Darkbasic Pro (still love this language), Purebasic, others
Hardware: Dell Precision 490; AMD Radeon HD 7570; LG TFT monitor (widescreen). Wanting a new PC at some point.
Interests: Drumming, Saxophone, Art, Theatre, Music.
3com
10
Years of Service
User Offline
Joined: 18th May 2014
Location: Catalonia
Posted: 7th Jun 2016 04:18
Now I got the point right, thanks 4 clarify.

I plane to make some cursors, I found that cursor a bit big, I prefer shortest and change the look.

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

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

PM
Bored of the Rings
GameGuru Master
19
Years of Service
User Offline
Joined: 25th Feb 2005
Location: Middle Earth
Posted: 7th Jun 2016 07:55
@3com-same here- will have to create my own cursors, yes small cursors I prefer also
Professional Programmer: Languages- SAS (Statistical Analysis Software) , C++, SQL, PL-SQL, JavaScript, HTML, Darkbasic Pro (still love this language), Purebasic, others
Hardware: Dell Precision 490; AMD Radeon HD 7570; LG TFT monitor (widescreen). Wanting a new PC at some point.
Interests: Drumming, Saxophone, Art, Theatre, Music.
3com
10
Years of Service
User Offline
Joined: 18th May 2014
Location: Catalonia
Posted: 7th Jun 2016 09:52
Hey guys, now raised another question, I'll try to explain right.

It looks like "ActivateMouse()" should be declared in "_init()", and also you are force to declare "SetSpritePosition ( g_sprCursor, g_MouseX, g_MouseY )" at the very start of "main()"; this is right when loadgame/savegame menues, but does not fit my needs, since I'm starting level, close to the trigger item, even if player marker is outside of the scene.

Imagine the scene:

Player is walking around a town, enter in a house, enter in a room, when close to pc display he is prompted to press E to run script> and is now and only now, when the sprite base + sprite fruits + mouse cursor should appears, and mouse being activate. But if I try this, mouse does not work, do nothing.

As example:



The code above work, but if I do...



It does not work, cursor appears a 0,0 and does nothing, mouse non activate, I know this because I can move camera.
And of course the rest of the code does not work, just I've pc display (trigger) and mouse, even I can move it, and so on, but does nothing, since there are not base sprite, fruits sprites, buttons sprites, and so on.

We are force to declare mouse as I said above ?
Or I'm doing something wrong?

Thanks guys 4 all feedbacks

3com



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

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

PM
Bored of the Rings
GameGuru Master
19
Years of Service
User Offline
Joined: 25th Feb 2005
Location: Middle Earth
Posted: 7th Jun 2016 11:06


is this initialised in _INIT and what is it set to?
Professional Programmer: Languages- SAS (Statistical Analysis Software) , C++, SQL, PL-SQL, JavaScript, HTML, Darkbasic Pro (still love this language), Purebasic, others
Hardware: Dell Precision 490; AMD Radeon HD 7570; LG TFT monitor (widescreen). Wanting a new PC at some point.
Interests: Drumming, Saxophone, Art, Theatre, Music.
3com
10
Years of Service
User Offline
Joined: 18th May 2014
Location: Catalonia
Posted: 7th Jun 2016 12:25 Edited at: 7th Jun 2016 12:36
yah! and is declared as "local npressed = 0"
and state to 1:

npressed = 1
end -- g_KeyPressE

and also:

if npressed == 1 and GetInKey() == "" then
npressed = 0
end
end -- main

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

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

PM
3com
10
Years of Service
User Offline
Joined: 18th May 2014
Location: Catalonia
Posted: 7th Jun 2016 13:26
And now the most odd I never found in GG.

Above script attached to a barrel in outdoor scene work fine.
The same script plus scene, just adding some house and placing barrel inside the home, well you can see in the vid below.



Non comments.

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

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

PM
smallg
Community Leader
18
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 7th Jun 2016 15:08
Move the set sprite position out of the e key press otherwise the mouse won't move.
Toggle the pressed variable to not be 0 otherwise the sprite will try to create multiple times and that is very bad (better to check it exists or not first)
lua guide for GG
https://steamcommunity.com/sharedfiles/filedetails/?id=398177770
windows 10
i5 @4ghz, 8gb ram, AMD R9 200 series , directx 11
Belidos
3D Media Maker
9
Years of Service
User Offline
Joined: 23rd Nov 2015
Playing: The Game
Posted: 7th Jun 2016 15:26
Shouldn't that barrel be set as always active id it's holding a background script?

i7, NV960 4GB, 16GB memory, 2x 4TB Hybrid, Win10.
i5 , AMD 6770 1GB, 8GB memory, 512GB Generic SATAIII + 2TB Seagate Baracuda SATAIII, Win7.
i3, Radeon integrated graphics, 4GB memory, 512gB Generic SATAII, Win8.1.
Q6600, Intel integrated graphics, 2GB memory, 180GB Generic SATAII, WinXP.
3com
10
Years of Service
User Offline
Joined: 18th May 2014
Location: Catalonia
Posted: 7th Jun 2016 16:45
Quote: "Move the set sprite position out of the e key press otherwise the mouse won't move."

Ya, this is what I'm pointing above, with the 2º script.

Quote: "Toggle the pressed variable to not be 0 otherwise the sprite will try to create multiple times and that is very bad (better to check it exists or not first)"


Yes, I myself has found with multiple cursor sprites, and yes, this is very bad; I did as you pointed, so I can use E once, in another words, I just can access to the fruits sprites once, and I need to use it multiple times, not just 1 time.

When I do like you say (firts script above) it works fine, but level start closes to the barrel, does not where the player marker is.

I want the player starting where player marker is, and he'll have to discover the item that trigger the script, and is then and only then, when all should start.

And still does not understand why the video bug, because I placed the barrel inside the house; outside it works and inside does not?

Thanks guys for being patient with me.

3com






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

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

PM
DVader
20
Years of Service
User Offline
Joined: 28th Jan 2004
Location:
Posted: 9th Jun 2016 22:59
Lol, nice vid.

You don't have to activate the mouse in init. You only activate the mouse when you need to. Take it out of the init and put it where you actually need the 2D mouse stuff. I've used it in several ideas now, it works fine. If you activate it when running around it will obviously cause issues. If you send me your script I can take a look, should be an easy fix.


SPECS: Q6600 CPU. Nvidia 660GTX. 8 Gig Memory. Win 7.
3com
10
Years of Service
User Offline
Joined: 18th May 2014
Location: Catalonia
Posted: 10th Jun 2016 02:20
@ DVader
With the code below I get the mouse a 0,0 like pic above, and does nothing, inmobil, static.



Thanks 4 help me.

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

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

PM
smallg
Community Leader
18
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 10th Jun 2016 09:50 Edited at: 10th Jun 2016 09:51
As I said before , you just need yo move the position out of the e press.



That should let you click toactivate the mouse and then when you click again it will go back to game, not exactly what you need but good enough to get you started (if it works, written from my phone so no idea)
lua guide for GG
https://steamcommunity.com/sharedfiles/filedetails/?id=398177770
windows 10
i5 @4ghz, 8gb ram, AMD R9 200 series , directx 11
DVader
20
Years of Service
User Offline
Joined: 28th Jan 2004
Location:
Posted: 10th Jun 2016 11:40
Different to how I'd do it, but that's programming for you Seems smallg has beat me to it. Here's my take, again not tested, so may not be 100%.

Hard to be sure exactly what you want, but that should show and hide a mouse cursor when you press e theoretically. You may want to freeze the player as well. I also make the sprite in the init as otherwise you will be making loads of em. if you really want to make it in the main loop, be sure to delete it as well.


SPECS: Q6600 CPU. Nvidia 660GTX. 8 Gig Memory. Win 7.
smallg
Community Leader
18
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 10th Jun 2016 15:11
Well typing on a phone is hard work for writing a script from scratch... Too many spelling mistakes so I just used his

Curious if <> even works in lua, pretty sure it didn't when I tried it and I have to use ~= to mean not equals.
Also in that statement it should be equal to 0 right? As you're checking for no key presses. (Line22)
lua guide for GG
https://steamcommunity.com/sharedfiles/filedetails/?id=398177770
windows 10
i5 @4ghz, 8gb ram, AMD R9 200 series , directx 11
3com
10
Years of Service
User Offline
Joined: 18th May 2014
Location: Catalonia
Posted: 10th Jun 2016 16:17
Both works fine separatelly, with a few changes (IE: both forget to load img in Init (error 501), anyway not problem.

Now I should get integrate it into my code, right now when press E the screen is full of fruits, not the goal, so I want to restric E use once, just for open the sprite base with the fruits over, arranged in cols and rows, so appears the mouse cursor full working, so player can navigte over the fruits, and make their selection.
I'm using Z to close panel (delete all the sprites, even mouse cursor)
And being create all them again, each time the player is closes to the trigger (barrel in my example), and press E.

Quote: "Hard to be sure exactly what you want"

You'r right, but this belong to a mesh intended to go to the store, this prevent me to post the complete code, anyway I'll post about when done (if I get it).

Just can say than my project is much more ambitious than a simple panel fruit, and it has to do with something we are all waiting, and although some of you may imagine, aims to go much further, if possible.

I've many work done, just has to get it working with mouse, instead of keys, it is most comfortable for the final users.

Thanks all you guys, I plane to cry S.O.S, when needed.

Quote: "Curious if <> even works in lua, pretty sure it didn't when I tried it and I have to use ~= to mean not equals."


I thought the same thing when I saw it, but I change it, instead of try it (excuse me, Dvader)

3com


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

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

PM
DVader
20
Years of Service
User Offline
Joined: 28th Jan 2004
Location:
Posted: 10th Jun 2016 16:25
Quote: "Curious if <> even works in lua, pretty sure it didn't when I tried it and I have to use ~= to mean not equals.
Also in that statement it should be equal to 0 right? As you're checking for no key presses. (Line22)"


Yeah your right, pretty sure <> doesn't work, just typed it up quick in notepad, lol, and yes == would be what I should have put in the last part I'm pretty old school, so have always used <> in other languages, hard to kick the habit I'm pretty sure he should be able to suss it from these examples though.


SPECS: Q6600 CPU. Nvidia 660GTX. 8 Gig Memory. Win 7.
3com
10
Years of Service
User Offline
Joined: 18th May 2014
Location: Catalonia
Posted: 10th Jun 2016 16:43
Quote: " I'm pretty old school"

Me too, so no problem 4 understand the old habits, I also have to.

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

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

PM
Bored of the Rings
GameGuru Master
19
Years of Service
User Offline
Joined: 25th Feb 2005
Location: Middle Earth
Posted: 10th Jun 2016 17:29 Edited at: 10th Jun 2016 17:30
from the LUA.org site:

3.2 – Relational Operators
Lua provides the following relational operators:

< > <= >= == ~=

All these operators always result in true or false. You can only use ~= for not equal to. Some languages use != or <> or ne
Professional Programmer: Languages- SAS (Statistical Analysis Software) , C++, SQL, PL-SQL, JavaScript, HTML, Darkbasic Pro (still love this language), Purebasic, others
Hardware: Dell Precision 490; AMD Radeon HD 7570; LG TFT monitor (widescreen). Wanting a new PC at some point.
Interests: Drumming, Saxophone, Art, Theatre, Music.
3com
10
Years of Service
User Offline
Joined: 18th May 2014
Location: Catalonia
Posted: 12th Jun 2016 16:23
Hey guys, finally I've got mouse working with my code!!!!

Now I will change some code, focused on the mouse. instead of the keyboard.

Likely more questions coming soon.

Thanks again folks for all the tips.

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

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

PM

Login to post a reply

Server time is: 2024-11-25 01:31:24
Your offset time is: 2024-11-25 01:31:24