ID:150923
Jul 2 2001, 5:17 pm (Edited on Jul 2 2001, 5:33 pm)
|
|
/******** Character handling example. This is example code using the Character Handling library. You'll want to copy this file into your game and change it around for your library. The library is a part of BaseCamp, Deadron's game infrastructure system. BaseCamp: From here you can reach Everest! If you have questions or suggestions, please email [email protected]. ***********/ var/subclass #include "characterhandling.dm" /*** How many characters is a player allowed to have? ***/ client base_num_characters_allowed = 5 /*** This sets the default mob to /mob/choosing_character. By having a special choosing_character class and then giving the player another kind of mob once they've chosen, you avoid having the choosing character Login() code conflict with any other Login() code you might want to use -- in particular, it avoids the bug where people keep coming back to the choosing character dialog after they already chose a character. If you don't understand all that, don't worry: just make sure you keep the character choosing stuff in the choosing_character class and that you create a different kind of mob for the player when they choose a character, and you'll be fine. ***/ world view = 7 mob = /mob/creating_character mob/creating_character base_save_allowed = 0 // If player quits before choosing, don't want to save this mob. Login() // Spawn here to avoid problems with calling prompts during login. spawn() src.CreateCharacter() proc/CreateCharacter() // In this case, the code creates a /mob/human or /mob/ogre with the specified attributes. // Get the character information from them. (You would probably want to do with this a browser page.) var/prompt_title = "New Character" var/help_text = "What do you want to name the character?" var/default_value = key var/char_name = input(src, help_text, prompt_title, default_value) as null|text if (!char_name) // Guess they don't want to create a new character after all, so send them to choose a character. client.base_ChooseCharacter() return // Make sure there isn't already a character named that. // Character names are stored as ckey, so get the ckey version of the name. var/ckey_name = ckey(char_name) var/list/characters = client.base_CharacterNames() if (characters.Find(ckey_name)) alert("You already have a character named that! Please choose another name.") src.CreateCharacter() return var/list/races = list("Saiyan(Broli)", "Saiyan(Goku)", "Namek","Human","Icer","Half Saiyan","Andriod") help_text = "Which class would you like to be?" default_value = "Saiyan(Goku)" var/char_race = input(src, help_text, prompt_title, default_value) in races // Okay we have enough information, so it's time to create the character and switch the player to it. var/mob/new_mob switch(char_race) if ("Saiyan(Broli)") new_mob = new /mob/broli() if ("Saiyan(Goku)") new_mob = new /mob/goku() if ("Namek") new_mob = new /mob/namek() if ("Human") new_mob = new /mob/human() if ("Icer") new_mob = new /mob/icer() if ("Half Saiyan") new_mob = new /mob/hsaiyan() if ("Andriod") new_mob = new /mob/android() // Set the attributes. new_mob.name = char_name // Now switch the player client over to the new mob and delete myself since I'm no longer needed. src.client.mob = new_mob var/turf/first_location = locate(3, 3, 1) new_mob.Move(first_location) del(src) mob var eye_color Login() ..() // This is just here for this sample, to make it clear which mob you've logged into. sample_report() Write(savefile/F) // This is sample code that keeps track of the player's last position on the map. // Their last position is stored when the mob is saved, then reinstated when the mob // is read in. // First, call the default Write() behavior for mobs. ..() // Now, if we have a map, remember their last location. if (world.maxx) F["last_x"] << x F["last_y"] << y F["last_z"] << z Read(savefile/F) // Call the default Read() behavior for mobs. ..() // Now, if we have a map, put them back on the map in their last location. if (world.maxx) var/last_x var/last_y var/last_z F["last_x"] >> last_x F["last_y"] >> last_y F["last_z"] >> last_z loc = locate(last_x, last_y, last_z) proc sample_report() src << " " src << "\blue Welcome [name]" well, theres some more code for the other dbz gamers to steal, what the the problem is.....THEY ALL LOOK LIKE THE ANDRIOD!!!!!!! help me!!!! </<></<></<> |
In response to LexyBitch
|
|
On 7/2/01 8:29 pm LexyBitch wrote:
Here are all of the problems I see: You missed one Lexy: 5) 99.9% of that post is my library code, with about 10 new lines, done incorrectly. |
In response to Deadron
|
|
On 7/2/01 9:53 pm Deadron wrote:
On 7/2/01 8:29 pm LexyBitch wrote:Deadron.. I think you should but a small credit display in /mob/Login() that says something like usr << "Character Handling by 'Deadron'". I doubt most of the people who don't give you credit, wouldn't be able to figure out how to get rid of it either. |
In response to Flick
|
|
On 7/3/01 5:16 am Flick wrote:
On 7/2/01 9:53 pm Deadron wrote: Absolutely! Not to mention, I would leave it in as a friendly credit in my game. |
In response to Skysaw
|
|
On 7/3/01 5:28 am Skysaw wrote:
On 7/3/01 5:16 am Flick wrote: By the way, assume that the last sentence in my section actually says what it's supposed to. (change wouldn't to would ... or something) sigh Invalid argument Usage: Sigh(dammit) |
In response to Flick
|
|
On 7/3/01 5:16 am Flick wrote:
Deadron.. I think you should but a small credit display in /mob/Login() that says something like usr << "Character Handling by 'Deadron'". I doubt most of the people who don't give you credit, wouldn't be able to figure out how to get rid of it either. I don't mind not getting credit for basic libraries...but just find it a bit odd that someone would talk about other people stealing their stuff when all the lines that work are mine anyway. If I ever end up releasing the full BaseCamp I might require a credit statement somewhere. In part just cause I like the slogan: BaseCamp: From here you can reach Everest! |
In response to Flick
|
|
Sariat ive been coding for bout one 1/2 day and see whats wrong + how to improve upon it (i think u should use sub categories)
Note: Any way to those who dont kno me Hi |
In response to Deadron
|
|
On 7/3/01 8:48 am Deadron wrote:
BaseCamp: From here you can reach Everest! First time I read that in your character handling library I let out a discouraged moan... then I realized you wrote Everest and not Everquest! ;) |
In response to DoOmBringer
|
|
var/char_race = input(src, help_text, prompt_title, default_value) in races
// Okay we have enough information, so it's time to create the character and switch the player to it. var/mob/new_mob switch(char_race) if ("Broli") new_mob = new /mob/broli() if ("Goku") new_mob = new /mob/goku() if ("Namek") new_mob = new /mob/namek() if ("Human") new_mob = new /mob/human() if ("Icer") new_mob = new /mob/icer() if ("Half Saiyan") new_mob = new /mob/hsaiyan() if ("Andriod") new_mob = new /mob/android() // Set the attributes. new_mob.name = char_name // Now switch the player client over to the new mob and delete myself since I'm no longer needed. src.client.mob = new_mob var/turf/first_location = locate(3, 3, 1) new_mob.Move(first_location) del(src) thats the RELEVANT code, here are the errors loading DBZ AFTA MATH.dme DBZ AFTA MATH.dm:97:error:new_mob:bad var DBZ AFTA MATH.dm:98:error:new_mob:bad var DBZ AFTA MATH.dm:99:error:new_mob:bad var DBZ AFTA MATH.dm:100:error:new_mob:bad var DBZ AFTA MATH.dm:101:error:new_mob:bad var DBZ AFTA MATH.dm:102:error:new_mob:bad var DBZ AFTA MATH.dm:103:error:new_mob:bad var DBZ AFTA MATH.dm:105:error:new_mob.name:bad var DBZ AFTA MATH.dm:110:error:new_mob:bad var DBZ AFTA MATH.dm:112:error:new_mob.Move:bad var DBZ AFTA MATH.dm:96:error:char_race:bad variable definition DBZ AFTA MATH.dm:96:error:switch :invalid variable name: reserved word DBZ AFTA MATH.dm:105:error::missing expression DBZ AFTA MATH.dm:89:char_race :warning: variable defined but not used DBZ AFTA MATH.dmb - 13 errors, 1 warning heh.... |
In response to Sariat
|
|
On 7/3/01 3:04 pm Sariat wrote:
var/char_race = input(src, help_text, prompt_title, default_value) in races Lexy already told you why that was broken. Your if() statements are not indented under the switch() statement. |
In response to Sariat
|
|
// Okay we have enough information, so it's time to create the character and switch the player to it. You indented the wrong line. Sigh... Indent the stuff AFTER the switch. A switch statement looks like this: switch(variable) if(value) do this if(value) do that if(value) do this and that but not those Read the furking Reference and the Guide if a particular bit of code is giving you trouble! Yeesh. |
In response to Deadron
|
|
On 7/3/01 3:06 pm Deadron wrote:
On 7/3/01 3:04 pm Sariat wrote: Can I draw everyone's attention once more to reason #1? |
In response to LexyBitch
|
|
i just want to say
you go girl |
1) You're a moron.
2) You're blithely RIPPING-OFF, STEALING, COPYING, etc. from funimation, yet you see something wrong with others doing the same for you.
3) You set yourself up for a million anti-DBZ slams by posting "They all look the same" (something we've often lamented.)
4)
switch(char_race)
if ("Saiyan(Broli)") new_mob = new /mob/broli()
if ("Saiyan(Goku)") new_mob = new /mob/goku()
if ("Namek") new_mob = new /mob/namek()
if ("Human") new_mob = new /mob/human()
if ("Icer") new_mob = new /mob/icer()
if ("Half Saiyan") new_mob = new /mob/hsaiyan()
if ("Andriod") new_mob = new /mob/android()
You need to indent all these if statements! They are contained WITHIN the switch, right? How is the computer supposed to know which if's are part of the switch if you don't mark them in some way. So, it's running through each of them, because "if (any statement that isn't an equation, inequality, 0 or null or false)" always evaluates to true. If ("Whatever") is a constant statement, because no question is being asked (except when it's contained in an switch statement, which your if's aren't.)
Incidentally, you posted so much of your damn code that it's only sheer luck I spotted this. Next time, ONLY POST THE RELEVANT PART. I can't believe you didn't do enough checking on your own to realize it wasn't just giving you the android's icon, but was making you the android all the time. That should've told you right away where the error is. And didn't it give you an error or warning that the switch statement was empty? If so, why did you ignore that? Do you think the compiler does that for fun?