Go Back   Champions of Regnum > English > Questions to the Community

Questions to the Community Guides and how-to play threads posted by other users

Reply
 
Thread Tools Display Modes
Old 11-23-2007, 07:27 AM   #61
mann2411
Baron
 
mann2411's Avatar
 
Join Date: Feb 2007
Location: Australia
Posts: 699
mann2411 is on a distinguished road
Default

work kiirani work cmon put those pics in
__________________
Brad - after a year of not playing I have no idea how to play my character, no clue what's going on and have to ask questions every few minutes.... I am the born again noob.
mann2411 no ha iniciado sesión   Reply With Quote
Old 11-23-2007, 04:42 PM   #62
Kiirani
Master
 
Kiirani's Avatar
 
Join Date: Aug 2007
Posts: 321
Kiirani is on a distinguished road
Default

Quote:
Originally Posted by mann2411
ppps wah you replaced pp2 and pb2 no good no good
Whoaaa, no no no I didn't!

When you load the page, hang on let me paste the code..


Basically it goes through all the labels and looks for multiple pictures associated with them, and picks one of them at random.

So all your pictures are there. So are any that I've taken, and any that other people have taken. Refresh and you might get another one
PHP Code:
    foreach($places as $place) {
        
$pic getpic($place,'small-'); // Get pic
        
if($pic != false) { // If we got pic
            
$pic $imgdir.'/'.$pic;
            
$place->extra .= '<img src="'.$pic.'" alt="A view of '.$place->name."\">\n"// Add pic to extra info
        
}
    } 
PHP Code:
function getpic($label,$prefix '',$type 'png'
{
    
$wd '/home/kiirani/www/public_html/stuff/regnum/images/'// Directory the images are in
    
chdir($wd); // It moves into that directory
    
$name $label->shortname// Gets the id of the label (msave, jabe...)
    
$dir $label->realm// All the images are stored in images/realm/
    
if(is_dir($dir.'/'.$name))
        
$dir $dir.'/'.$name// if there are WAY too many images of one thing, I can make a dir especially for it. if it doesn't exist then they're in the root of the realm dir.
    
$files scandir($dir); // Get all the files in the directory they're expected to be in    
    
$pattern '/^'.$prefix.$name.'(-[\d]*)?\.'.$type.'$/i'// $prefix is generally set to small, so this matches for example "small-jabe.png", and "small-jabe-1.png", "small-jabe-55239.png"

    
$imgs array_filter($files,create_function('$subj','return preg_match(\''.$pattern.'\',$subj);')); // Array of all the files matching the pattern
    // This is all just preparation
    
sort($imgs);
    
$min 0;
    
$max count($imgs);

    
// If we have images
    
if($max ) {
        
$max--;
        
$file $imgs[rand($min,$max)]; // Pick one at random
        
return $dir.'/'.$file// And this is the one that's used
    
}
    return 
false;


Code:
kiirani@animosity ~/www/public_html/stuff/regnum/images/syrtis $ ls -1
overlay.png
pb.png
small-algaros.png
small-cupula.png
small-gcamp.png
small-jabe.png
small-msave-1.png
small-msave.png
small-pb.png
small-pb2-1.png
small-pb2.png
small-raeraia.png
small-stone.png
syrtistp.png
syrtisunmarked.jpg

Last edited by Kiirani; 11-23-2007 at 04:57 PM.
Kiirani no ha iniciado sesión   Reply With Quote
Old 11-23-2007, 04:45 PM   #63
Kiirani
Master
 
Kiirani's Avatar
 
Join Date: Aug 2007
Posts: 321
Kiirani is on a distinguished road
Default

Anyway, I'm adding a couple of new labels plus pictures now
Kiirani no ha iniciado sesión   Reply With Quote
Old 11-24-2007, 03:38 AM   #64
craiyzee
Initiate
 
craiyzee's Avatar
 
Join Date: Jul 2007
Location: In That Hole Behind You
Posts: 174
craiyzee is on a distinguished road
Default

WOW kii, these are really fantastic!
__________________
kaelee
craiyzee no ha iniciado sesión   Reply With Quote
Old 11-24-2007, 04:03 AM   #65
Kiirani
Master
 
Kiirani's Avatar
 
Join Date: Aug 2007
Posts: 321
Kiirani is on a distinguished road
Default

Quote:
Originally Posted by craiyzee
WOW kii, these are really fantastic!
Hehe ^_^ Thanks


*ahem*

Writing the backend for this has been really interesting to me, to go from a single image to a semi automated backend, automate it a little further, extend my php skills and refine my coding style.

In fact, it's been so interesting that I'm now doing two things :

1) Moving it to a database backend. This opens up the possibility for using the same information for other things -- Info pages on forts and cities, possibly an npc database.
2) Rewriting it in python. I love python.

No, I can't just upload pretty pictures and smile, I like to tinker with the insides

Once I've got it semi-working, I'll put up a link to a beta of some sort (clever people can find it online already)

I'd like to hear feedback on uh.. Well, there isn't really much information. But I'd like to hear feedback on the fact that I'm doing this

In fact, as I write this I think I'll take the easiest road to giving more information on what I'm doing and uh.. Scan my notes You also get to see what my work process is like. (And my handwriting :/)

If you have weird contrast settings and actually notice the little patch where I erased a phone number... I erased a phone number
http://kiirani.com/stuff/regnumnotes.jpg

Edit of perspective: I seem to like the phrase "in fact" a lot.
Kiirani no ha iniciado sesión   Reply With Quote
Old 11-24-2007, 06:23 AM   #66
Miraculix
Count
 
Miraculix's Avatar
 
Join Date: Nov 2007
Location: Infinite Improbability Drive
Posts: 1,287
Miraculix will become famous soon enough
Default

well, i could help you with the python part, i love python too i could also help you with the database, ive worked mostly with mysql, there's no reason to believe you'd use something else

but uh, exactly what are you planning to do in python? i mean, php+mysql is pretty much all you'd need (well, and apache )
Miraculix no ha iniciado sesión   Reply With Quote
Old 11-24-2007, 07:43 AM   #67
Kiirani
Master
 
Kiirani's Avatar
 
Join Date: Aug 2007
Posts: 321
Kiirani is on a distinguished road
Default

Quote:
Originally Posted by Miraculix
well, i could help you with the python part, i love python too :p i could also help you with the database, ive worked mostly with mysql, there's no reason to believe you'd use something else :p

but uh, exactly what are you planning to do in python? i mean, php+mysql is pretty much all you'd need (well, and apache :p)
I don't really need help with any of it XD I already know enough about mysql to have written my own half complete cms.. And uh, mostly complete blog system currently live on kiirani.com :p

As for python.. I have the syntax sorta down, it's just a case of looking things up if I get lost. I'll bug you on irc if google isn't being nice though :D

Hmm. Why python?
The current non-database system is written in php, as is kiirani.com. Since learning python, writing an irc bot etc, my coding style has changed a lot. I process data, build a content variable, then output the content at the end of the page.

This is essentially how mod_python's publisher works.

Writing both systems in php was annoying for me. I miss the little things, list comprehensions, "if x in y:" rather than "if(in_array(x,y)) { "

Basically, I like python, and I was told once "if it's on your server, you can code it in whatever you like"

And so, I am :P

(oh yeah. All of this stuff is being hosted on my home pc, did I mention that?)
Kiirani no ha iniciado sesión   Reply With Quote
Old 11-24-2007, 09:26 AM   #68
Miraculix
Count
 
Miraculix's Avatar
 
Join Date: Nov 2007
Location: Infinite Improbability Drive
Posts: 1,287
Miraculix will become famous soon enough
Default

i kinda guessed that actually

i wasnt implying you dont "know" anything well enough, i was just offering some of my time to get things done in case you needed help, that's all.

your own cms eh? nice... very nice
Miraculix no ha iniciado sesión   Reply With Quote
Old 11-24-2007, 07:00 PM   #69
Kiirani
Master
 
Kiirani's Avatar
 
Join Date: Aug 2007
Posts: 321
Kiirani is on a distinguished road
Default

It's been a "learn php" project for the last two years :P

I guess it worked, I know php.

Um, let's see. You're not on irc, so.. I'm pretty comfortable using the python online docs, but thank you.. And as nice as it is for you to offer, I never was good at group projects XD

I'll ask if I get stuck on something
Kiirani no ha iniciado sesión   Reply With Quote
Old 11-24-2007, 09:38 PM   #70
padreigh
Master
 
Join Date: Aug 2007
Location: Germany, NRW
Posts: 270
padreigh is on a distinguished road
Default

How about adding Area names to WZ, ie Pines crossroads and stuff for alsius?
__________________
Running Gag,Amenotil F., Gundar F., Jaspis U., Lance Lost, Tinman of Oz. (H,C,W,M,B,K)
Internally processed, nutritioally-drained biological output happens - it's called update
padreigh no ha iniciado sesión   Reply With Quote
Reply

Thread Tools
Display Modes

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. The time now is 02:17 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
NGD Studios 2002-2024 © All rights reserved