| Blockland Forums > Modification Help |
| Auto Loading Compass |
| << < (2/2) |
| Kalphiter:
--- Quote from: jes00 on January 23, 2012, 03:16:03 PM ---But that's kinda the point of the Coding Help topic; for when you can't "figure it out". --- End quote --- Add unique echoes so that you know what code is reached and what isn't. |
| CityRPG:
What kalphiter said. --- Code: ---function testSomething() { echo("In Function!"); if(someTest()) { echo("Pass 1"); if(someOtherTest()) { echo("Pass 2"); while(doingSomething()) { echo("Doing something!!!"); } } } } --- End code --- If you're not seeing proper output at say, Pass 2, then you know SomeOtherTest is breaking it. This is a very sophisticated and high-level debugging technique. Use it carefully. |
| jes00:
It only echos "Deleted GUI text box", "Changed save button command.", and "Changed load button command.". --- Code: ---//========================================================================= // GUI Stuff //========================================================================= CompassWaypointGUI_File_Filename.delete(); echo("\c2Deleted GUI text box"); CompassWaypointGUI_File.getObject(0).getObject(1).command = "CompassWaypointGUI.saveWaypointDelay();"; echo("\c2Changed save button command."); //Save button^^ CompassWaypointGUI_File.getObject(0).getObject(2).command = "CompassWaypointGUI.loadWaypointDelay();"; echo("\c2Changed load button command."); //Load button^^ //========================================================================= // Functions //========================================================================= function CompassWaypointGUI::saveWaypointDelay() { %hostName = getSubStr($ServerInfo::Name, 0, strStr($ServerInfo::Name, "\'")); %host = %host @ "'s server"; CompassWaypointGUI.saveWaypoints(%host); } function LoadWaypointDelay(%filename) { %host = getSubStr($ServerInfo::Name, 0, strStr($ServerInfo::Name, "\'")); echo("\c2Host = " @ %host); if(isFile("config/client/WP/" @ %host @ "'s server.txt")) { echo("\c2LoadWaypointDelay: File found."); CompassWaypointGUI.loadWaypoints(%host @ "'s server.txt"); echo("\c2CompassWaypointGUI.loadWaypoints called."); } else { echo("\c2LoadWaypointDelay: File not found."); } } package Compass_Load { function serverConnection::onConnectionAccepted() { parent::onConnectionAccepted(); echo("\c2Connection accepted."); %host = getSubStr($ServerInfo::Name, 0, strStr($ServerInfo::Name, "\'")); echo("\c2Host = " @ %host); if(isFile("config/client/WP/" @ %host @ "'s server.txt")) { %filename = "config/client/WP/" @ %host @ "'s server.txt"; echo("\c2File found: " @ %filename); LoadWaypointDelay(%filename); echo("\c2LoadWaypointDelay called."); } else { echo("\c2onConnectionAccepted: File not found."); } } }; activatePackage(Compass_Load); --- End code --- |
| Slicksilver:
--- Quote from: jes00 on January 23, 2012, 06:48:31 PM ---It only echos "Deleted GUI text box", "Changed save button command.", and "Changed load button command.". --- Code: ---//========================================================================= // GUI Stuff //========================================================================= CompassWaypointGUI_File_Filename.delete(); echo("\c2Deleted GUI text box"); CompassWaypointGUI_File.getObject(0).getObject(1).command = "CompassWaypointGUI.saveWaypointDelay();"; echo("\c2Changed save button command."); //Save button^^ CompassWaypointGUI_File.getObject(0).getObject(2).command = "CompassWaypointGUI.loadWaypointDelay();"; echo("\c2Changed load button command."); //Load button^^ //========================================================================= // Functions //========================================================================= function CompassWaypointGUI::saveWaypointDelay() { %hostName = getSubStr($ServerInfo::Name, 0, strStr($ServerInfo::Name, "\'")); %host = %host @ "'s server"; CompassWaypointGUI.saveWaypoints(%host); } function LoadWaypointDelay(%filename) { %host = getSubStr($ServerInfo::Name, 0, strStr($ServerInfo::Name, "\'")); echo("\c2Host = " @ %host); if(isFile("config/client/WP/" @ %host @ "'s server.txt")) { echo("\c2LoadWaypointDelay: File found."); CompassWaypointGUI.loadWaypoints(%host @ "'s server.txt"); echo("\c2CompassWaypointGUI.loadWaypoints called."); } else { echo("\c2LoadWaypointDelay: File not found."); } } package Compass_Load { function serverConnection::onConnectionAccepted() { parent::onConnectionAccepted(); echo("\c2Connection accepted."); %host = getSubStr($ServerInfo::Name, 0, strStr($ServerInfo::Name, "\'")); echo("\c2Host = " @ %host); if(isFile("config/client/WP/" @ %host @ "'s server.txt")) { %filename = "config/client/WP/" @ %host @ "'s server.txt"; echo("\c2File found: " @ %filename); LoadWaypointDelay(%filename); echo("\c2LoadWaypointDelay called."); } else { echo("\c2onConnectionAccepted: File not found."); } } }; activatePackage(Compass_Load); --- End code --- --- End quote --- Your code runs when you join a server. Did you check then, or when you executed it? If you're getting nothing when you join a server, it's because serverConnection::onConnectionAccepted is the wrong function to parent. I'm not sure if it is or isn't. I think it is. |
| Navigation |
| Message Index |
| Previous page |