ID:2129406
 
Code:


Problem description:

see im working on this project that is pokemon, and i have issues with runtime error: BYOND Error: bad mob
proc name: Read (/mob/Read)
usr: null
src:
call stack:
Read(Players/louisthe10.sav (/savefile))
Menu()
Menu (5,9,1) (/turf/Menu): Click(Menu (5,9,1) (/turf/Menu), "Main.map1", "icon-x=1;icon-y=20;left=1;scre...")

I know its because im saving a mob (the pokemon) under the mob the client.
Just make a list and put objects or whaterver pokemons are in a list. I think lists are auto saved like other vars if they dont use tmp.

And than just simple load character and list should be also loaded.
i have a list. still doesnt work.
mob
var
list
pokemonlist=list()
Can we see what your saving and loading code looks like?
In response to Lummox JR
their pretty basic and standard and i dont want a advanced system. i like the k.i.s.s keep it simple stupid method because im still a rookie. and i also like things compressed. small as they can possibly be.
mob/proc
Menu()
MAINMENU
switch(input(src,"Welcome to [world.name]","Game Menu",text) in list ("Create New","Load","Delete"))
if("Create New")
if(fexists("Players/[src.ckey].sav"))
alert("You already have a player on this server!","[world.name]")
goto(MAINMENU)
else
src.Names()
sleep(5)
switch(alert(src, "Choose Gender" , "Gender Select","Male","Female"))
if ("Male")
src.icon = 'person.dmi'
src.icon_state = "Boy Hero 1"
if ("Female")
src.icon = 'person.dmi'
src.icon_state = "Girl Hero 1"
src.loc=locate(59,64,2)
src.Give_Name()
src.GiveVerbs()
src.ADMIN()
world<<output("<b><font color=red><u>System Info:</u></font> <font color=green>[src.name] has created a character!</font>", "output2")
if("Load")
if(fexists("Players/[src.ckey].sav"))
var/savefile/F=new("Players/[src.ckey].sav")
Read(F)
src.GiveVerbs()
src.Stuff()
else
alert(usr,"No file found")
goto(MAINMENU)
if("Delete")
if(fexists("Players/[src.ckey].sav"))
fdel("Players/[src.ckey].sav")
alert(src,"Save file deleted.")
del(src)
else
alert(usr,"No file found")
goto(MAINMENU)




mob
verb
Save()
var/savefile/F=new("Players/[src.ckey].sav")
Write(F)
src<<"Character Saved!"
Write(savefile/F)
..()
F["x"]<<x
F["y"]<<y
F["z"]<<z
F["dir"]<<dir

Read(savefile/F)
..()
F["x"]>>x
F["y"]>>y
F["z"]>>z
F["dir"]>>dir
src.loc=locate(src.x,src.y,src.z)

i had this in another post but they guy didn't really explain anything to a point where i could understand. i want to keep it the way it as it worked for other games. the problem only persists of getting a bad mob after you get your starter Pokemon. i have used similar save code for another project and it worked fine. i think its just because Im saving mobs under mobs. by the way thank you for taking your time to read this and help me, ive been stuck on this for days on end. trying different systems and this was most efficient for me. Could it be because Pokemon mobs are labeled as mob/Pokemon and the vars are labed as just mobs? and i need some notes to help me understand certain functions. please and thank you.
This will obviously depend on how you want to call back on their Pokemon but...

You can use a list of mobs for the player's Pokemon (this is if you have defined your Pokemon as mobs)
mob
var
mob/Pokemon[] = list()
mob/PartyPokemon[6] = list(null, null, null, null, null, null)

Then when the player chooses a starter you can save that starter into their Pokemon list.
mob
proc
SelectStarter(var/mob/SelectedPokemon)
src.Pokemon.Add(SelectedPokemon)
src.PartyPokemon[1] = SelectedPokemon

Now as long as you don't define the variables as tmp they will save your pokemon.

This is just an idea of how it would work, I am sure there are better ways out there...
In response to Nailez
Nailez wrote:
mob/PartyPokemon[6] = list(null, null, null, null, null, null)

This is called double-initialization because the [6] already initializes the variable as a list of 6 nulls.
The verbose, non-square-bracket syntax is:
var list/PartyPokemon = new /list (6)
Oh I see, thanks for that!
There's goto abuse in that code. You should have it in a while loop, and continue instead of goto.
In response to Nailez
runtime error: cannot write to indexed value in this type of list
proc name: SelectStarter (/mob/proc/SelectStarter)
usr: (src)
src: Demon (/mob)
src.loc: Floor10 (59,65,2) (/turf/Floor10)
call stack:
Demon (/mob): SelectStarter(null)
Prof Shinn (/mob/Prof_Shinn): Talk()



mob
proc
SelectStarter(var/mob/SelectedPokemon)
src.pokemonlist.Add(SelectedPokemon)
src.PkmInInven[1] = SelectedPokemon


However it did elmeinate the bad mob runtime error so thank you but now i got a new one xD
What does your PkmInInven list look like when you defined it?
In response to Nailez
mob/var

PkmInInven=0

i think i know why its not working but what should it look like. in the current code it sets as usr.PkmInven++. how do i code it so the max can be 6?
Okay so in this code:
src.PkmInInven[1] = SelectedPokemon

Your trying to set the PkmInInven to the Pokemon. But I just put that as an example, you don't need to put that.

The error your getting is because your trying to set the first item in the PkmInInven list as the selected pokemon but you cant because PkmInInve is not defined as a list.

So SelectStarter should look like this:
mob
proc
SelectStarter(var/mob/SelectedPokemon)
src.pokemonlist.Add(SelectedPokemon)
src.PkmInInven ++
As for limiting the amount of pokemon you can have...

If pokemonlist is the list of pokemon in the party (which is limited to 6) then you can do a check to see if pokemonlist length is < 6 when you add a pokemon to it.

if(pokemonlist.len < 6)
//Add the pokemon to the list
else
//Send the pokemon to the pc? Or whatever you want to here


There are probably other ways as well.
thank you so much for the help everyone!
In response to Lummox JR
so instead of goto(MENU)
i do While(MENU)?
Maybe something like:
mob
proc
Menu()
var/CanContinue = 0
while(CanContinue == 0)
//My switch statement here..

And everywhere you have not put goto(MAINMENU) you put CanContinue = 1 and remove goto(MAINMENU)

So for your "Load" part
if("Load")
if(fexists("Players/[src.ckey].sav"))
var/savefile/F=new("Players/[src.ckey].sav")
Read(F)
src.GiveVerbs()
src.Stuff()
CanContinue = 1
else
alert(usr,"No file found")


I'll let you fix up the rest of the proc.
now i have another issue. should i post it in here sense its related to the list issue?
Post it
Page: 1 2 3