Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 05-15-2012, 07:07 PM
Emera Emera is offline
Delterian Hybrid
Emera's Avatar
Join Date: Mar 2011
Location: Newcastle Upon-Tyne
Posts: 1,704
Emera is a jewel in the roughEmera is a jewel in the rough
Feedback: Single player minimap

I've been playing around with a lot of areas within GScript that I've never properly looked at before such as SQLite storage methods and more advanced uses for maths. This task was more to do with using maths for more than just placing GUI controls across the screen, and took some thinking on my part.

I've managed to script a simple minimap script that shows your player's position on the map. It works by taking how many levels your GMAP is made up of and finding how many tiles are in those levels added up. It then positions an image on the map image according to the player's location.

It works, I know that, but I'm just curious as to if there's a simpler way to go about doing this. I looked briefly at Dusty's minimap script after finishing this, and his approach is somewhat different to mine.

Any feedback, criticism and advice is welcome as long as it's constructive. Thank you.

(I had to use pastebin.graalcenter.org since incapsula wouldn't let me post the code)

Minimap code (pastebin.graalcenter.org)
Attached Thumbnails
Click image for larger version

Name:	minimapimage.PNG
Views:	219
Size:	38.1 KB
ID:	54635  
Reply With Quote
  #2  
Old 05-15-2012, 10:47 PM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Just on a readability note, you should make constants like this.mapimage and this.scale actually constants:

PHP Code:
//#CLIENTSIDE
const MAP_IMAGE "delt_deltlite-mapimg.png";
const 
SCALE 8;
const 
MAP_DIM = {117};
const 
MARKER "plisticononline.png";

function 
onCreated() {
  
SetPref();
  
DrawMap();
  
onTimeout();
}

// ... 
It makes it easier for whoever is reading your script to understand that you're just working with magic numbers that never change throughout the script.

You should probably also set profile.modal = false; on the mini map control (MapContainer) so it can't accidentally steal focus from the client.

And a 0.05 second timeout is almost certainly not necessary. Ideally you'd only calculate the position a couple times per second or less, and only when the player has moved.
__________________
Reply With Quote
  #3  
Old 05-19-2012, 11:09 PM
Emera Emera is offline
Delterian Hybrid
Emera's Avatar
Join Date: Mar 2011
Location: Newcastle Upon-Tyne
Posts: 1,704
Emera is a jewel in the roughEmera is a jewel in the rough
Thanks for the feedback.

I'm now using constants to store the data instead of this. variables, the control no longer steals the focus from the GraalControl and I'm only checking for the player's position every second now.

Sorry for the slow reply.
Reply With Quote
  #4  
Old 05-20-2012, 04:45 PM
BlueMelon BlueMelon is offline
asdfg
BlueMelon's Avatar
Join Date: Sep 2008
Posts: 1,481
BlueMelon is a splendid one to beholdBlueMelon is a splendid one to beholdBlueMelon is a splendid one to beholdBlueMelon is a splendid one to behold
Good work! I see you're improving since you started scripting.
__________________
http://i.imgur.com/OOJbW.jpg
Reply With Quote
  #5  
Old 05-20-2012, 05:27 PM
Emera Emera is offline
Delterian Hybrid
Emera's Avatar
Join Date: Mar 2011
Location: Newcastle Upon-Tyne
Posts: 1,704
Emera is a jewel in the roughEmera is a jewel in the rough
Quote:
Originally Posted by BlueMelon View Post
Good work! I see you're improving since you started scripting.
heh, thanks BM
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 10:21 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.