Scripts / Free simple compass script

Author
Message
Avram
GameGuru TGC Backer
17
Years of Service
User Offline
Joined: 3rd Sep 2006
Location: Serbia
Posted: 29th Dec 2014 17:30 Edited at: 31st Dec 2014 13:32
Here's a simple script showing the compass in the top-left corner of the screen:











The script requires my OOP LUA framework (linked in my forum signature).



Put an always active entity on the map and attach compass.lua to it. When looking at the editor, the north is up (as if looking at the map). Check the screenshot.



You also need to provide 24 images in folder "scriptbank\images\compass", named 000.png, 001.png, 002.png, ... 023.png, each representing compass rotated by 15 degrees (from 0 to 345 degrees). I don't know if I can upload my images here, as



I was using public domain image for compass so I've attached all required rotated images.



If it is allowed, I'll gladly upload rotated images.

Attachments

Login to view attachments
DVader
20
Years of Service
User Offline
Joined: 28th Jan 2004
Location:
Posted: 29th Dec 2014 17:39
Looks great Avram! A pity there is no rotate image command, would simplify things a little Nice work around.



SPECS: Q6600 CPU. Nvidia 660GTX. 8 Gig Memory. Win 7.
3com
9
Years of Service
User Offline
Joined: 18th May 2014
Location: Catalonia
Posted: 29th Dec 2014 18:27
Great work Avram!
Thanks 4 share it.

3com
PM
Jerry Tremble
GameGuru TGC Backer
11
Years of Service
User Offline
Joined: 5th Nov 2012
Location: Sonoran Desert
Posted: 29th Dec 2014 22:38 Edited at: 29th Dec 2014 22:38
You are still the man! Great to have you back! This is awesome! Thanks!

MAME Cab PC: i7 4770@3.4Ghz (passmark 9945), 12GB RAM, Win 8.1/64, GeForce GTX645 (passmark 1898); Shiny new laptop: i7 4800MQ@2.7Ghz (passmark 8586), 16GB RAM, Win 8.1/64, GeForce GTX870M (passmark 3598); Old laptop: i5@2.3Ghz, 8GB RAM, Win 7/64, Intel 3000 graphics
PM
Angiel
9
Years of Service
User Offline
Joined: 21st Dec 2014
Location: Italy
Posted: 30th Dec 2014 20:34
Great work, compliments.
I hope you will continue to implement the scripts (hunger, thirst, inventory etc. ).
Avram
GameGuru TGC Backer
17
Years of Service
User Offline
Joined: 3rd Sep 2006
Location: Serbia
Posted: 31st Dec 2014 13:23
Thanks! I think someone already mentioned he is working on "world" script (day/night periods, hunger, thirst, inventory, ...) but I guess it can be added fairly easy anyway.

Ah yes, when I restarted FPSC my compass went to the very top-left of the screen so I had to change SetImagePosition(1,1) to SetImagePosition(8,12). I still don't know what exactly these numbers mean, I know those are X and Y axes, but the values are probably in percentage or... don't really know yet.

p.s. Santa just edited first post of this thread and attached 24 rotated images because they are public domain and can be modified/distributed further. Happy New Year!

DVader
20
Years of Service
User Offline
Joined: 28th Jan 2004
Location:
Posted: 31st Dec 2014 16:50
Quote: "Ah yes, when I restarted FPSC my compass went to the very top-left of the screen so I had to change SetImagePosition(1,1) to SetImagePosition(8,12)"

You are kidding me, lol? No wonder my script for showing images never worked! They were probably several screens out the way! I was using old fashioned pixel co-ordinates! Those sound very low, even for percentages, I did try 50,50 I think but from the sounds even that would be offscreen. Sounds an odd placement system!



SPECS: Q6600 CPU. Nvidia 660GTX. 8 Gig Memory. Win 7.
cybernescence
GameGuru Master
11
Years of Service
User Offline
Joined: 28th Jan 2013
Playing: Cogwheel Chronicles
Posted: 31st Dec 2014 16:53
I think the X,Y are %'s of screen (so 50,50 is centre of screen), but you also have to set where that x,y position is in relation to the image to be displayed, i.e. if set to '0' it places the centre of the image on the x,y co-ordinate - SetImageAlignment(0), but if set to '1', places the top-left of the image at the x,y position. I think

Avram
GameGuru TGC Backer
17
Years of Service
User Offline
Joined: 3rd Sep 2006
Location: Serbia
Posted: 31st Dec 2014 17:32
A-ha, so it should probably use 1,1 (or 0,0) and SetImageAlignment(1). That's why it didn't work when i used SetImageAlignment(1) and used 100,100 - the top left corner of the image was located at 100%,100% (bottom right corner of the screen) so I couldn't see it. And I thought "why would they (tgc) put image origin point at center of the image, it should be top-left", but it seems we can choose where will it be. Nice!

Angiel
9
Years of Service
User Offline
Joined: 21st Dec 2014
Location: Italy
Posted: 31st Dec 2014 18:12
Quote: "Thanks! I think someone already mentioned he is working on "world" script (day/night periods, hunger, thirst, inventory, ...) but I guess it can be added fairly easy anyway."


Very interesting, is just what I would do with FPSR; when you have the news let me know.
Happy New Year to all.
DVader
20
Years of Service
User Offline
Joined: 28th Jan 2004
Location:
Posted: 31st Dec 2014 18:50 Edited at: 31st Dec 2014 18:50
My image showed up instantly, lol. Never though about it being percentage based. Probably helpful if TGC added it to the description Better really with different resolutions, but I'm so used to placing things with the actual co-ordinates didn't even think about it. Pity I can't do what I wanted though being only able to show one image at a time Still halfway there, lol.



Oops, meant to add a picture.



SPECS: Q6600 CPU. Nvidia 660GTX. 8 Gig Memory. Win 7.
Avram
GameGuru TGC Backer
17
Years of Service
User Offline
Joined: 3rd Sep 2006
Location: Serbia
Posted: 31st Dec 2014 19:39
Nice! If we could place more than one image at a time, we could display map (1st image) with user position (2nd image) overlaying it

cybernescence
GameGuru Master
11
Years of Service
User Offline
Joined: 28th Jan 2013
Playing: Cogwheel Chronicles
Posted: 1st Jan 2015 10:34
I was experimenting with making one of the weapon hud slots a map (instead of hands and a gun, a helicopter view of the map is displayed) ... but so far I can't find a way of telling within script which gun is in use, to then allow the script to only overlay position co-ordinated image pointers onto the image map (for player and enemy position etc)

DVader
20
Years of Service
User Offline
Joined: 28th Jan 2004
Location:
Posted: 1st Jan 2015 16:51 Edited at: 1st Jan 2015 16:58
@ Avram. Yeah, was my intention to have a nice marker for your players position. Without the ability to display more than one image it is a bit of a no goer.



@ Cybernescence. A combination of models and images could work, as long as the model stays p
3com
9
Years of Service
User Offline
Joined: 18th May 2014
Location: Catalonia
Posted: 1st Jan 2015 21:20
Even you can work wit object number, I thought.



Now you can work with EntObjNo variable, something like...



Like ai_soldier script does.

3com
PM
Avram
GameGuru TGC Backer
17
Years of Service
User Offline
Joined: 3rd Sep 2006
Location: Serbia
Posted: 11th Jan 2015 17:26
Anyone actually knows what is entity object number? What's the difference between e and g_Entity[e]['obj']?

3com
9
Years of Service
User Offline
Joined: 18th May 2014
Location: Catalonia
Posted: 11th Jan 2015 17:59
I think it is an entity number/index. Like the number Reloaded assing to entity, when you place it into the map.
About the difference, I think "e" make reference to the entity itself, and "g_Entity[e]['obj']" to their number/index. But wiithout related documentation, it is just my thougts.

I think the goal here would be, to be able to use it in any script for found any entity index. IE:
Assume I have an entity called "table026" and I want to interact with it from other script, non the "table026" one.
Firts I need get the "table026" index.



You can use entity number too, anyway I have seen Reloaded, changing this number arbitrarily, thus is so hard to work with entity number itself.

3com
PM
Avram
GameGuru TGC Backer
17
Years of Service
User Offline
Joined: 3rd Sep 2006
Location: Serbia
Posted: 11th Jan 2015 18:47
But we don't have g_Entity["table026"] (or do we? it wasn't there couple versions ago), we have g_Entity[some_number] where "some_number" is entity's "e", so we already need to know "e" to get entity number. If we already know it, we can use it instead of entity object number

3com
9
Years of Service
User Offline
Joined: 18th May 2014
Location: Catalonia
Posted: 12th Jan 2015 11:40
Quote: "If we already know it, we can use it instead of entity object number"

Yes and not.
Assume you've 10 soldiers, with number 500 to 510
Soldier01, soldier02, soldier03 .....soldier10
Imagine you want to spawn then.
Using names you do:



using entity numbers/index:



As you can see is better work with indexes.

We have to be able to referenced entity from anybody script.
Currently we can use entity index, but Reloaded sometime change this number.
The above code work for me, I save it, close and reopen it, then the above code does not work for me. Why? Because Reloaded change one entity number, now all the soldiers are 500, 501, 502, .....509, except the 510 one, that now it is number 84, why? I don't know.

I thought that to be able to set index via entity properties panel, could help.

3com
PM
J_C
16
Years of Service
User Offline
Joined: 9th Nov 2007
Location:
Posted: 12th Jan 2015 16:10
@Avram

I always thought the Entity [e] number was FPSC-Rs index for the Entity in the list of Entities on the map..
The list of Entities that Lee accesses in his main loop...

The g_Entity[e]['obj'] number is the 3D objects ID that represents the
PM
smallg
Community Leader
18
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 12th Jan 2015 19:38
i tend to avoid g_Entity[e]['obj'] completely as in my experience it just crashes reloaded but then maybe i just haven't used it correctly... i see no reason to not use 'e' though, it works fine.

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: 13th Jan 2015 17:01
@smallg

You are correct they are two different things...

The g_Entiry[e]['obj'] is only used by the AI code because it needs to access the 3D object directly
AISetEntityControl( g_Entiry[e]['obj'], AI_MANUAL)
AIEntityStop( g_Entiry[e]['obj'
PM
3com
9
Years of Service
User Offline
Joined: 18th May 2014
Location: Catalonia
Posted: 13th Jan 2015 17:45
Quote: " i see no reason to not use 'e' though, it works fine."

You are right.

From my experience, I have noticed that Reloaded lists the objects, according to the order in which they are located on the map.
For example, if I place a table in a blank map, that table will be assigned the number 1, if then placed a cup of coffee on the table, that cup of coffee will be assigned the number 2, and so on.

Imagine the following scenario:
I place a light above the table and a switch at the entrance of the room.
The light will have the number 3 and the switch the number 4.

I want to turn the light from the switch (obviously), so I write a script and attached to the switch. obviously I want to turn the light from within the script attached to the switch, which will call, say, switch.lua.

However, from within the script called switch.lua, I can only use 'e' to refer to the switch itself, does not help me to refer to the light object.

To refer to the light object from another script, I need to use the number of the light object, or index assigned to that object. This is where it would be nice to assign an index number in the properties panel.

This way I can refer / interact with any object from within any script.

Would help greatly for example, to place/spawn objects on the map, according to the area in which the player is found

3com
PM
Avram
GameGuru TGC Backer
17
Years of Service
User Offline
Joined: 3rd Sep 2006
Location: Serbia
Posted: 13th Jan 2015 21:16
Well I use my own framework for that. I set a name in a script and then from any other script I can get the entity (and it's "e") by it's name (and/or distance from player/another entity). Though this should be allowed directly in FPSC:R (LUA) without need for third party code.

3com
9
Years of Service
User Offline
Joined: 18th May 2014
Location: Catalonia
Posted: 13th Jan 2015 21:36
Quote: "Though this should be allowed directly in FPSC:R (LUA) without need for third party code."

That's the point.

3com
PM
smallg
Community Leader
18
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 13th Jan 2015 21:46
Quote: "Though this should be allowed directly in FPSC:R (LUA) without need for third party code."


agreed, there's still a lot of basic commands we simply don't have yet... can't even check ammo in a shooting game... @Lee; scripting needs some love

life's one big game

windows vista ultimate

i5 @3.3ghz, 4gb ram, geforce gtx460, directx 11
Super Clark
GameGuru TGC Backer
13
Years of Service
User Offline
Joined: 4th Apr 2011
Location: UK
Posted: 19th Feb 2015 23:47
Great little addition matey works great ... Thanks for your work
PM
Tarkus1971
Audio Media Maker
9
Years of Service
User Offline
Joined: 24th Feb 2015
Location: England, UK
Posted: 26th Mar 2015 15:51
Is this script GameGuru OK, I can't seem to get it to work at all.......... anyone know?
malospam
12
Years of Service
User Offline
Joined: 27th Aug 2011
Location: Florida
Posted: 10th Apr 2015 00:55
Hey Avram, you stated in your post "The script requires my OOP LUA framework (linked in my forum signature). "
When I click on the links, it just goes back to the forums here. Can you explain what this is and how I can get it? Thanks!!
maker of iphone/ipad games
PM
Devcore35
GameGuru TGC Backer
9
Years of Service
User Offline
Joined: 5th Aug 2014
Location: Rouen (76) - France
Posted: 12th Apr 2015 18:10
Great ! Good job !!! Thanks you very much !
PM
Avram
GameGuru TGC Backer
17
Years of Service
User Offline
Joined: 3rd Sep 2006
Location: Serbia
Posted: 17th Apr 2015 12:06 Edited at: 17th Apr 2015 12:22
@malospam: You can get it here: https://bitbucket.org/Avram/game-guru-toolkit

Since the name changed the link on bitbucket changed too.

Login to post a reply

Server time is: 2024-04-19 05:19:08
Your offset time is: 2024-04-19 05:19:08