| Blockland Forums > Modification Help |
| Variable Questions |
| << < (4/4) |
| Chrono:
--- Quote from: jes00 on August 31, 2011, 12:54:30 PM ---So would this work? --- End quote --- You should really have a 'variable prefix' like how the default game uses Pref::Server::. Something like $RPG::Gold[%client.bl_id] So then the code would turn into this: --- Code: ---function GameConnection::saveVars(%client) { export("$RPG::*" @ %client.bl_id, "config/Vars/" @ %client.bl_id @ ".cs"); } --- End code --- to load: --- Code: ---package autoLoad { function gameConnection::AutoAdminCheck(%client) //This is called once a client joins the server { if(isFile("config/Vars/" @ %client.bl_id @ ".cs")) exec("config/Vars/" @ %client.bl_id @ ".cs"); else %client.configureMedievalRpgSaves()(); return Parent::AutoAdminCheck(%client); } }; activatePackage(autoLoad); --- End code --- and to remove data of a user who has left the server: --- Code: ---package autoSave { function GameConnection::onClientLeaveGame(%client) { %client.saveVars(); deleteVariables("$RPG::*" @ %client.bl_id); return Parent::onClientLeaveGame(%client); } }; activatePackage(autosave); --- End code --- Note the position of the *. This is a wildcard. Thus, it saves/deletes anything that is $RPG::*[%client.bl_id] If you want the bottom print to display all 4 of those variables, you'd need a tick function that calls this: %client.bottomPrint("<color:4040f0>Health: <color:ffffff>" @ $RPG::Health[%client.bl_id] @ " <color:8080dd>MP: <color:ffffff>" @ $RPG::MP[%client.bl_id] @ " <color:c0c0c0>Class: <color:ffffff>" @ $RPG::Class[%client.bl_id] @ " <color:9c6963>Gold: <color:ffffff>" @ $RPG::Gold[%client.bl_id],10); (I didn't know if health and MP were current or max, you'd have to clarify on that. |
| jes00:
Is it possible to make a variable appear as a word? |
| Chrono:
Variables can be words. |
| jes00:
--- Quote from: Chrono on August 31, 2011, 09:44:59 PM ---Variables can be words. --- End quote --- Good, Good. |
| jes00:
So I would use --- Code: ---$Var[%client.bl_id] --- End code --- to modify a var? |
| Navigation |
| Message Index |
| Previous page |