Scripts / [SOLVED] GGMax does gives you the mouse control?

Author
Message
3com
9
Years of Service
User Offline
Joined: 18th May 2014
Location: Catalonia
Posted: 16th Oct 2020 19:39
Hi guys
I've tried a GG map in GGMax but it doesn't work as it does in GG.
The map is about a blackjack game (testing sprites in GGMax beta3), I've found a legacy vid I've posted times ago, it shows all working fine in GG.



However, GGMax doesn't give me the mouse control, it looks like ActivateMouse() doesn't work.
If not a matter of the script, due it works fine in GG.
I've checked all the images, even the mouse pointer image, and all of them are in the right place.

Has anyone experienced a similar problem with GMax?
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
cpu mark: 10396.6
2d graphics mark: 947.9
3d graphics mark: 8310.9
memory mark 2584.8
Disk mark: 1146.3
Passmark rating: 3662.4

The author of this post has marked a post as an answer.

Go to answer
PM
GubbyBlips
5
Years of Service
User Offline
Joined: 14th Jan 2019
Location:
Posted: 16th Oct 2020 21:02
?! I hope so 3com. I have the idea to mix a little sci fi with some
good old medieval locations, like you show.
Would hope when MAX comes out, it will be able to take the sprites?!
PM
3com
9
Years of Service
User Offline
Joined: 18th May 2014
Location: Catalonia
Posted: 16th Oct 2020 21:24
This post has been marked by the post author as the answer.
Oh, sorry guys I've fixed it, that was my fault.

I will post the vid in my GGMax thread when done, I'm testing other animated sprites.

Quote: "Would hope when MAX comes out, it will be able to take the sprites?!"

I hope so too, anyway, we need more control over sprites in GGMax, even in GG.
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
cpu mark: 10396.6
2d graphics mark: 947.9
3d graphics mark: 8310.9
memory mark 2584.8
Disk mark: 1146.3
Passmark rating: 3662.4

PM
AmenMoses
GameGuru Master
8
Years of Service
User Offline
Joined: 20th Feb 2016
Location: Portsmouth, England
Posted: 16th Oct 2020 21:33
What control is missing?
Been there, done that, got all the T-Shirts!
PM
3com
9
Years of Service
User Offline
Joined: 18th May 2014
Location: Catalonia
Posted: 16th Oct 2020 22:34
First I was traying with titlesbank cursor image as GG does, but this image does not work in GGMax, dunno why? after that I've tried with a custom one, but I have missed to include scriptbank in the cursor image path file. (scriptbank \\images\\myfolder\\mycursor.png)

Quote: "What control is missing?"

Sprite marker?
It might help a lot as image marker does. imho.
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
cpu mark: 10396.6
2d graphics mark: 947.9
3d graphics mark: 8310.9
memory mark 2584.8
Disk mark: 1146.3
Passmark rating: 3662.4

PM
AmenMoses
GameGuru Master
8
Years of Service
User Offline
Joined: 20th Feb 2016
Location: Portsmouth, England
Posted: 16th Oct 2020 23:30
If you are referring to imageinzone.lua that uses sprites.
Been there, done that, got all the T-Shirts!
PM
3com
9
Years of Service
User Offline
Joined: 18th May 2014
Location: Catalonia
Posted: 16th Oct 2020 23:51 Edited at: 17th Oct 2020 00:49
I've taken a look at this script and yes, it does.
So, I'm going to try to place sprites within an image zone.
Wonder if it is going to make my life easier when positioning sprites on the screen coming from.

Edit: I have a Deja Vu, I recall days ago dealing with something like that while trying to help someone, on the thread comes the fact then there are 2 different imageinzone.lua scripts, ones are as you pointed above and it sits on the scriptbank folder, and the other ones sit on marker folder, and it is using by GGMax, with image zone marker.
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
cpu mark: 10396.6
2d graphics mark: 947.9
3d graphics mark: 8310.9
memory mark 2584.8
Disk mark: 1146.3
Passmark rating: 3662.4

PM
3com
9
Years of Service
User Offline
Joined: 18th May 2014
Location: Catalonia
Posted: 17th Oct 2020 01:17
I think the "Image Zone" marker is made to work with the "marker / imageinzone.lua" script
The script "imageinzone.lua" seems to get its values directly from the object's properties, this sounds a bit hardcoded to me.
Therefore it is necessary to choose an image in the panel "entity tool", this will be the image that you will see when the player enters the entity's range of action.

It definitely doesn't seem like the best way to deal with sprites to me.
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
cpu mark: 10396.6
2d graphics mark: 947.9
3d graphics mark: 8310.9
memory mark 2584.8
Disk mark: 1146.3
Passmark rating: 3662.4

PM
AmenMoses
GameGuru Master
8
Years of Service
User Offline
Joined: 20th Feb 2016
Location: Portsmouth, England
Posted: 17th Oct 2020 13:18 Edited at: 17th Oct 2020 13:45
Here is a fun script that should demonstrate almost everything you need to know about sprites

As a bit of fun see if you can predict what you should see on screen before you test it!

Added a second one with even more sprites and more variation.
Been there, done that, got all the T-Shirts!

Attachments

Login to view attachments
PM
3com
9
Years of Service
User Offline
Joined: 18th May 2014
Location: Catalonia
Posted: 17th Oct 2020 18:26
@ AmenMoses
Ty Amen, cool scripts, I went straight for the second script
It helps me a lot to takes different looks at sprites. I've tried to predict and I think about the snow because of the image you choose and how you play with alpha in your script, I wrong, but this gives me the idea.

As a side note GGMax looks like working best with PasteSpritePosition rather than SetSpritePosition.

I've made some changes to suit my needs. I'll post a vid in my Enjoying with GGMax thread. Do not want to duplicate video in several threads.
I've made snow with your script, I'm going to share it on my Enjoying with GGMax thread.
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
cpu mark: 10396.6
2d graphics mark: 947.9
3d graphics mark: 8310.9
memory mark 2584.8
Disk mark: 1146.3
Passmark rating: 3662.4

PM
smallg
Community Leader
18
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 17th Oct 2020 21:03
Quote: "As a side note GGMax looks like working best with PasteSpritePosition rather than SetSpritePosition."

yh and max has a refresh bug so any text or sprites get stuck on screen so you need to call some form of text at all times to keep the screen updated - even calling Text(30000,30000,3," ") is enough till it gets fixed
lua guide for GG
https://steamcommunity.com/sharedfiles/filedetails/?id=398177770
windows 10
i5 @4ghz, 8gb ram, AMD R9 200 series , directx 11
AmenMoses
GameGuru Master
8
Years of Service
User Offline
Joined: 20th Feb 2016
Location: Portsmouth, England
Posted: 17th Oct 2020 21:19
PasteSpritePosition has a bug, unless they have fixed it already but if so they haven't indicated that on GitHub.

Also with PasteSprite you have to call it every frame, SetSprite only needs to be called when you are moving the sprite.

Been there, done that, got all the T-Shirts!
PM
3com
9
Years of Service
User Offline
Joined: 18th May 2014
Location: Catalonia
Posted: 17th Oct 2020 21:52
Quote: "yh and max has a refresh bug so any text or sprites get stuck on screen so you need to call some form of text at all times to keep the screen updated - even calling Text(30000,30000,3," ") is enough till it gets fixed"

Good to know. I've struggled to try to fix it via LUA with not to avail, now I know why. Ty for the tip.
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
cpu mark: 10396.6
2d graphics mark: 947.9
3d graphics mark: 8310.9
memory mark 2584.8
Disk mark: 1146.3
Passmark rating: 3662.4

PM
smallg
Community Leader
18
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 17th Oct 2020 22:44
Quote: "PasteSpritePosition has a bug, unless they have fixed it already but if so they haven't indicated that on GitHub."

what's the bug with PasteSpritePosition? it seems like it works fine in Max at least (haven't used classic in a long time now).
lua guide for GG
https://steamcommunity.com/sharedfiles/filedetails/?id=398177770
windows 10
i5 @4ghz, 8gb ram, AMD R9 200 series , directx 11
AmenMoses
GameGuru Master
8
Years of Service
User Offline
Joined: 20th Feb 2016
Location: Portsmouth, England
Posted: 18th Oct 2020 00:28
Internally it converts to integer so the sprite placement is not very accurate. SetPosition correctly takes in floating point values.

Although it is entirely possible they have fixed that in MAX but not got around to pushing out a GG build with it in.

When you have a screen width of 2560 pixels having a sprite positioned to the nearest 25 ish pixels is not exactly conducive to a good looking hud!
Been there, done that, got all the T-Shirts!
PM
smallg
Community Leader
18
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 19th Oct 2020 12:16
Quote: "Internally it converts to integer so the sprite placement is not very accurate. SetPosition correctly takes in floating point values."

ah thanks, not sure i would notice it but good to keep in mind
Quote: "Good to know. I've struggled to try to fix it via LUA with not to avail, now I know why. Ty for the tip"

i got so confused when DeleteImage() was hard crashing Max until i realised it was because it was not refreshing the screen - so even though i wasn't calling PasteSprite() anymore Max was still doing it in the background and crashing as the sprite didn't have an image anymore
note that the space is important if you call empty Text - i.e. Text(50,50,3,"") doesn't help but Text(50,50,3," ") does
i know technically this is only because of a bug but it would be great if Lee would take some time to fix those hard crashes - perhaps just load a blank image if no image is found etc.. it's how AGK handles it and just makes it way more user friendly than crashing to desktop

lua guide for GG
https://steamcommunity.com/sharedfiles/filedetails/?id=398177770
windows 10
i5 @4ghz, 8gb ram, AMD R9 200 series , directx 11
3com
9
Years of Service
User Offline
Joined: 18th May 2014
Location: Catalonia
Posted: 19th Oct 2020 16:57 Edited at: 19th Oct 2020 18:58
Quote: "perhaps just load a blank image if no image is found etc.. it's how AGK handles it and just makes it way more user friendly than crashing to desktop"

I even say the same, even with the wrong shader in GG, when the shader doesn't being 5.0 or higher.
Texture missing. even item missing, in all those cases why not load a default file instead of hard crashing.

If not shader then loadshader(default-fx) end
If texture missingt then
loadTexture(default_texture-png)
PromptUserAbout("Missing texture......")
end

Now I have GGMax crashing because "#define RUNTIMEERROR_SOUNDNOTEXIST 3004" error, but I surely have the sound file in front of me, in the right path I've declared on the script.
Basically:



Getting "Runtime error 3004" when running script.

Wav file is mono, 44100, 16bits.
I've taken a look and they are running wav files in 16bits in cellar demo, so that's not the issue, the only reason I guess is the runtime 7002 I can't rid of it every time I open GGMax, anyway, GGMax continues to work despite the bug, although I'm not sure to what extent it is affected by the bug.

#define RUNTIMEERROR_B3DMESHLOADFAILED 7002

Maybe next weekend I'll begin to search for the guilty mesh, (if any, because I've got this error suddenly)

Edit: Missing script block.

Edit2: Reported in GGMax beta3 bug reports thread.
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
cpu mark: 10396.6
2d graphics mark: 947.9
3d graphics mark: 8310.9
memory mark 2584.8
Disk mark: 1146.3
Passmark rating: 3662.4

PM
smallg
Community Leader
18
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 20th Oct 2020 16:03
Quote: "What control is missing?"

i know we can store these ourselves but
GetSpriteWidth()
GetSpriteHeight() - (especially needed when using -1 to keep aspect)
GetSpriteImage()
would be very useful to make things easier
lua guide for GG
https://steamcommunity.com/sharedfiles/filedetails/?id=398177770
windows 10
i5 @4ghz, 8gb ram, AMD R9 200 series , directx 11
AmenMoses
GameGuru Master
8
Years of Service
User Offline
Joined: 20th Feb 2016
Location: Portsmouth, England
Posted: 20th Oct 2020 17:46
Those aren't really 'control' more 'information'.

Lee never seems overly eager to provide information functions in Lua, I had to fight hard to get some of the ones we now have.

There are still a bunch of things that have "Set" functions but no "Get" equivalent.
Been there, done that, got all the T-Shirts!
PM
smallg
Community Leader
18
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 20th Oct 2020 18:53
yh it's not a problem, we can store most of it ourselves easily enough and i think Lee doesn't really need all the information commands in lua as he will have access to the behind the scenes stuff so it's easy to forget or bypass the user friendly stuff which has little impact on his work
lua guide for GG
https://steamcommunity.com/sharedfiles/filedetails/?id=398177770
windows 10
i5 @4ghz, 8gb ram, AMD R9 200 series , directx 11
3com
9
Years of Service
User Offline
Joined: 18th May 2014
Location: Catalonia
Posted: 20th Oct 2020 19:34
Quote: "There are still a bunch of things that have "Set" functions but no "Get" equivalent. "

That's true.
We wait for everything to calm down, and we will begin to demand new toys (LUA commands) to play with.
There are many settings in entity panel, even in Visual panel that needs to be "LUAded" I just made up a new word, didn't I? LOL
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
cpu mark: 10396.6
2d graphics mark: 947.9
3d graphics mark: 8310.9
memory mark 2584.8
Disk mark: 1146.3
Passmark rating: 3662.4

PM
smallg
Community Leader
18
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 21st Oct 2020 19:09
@3com does SetSpriteAngle(id,#) work in Max for you? for me it's making the sprites disappear
lua guide for GG
https://steamcommunity.com/sharedfiles/filedetails/?id=398177770
windows 10
i5 @4ghz, 8gb ram, AMD R9 200 series , directx 11
3com
9
Years of Service
User Offline
Joined: 18th May 2014
Location: Catalonia
Posted: 21st Oct 2020 20:05
Quote: "does SetSpriteAngle(id,#) work in Max for you? "

Yes, it does, in fact, I'm using it in the Amenmoses's sptritefun script, there I'm using random angles to move the snow.
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
cpu mark: 10396.6
2d graphics mark: 947.9
3d graphics mark: 8310.9
memory mark 2584.8
Disk mark: 1146.3
Passmark rating: 3662.4

PM
smallg
Community Leader
18
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 21st Oct 2020 21:01
weird, definitely not working right for me
using spritefun.lua and if i add SetSpriteAngle() it doesn't work as expected... i think the offset is broken with the rotation?

lua guide for GG
https://steamcommunity.com/sharedfiles/filedetails/?id=398177770
windows 10
i5 @4ghz, 8gb ram, AMD R9 200 series , directx 11
3com
9
Years of Service
User Offline
Joined: 18th May 2014
Location: Catalonia
Posted: 21st Oct 2020 21:52
Try my mod if you want to.

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
cpu mark: 10396.6
2d graphics mark: 947.9
3d graphics mark: 8310.9
memory mark 2584.8
Disk mark: 1146.3
Passmark rating: 3662.4

PM
AmenMoses
GameGuru Master
8
Years of Service
User Offline
Joined: 20th Feb 2016
Location: Portsmouth, England
Posted: 21st Oct 2020 22:04
Omg, people butchering my pretty scripts right in front of my eyes, the pain, the pain.

Oooh, lager.
Been there, done that, got all the T-Shirts!
PM
3com
9
Years of Service
User Offline
Joined: 18th May 2014
Location: Catalonia
Posted: 21st Oct 2020 22:13
Quote: "Omg, people butchering my pretty scripts right in front of my eyes, the pain, the pain."

Oh! smallg what are you doing? LOL
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
cpu mark: 10396.6
2d graphics mark: 947.9
3d graphics mark: 8310.9
memory mark 2584.8
Disk mark: 1146.3
Passmark rating: 3662.4

PM
GubbyBlips
5
Years of Service
User Offline
Joined: 14th Jan 2019
Location:
Posted: 22nd Oct 2020 00:00
So what does your FPS rate get to with 5000 sprites?
I did something similar with text to see how slow it
would get, and with around 1000 text characters,
it already drops to something like 7 fps on my weird
lil computer. //GG jr//
PM
AmenMoses
GameGuru Master
8
Years of Service
User Offline
Joined: 20th Feb 2016
Location: Portsmouth, England
Posted: 22nd Oct 2020 16:17 Edited at: 22nd Oct 2020 16:18
Depends on what you are doing with the sprites. If as in my fun little script you are moving all of them every frame then that will be quite an overhead but if you had 5000 static sprites then there would be no noticeable overhead.

With the fun script altered a little to only update positions at 50 times a second and VSync off I got 281 FPS with 3000 sprites.

Edited to add that's on GG not MAX.
Been there, done that, got all the T-Shirts!
PM
smallg
Community Leader
18
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 22nd Oct 2020 16:52 Edited at: 22nd Oct 2020 16:56
Quote: "So what does your FPS rate get to with 5000 sprites?"

but why would you need 5000 sprites? at that point you are probably better using particles anyway or optimising your script to reuse existing sprites etc - if it's purely for stress testing then nearly all game engines struggle to display thousands of sprites unless you are using tricks (batch rendering etc)

Quote: "Try my mod if you want to. "

yep, same result.. only the ones with 0 angle are shown on screen... if it's only me getting the weirdness then i assume there's something wrong with my installation, i'll try reinstall beta 3 (didn't help) and if that doesn't work i guess i'll just have to wait for the next beta to see if that fixes it
edit, actually your script is not rotating any of the sprites as you don't have a value for spr_angle set in the UpdateSprites() function... if i add a value to it then no sprites are shown
lua guide for GG
https://steamcommunity.com/sharedfiles/filedetails/?id=398177770
windows 10
i5 @4ghz, 8gb ram, AMD R9 200 series , directx 11
3com
9
Years of Service
User Offline
Joined: 18th May 2014
Location: Catalonia
Posted: 22nd Oct 2020 18:11
Quote: "actually your script is not rotating any of the sprites as you don't have a value for spr_angle set in the UpdateSprites() function"

I can see SetSpriteAngle ( v.spr , spr_angle ) within UpdateSprites() function, in my mod above.
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
cpu mark: 10396.6
2d graphics mark: 947.9
3d graphics mark: 8310.9
memory mark 2584.8
Disk mark: 1146.3
Passmark rating: 3662.4

PM
smallg
Community Leader
18
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 22nd Oct 2020 18:23
yes but there is no value for spr_angle in updateSprites(), it's local to randomSprite()
lua guide for GG
https://steamcommunity.com/sharedfiles/filedetails/?id=398177770
windows 10
i5 @4ghz, 8gb ram, AMD R9 200 series , directx 11
3com
9
Years of Service
User Offline
Joined: 18th May 2014
Location: Catalonia
Posted: 22nd Oct 2020 18:34
Quote: "yes but there is no value for spr_angle in updateSprites(), it's local to randomSprite()"

Oh! you are right about, I'm going to fix it to testing the rotating sprite function, asap.
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
cpu mark: 10396.6
2d graphics mark: 947.9
3d graphics mark: 8310.9
memory mark 2584.8
Disk mark: 1146.3
Passmark rating: 3662.4

PM
3com
9
Years of Service
User Offline
Joined: 18th May 2014
Location: Catalonia
Posted: 22nd Oct 2020 19:27
@ smallg
Try this one below.

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
cpu mark: 10396.6
2d graphics mark: 947.9
3d graphics mark: 8310.9
memory mark 2584.8
Disk mark: 1146.3
Passmark rating: 3662.4

PM
GubbyBlips
5
Years of Service
User Offline
Joined: 14th Jan 2019
Location:
Posted: 22nd Oct 2020 19:42
"but why would you need 5000 sprites?"
Well, it's not a need, but just an educational stress test as you noted.
Just curious- aka - science!

Actually I could see some games using up to dozens of hundreds
of sprites under certain design conditions-- NOT a standard look
in stock GG nature!

"if you had 5000 static sprites then there would be no noticeable overhead."
Strange, because you would still have to draw all 5000 sprites to the
screen each frame- right? (probably reveals my giant ignorance...)
PM
AmenMoses
GameGuru Master
8
Years of Service
User Offline
Joined: 20th Feb 2016
Location: Portsmouth, England
Posted: 22nd Oct 2020 21:35
Ok I'll try to explain, the sprites are individually created from images (or in the case of my fun script a single image) and the drawing of them to the screen effectively happens last, i.e. the whole scene is rendered via multiple draw calls and shader effects etc then the sprites are applied on top of this.
From the point of view of the rendering pipeline this equates to a single draw call for all the sprites at once, if the sprites are static it is simply a case of applying the same draw call as last frame so the overhead is minimal, if otoh you are moving them around or changing the colour, alpha or rotating then you have the CPU overhead of all that to contend with.
The trick to reducing that CPU overhead (which is crippling to users with rather pathetic CPUs) is to make sure that this effort is only executed when absolutely necessary. You can probably get away with only moving sprites at a rate equivalent to 25 FPS and it will still look smooth enough for most users. (there are a few weirdos out there that believe they can see at a higher rate than that but they are either biological freaks or liars)
Been there, done that, got all the T-Shirts!
PM
GubbyBlips
5
Years of Service
User Offline
Joined: 14th Jan 2019
Location:
Posted: 24th Oct 2020 01:33
If these function aren't what you use to find the sprite size,
then what are they used for?!

myWidth = GetImageWidth ( 1 ) -- get percentage width of image
myHeight = GetImageHeight ( 1 ) -- get percentage height of image

wouldn't you want to use 100 for the percentage comparison?
///...
so tested them
got 0.074 'width' and 0.119 on 'height' for a 64x64 sprite-- have no idea
what these numbers mean. Placing 1 or 100 in the brackets did not
change the output. ?? Nor did changing sprite size.
PM
smallg
Community Leader
18
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 24th Oct 2020 09:47
pretty sure they are from the original image system - i.e. LoadImages() not LoadImage() which doesn't work with the sprite system.
you would but the ID of the image in the brackets
lua guide for GG
https://steamcommunity.com/sharedfiles/filedetails/?id=398177770
windows 10
i5 @4ghz, 8gb ram, AMD R9 200 series , directx 11
3com
9
Years of Service
User Offline
Joined: 18th May 2014
Location: Catalonia
Posted: 24th Oct 2020 11:27
imageinzone.lua codeblock



This comes in handy when you want to place sprites within one other sprite, For example, a chessboard and the pieces.


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
cpu mark: 10396.6
2d graphics mark: 947.9
3d graphics mark: 8310.9
memory mark 2584.8
Disk mark: 1146.3
Passmark rating: 3662.4

PM
GubbyBlips
5
Years of Service
User Offline
Joined: 14th Jan 2019
Location:
Posted: 24th Oct 2020 17:33
Thanks smallg, 3com. Should be presented more clearly in global...

myWidth = GetImageWidth ( my_sprite ) -- get percentage width of image
PM
AmenMoses
GameGuru Master
8
Years of Service
User Offline
Joined: 20th Feb 2016
Location: Portsmouth, England
Posted: 24th Oct 2020 19:43
GetImageWidth ( ImageId ) gives you the actual width in pixels of the specified Image and doesn't work with sprites.

If you just so happened to have the SpriteId value the same as the ImageId that the sprite came from then it would appear to work except if you changed the size of the sprite and called it again you would find the value returned wouldn't change.


Been there, done that, got all the T-Shirts!
PM
GubbyBlips
5
Years of Service
User Offline
Joined: 14th Jan 2019
Location:
Posted: 25th Oct 2020 03:34
So that's where I'm confused-- on this function, there's only one reference
to an image I see;
SetImagePosition(x,y) ---- but no specify ID?
Question?: LoadImages(str,v) = filepath, ID?

And are these calling for that id reference?
function ShowImage(i)
function HideImage(i)
function SetImageAlignment(i)
PM
3com
9
Years of Service
User Offline
Joined: 18th May 2014
Location: Catalonia
Posted: 25th Oct 2020 03:55
Not sure, but I'm guessing GG loading some sort of plane mesh, and then its background is the image you are using for since the plane (the image container) always is the same, does not need any ID, is this case, just need the position coordinates (x,y), because of a 2d mesh.

LoadImages(str,v)
str = your image folder path
V = 0 - means you are loading all the images within your folder. So if you have 5 images there, then they all will be loaded and indexed from 1 thru 5 (in this case). Usually, these images are labeled from 000 to 005 (in this case, again), being 000 the first one, but indexed as 1.

ShowImage(i)
Using the example above this would be: ShowImage(1) is going to show the first image within your folder.
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
cpu mark: 10396.6
2d graphics mark: 947.9
3d graphics mark: 8310.9
memory mark 2584.8
Disk mark: 1146.3
Passmark rating: 3662.4

PM
AmenMoses
GameGuru Master
8
Years of Service
User Offline
Joined: 20th Feb 2016
Location: Portsmouth, England
Posted: 25th Oct 2020 10:53
When it comes to image commands the only one I've ever needed to use is LoadImage.

And the global.lua description is a) correct and b) all you really need to know, i.e:

myImage = LoadImage ( "myFolder\\myImage.png" )

In simple situations where all you need is a single sprite to display, for example the radar background image , you don't even need nor care about the image:

local mySprite = CreateSprite( LoadImage ( "myFolder\\myImage.png" ) )

Then you simply use sprite commands exclusively to manipulate it. You only really need an imageId when you are creating multiple sprites from a single image.

As far as I am concerned you could toss all the other image commands in the bin without any loss of functionality.
Been there, done that, got all the T-Shirts!
PM
smallg
Community Leader
18
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 25th Oct 2020 12:10
Quote: "As far as I am concerned you could toss all the other image commands in the bin without any loss of functionality. "

they really should, just causes too much unnecessary confusion having 2 systems and the original system (i.e. LoadImages()) is outdated
Quote: "You only really need an imageId when you are creating multiple sprites from a single image."

or when you want to delete the image with DeleteImage(id)
lua guide for GG
https://steamcommunity.com/sharedfiles/filedetails/?id=398177770
windows 10
i5 @4ghz, 8gb ram, AMD R9 200 series , directx 11
AmenMoses
GameGuru Master
8
Years of Service
User Offline
Joined: 20th Feb 2016
Location: Portsmouth, England
Posted: 25th Oct 2020 14:00
Deleting the image is very dangerous unless you ensure that any sprites you created that reference it have been deleted first.

I'm not sure if image storage is freed up properly between levels though, it should be!
Been there, done that, got all the T-Shirts!
PM

Login to post a reply

Server time is: 2024-04-19 05:45:40
Your offset time is: 2024-04-19 05:45:40