Scripts / [SOLVED] Help with script

Author
Message
Tresgamer
3
Years of Service
User Offline
Joined: 30th Apr 2021
Location:
Posted: 1st May 2021 08:20
Need some help trying to run this and i am getting "Runtime Error: 501 :Image Number 96000 ()

Commenting out the mySprite variable and the relevant call inside the function allows the game to run/start.
Not sure where i am going wrong.



Thanks in advance.

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

Go to answer
PM
smallg
Community Leader
19
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 1st May 2021 09:54 Edited at: 1st May 2021 12:08
This post has been marked by the post author as the answer.
the default start location is "Files" in the GG structure so assuming your image is in the default place ("Files/scriptbank/images")
your LoadImage path should be
myImage = LoadImage("scriptbank\\images\\myFolder\\test.png")
edit: myImage, not mySprite

also myWidth and myHeight should not be (1) but (myImage)
lua guide for GG
https://steamcommunity.com/sharedfiles/filedetails/?id=398177770
windows 10
i5 @4ghz, 8gb ram, AMD R9 200 series , directx 11
Tresgamer
3
Years of Service
User Offline
Joined: 30th Apr 2021
Location:
Posted: 1st May 2021 10:01
"myWidth and myHeight should not be (1) but (myImage)"

Hmmm tried this as you suggested still not working. Directory structure is setup correctly.
PM
Tresgamer
3
Years of Service
User Offline
Joined: 30th Apr 2021
Location:
Posted: 1st May 2021 10:11 Edited at: 1st May 2021 11:34
Also i should mention i am trying to load this script on an entity within the game. This could possibly be the problem?????? Forgive me i am new to the engine like two days old new and still trying to work out its structure and how it all works.

And while i am here is there a better way to do what i am trying to achieve? Like say load the script at "level start"? Would a way point/marker be better?
PM
Tresgamer
3
Years of Service
User Offline
Joined: 30th Apr 2021
Location:
Posted: 1st May 2021 10:11 Edited at: 1st May 2021 11:38
zzzzzzzzzzz After hours of chasing my tail around finally found out the problem. After reading through some of your posts on discord smallg.

Needed to adjoin "scriptbank\\images\\" to the front of ( "myFolder\\test.png" )
Plus the fix you mentioned earlier.

Edit: And lol just realized you mentioned all of this in your initial post. One of those moments where one can miss something right in front of them then only realize hours later. My bad


Thanks
PM
smallg
Community Leader
19
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 1st May 2021 12:07
Quote: "Also i should mention i am trying to load this script on an entity within the game. This could possibly be the problem?????? Forgive me i am new to the engine like two days old new and still trying to work out its structure and how it all works.

And while i am here is there a better way to do what i am trying to achieve? Like say load the script at "level start"? Would a way point/marker be better?"

welcome to GG
no, GG is object orientated programming so attaching scripts to objects is the normal way to do things - so you normally end up with scripts attached to each object (or entity as GG calls them) that control the same object(s).
even if it's not required that the script do anything to the object at all (as in this case) the script still needs to be told to run so attaching it to an object is the recommended way to do so.
lua guide for GG
https://steamcommunity.com/sharedfiles/filedetails/?id=398177770
windows 10
i5 @4ghz, 8gb ram, AMD R9 200 series , directx 11
Tresgamer
3
Years of Service
User Offline
Joined: 30th Apr 2021
Location:
Posted: 1st May 2021 12:32
Cool Thanks. Loving this engine so far and have already bought the max preorder. Once i improve my Lua comprehension a bit more and learn the structure of game guru itself i can tell this engine can get a lot done within its scope.
PM
Tresgamer
3
Years of Service
User Offline
Joined: 30th Apr 2021
Location:
Posted: 1st May 2021 14:10 Edited at: 1st May 2021 14:11
Instead of starting a new thread will post here instead. How would i go about making a new line within a string?

What i am trying to do is.

Or is this not possible?
PM
smallg
Community Leader
19
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 1st May 2021 16:51
\n should work in lua but from my tests with it before it doesn't appear to work in GG.
you can just place the Text manually though
i.e.
Text(0,5,2,"Key1:F11")
Text(0,7,2,"Key2:Settings")
lua guide for GG
https://steamcommunity.com/sharedfiles/filedetails/?id=398177770
windows 10
i5 @4ghz, 8gb ram, AMD R9 200 series , directx 11
Tresgamer
3
Years of Service
User Offline
Joined: 30th Apr 2021
Location:
Posted: 1st May 2021 19:51
Yeah thought that was going to be the solution. Guess it will work for now until i find a better way to achieve what i am trying to do if at all applicable.

Plus my lua is pretty rusty i have only learnt the basics of it from using a mod for Minecraft called computercraft which was a good few years ago now since i played that. So i still have some learning to do. Although i am making good strides with it atm, and it is pretty easy to understand the basics of it.

I been reading over your scripts thread and learning some of the stuff that can be done within the scripts so its helping a lot
PM
GubbyBlips
5
Years of Service
User Offline
Joined: 14th Jan 2019
Location:
Posted: 1st May 2021 23:55
Thanks for this, was good timing as I needed to insert a sprite today, since it's been about 5 months since I tested out sprites -- and that then was just a quicky test also.

So in following this sprites discussion, seems to be is a bit of an issue with PasteSpritePosition()
But SetSpritePosition() seems to be working okay.
PM
smallg
Community Leader
19
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 2nd May 2021 10:24
what's wrong with PasteSpritePosition()? works fine for me
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: 2nd May 2021 15:01
Unless it has been fixed recently PasteSpritePosition uses integer values so you can only get close to where you want it most of the time.

Apart from that they are actually very different.

SetSpritePosition honours the depth value of the sprite and only needs to be called once to position a sprite, PasteSprite otoh doesn't honour the depth and must be called every frame, the trick to overlapping sprites with the paste commands is to paste them in order of depth, so for best results make sure all pasting is done in a single script.
The other difference is that with SetSpritePosition the sprites are all on top of text whereas with paste the sprites are beneath the text.

Been there, done that, got all the T-Shirts!
PM
GubbyBlips
5
Years of Service
User Offline
Joined: 14th Jan 2019
Location:
Posted: 2nd May 2021 17:51
PasteSprite was giving me a strange glitch;
I've changed the script now, but I was getting the same sprite in two different locations,
with just one single call for Pastsprite (in init) then positionsprite. ?? something like that...?

0,0 and 50,50 when I wished for it to be centered-- and PasteSprite didn't provide any movement
as I was using keys to see where it would move. Probably what AmenMoses described was the
reason for the confusion, and I'll have to clarify those differences and keep that in consideration.
PM
smallg
Community Leader
19
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 2nd May 2021 18:00
well PasteSprite does create a clone of the original
i.e. you can have many PasteSprite() calls for the same sprite at once
so if you didn't move the original off screen with SetSpritePosition it will also show on screen
or if you use PasteSprite and PasteSpritePosition it will create 2 copies as PasteSpritePosition creates a clone and positions the sprite at the location given while PasteSprite just creates a clone at the original's location (the original you can then move later with SetSpritePosition)
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: 2nd May 2021 21:02
It's actually two different systems in the code.

SetSpritePosition places the sprite into a list which is displayed every frame from then on (unless off screen of course). All sprites in the list are displayed at the same time and it is done *after* the text rendering which is why you can't have text on top of positioned sprites.

PasteSprite and PasteSpritePosition effectively create a brand new sprite from the same image which is displayed once and then discarded. This is done before the text rendering so you can then have text on top.

I believe each pasted sprite is it's own drawcall whereas the positioned sprites are all done in a single call (or something like that), if so the former would be better performance wise.

Don't ask me why we have two different systems, like everything GG related, it's one of those esoteric mysteries.
Been there, done that, got all the T-Shirts!
PM
Tresgamer
3
Years of Service
User Offline
Joined: 30th Apr 2021
Location:
Posted: 3rd May 2021 17:42
Good to know.
PM

Login to post a reply

Server time is: 2024-12-22 01:53:42
Your offset time is: 2024-12-22 01:53:42