Author Topic: Weird syntax errors  (Read 811 times)

Whenever I try to execute an addon from the game (I updated it and want to reload it without restarting the server) I do an exec(add-ons/bleh/server.cs);

It tells me I have a syntax error in the weirdest of places.
It would say something like
Code: [Select]
Executing Add-Ons/Gamemode_Deathrun/Gamemode_Deathrun.cs.
% Add-Ons/Gamemode_Deathrun/Gamemode_Deathrun.cs Line: 503 - Syntax error.
% >>> Some error context, with ## on sides of error halt:
% ^^if(%client.tdmteam==1 && isObject(%client.minigame) && !%client.minigame.tdmModeRule[5])
^^{
^^^messageClient(%client, '', "\c0You can't Self Delete as a death.");
^^^return;
^^}
^^else if(%client.tdmteam==0 && isObject(%client.minigame) && !%client.minigame.tdmModeRule[6])
^^{
^^^messageClient(%client, '', "\c0You can't s##
% >>> Error report complete.

When that happens I just restart.

But the proper way to reload something in a zip file would be
Code: [Select]
discoverFile("add-ons/your_addon.zip"); exec("add-ons/your_addon/server.cs");

Just to clarify, I believe this has to do with the game keeping record of how the .zip is composed. Since you changed it a bunch, it no longer recognizes the file, so it gives an error where it's trying to stop reading. That's why discover works: it re-records the file.

Just to clarify, I believe this has to do with the game keeping record of how the .zip is composed. Since you changed it a bunch, it no longer recognizes the file, so it gives an error where it's trying to stop reading. That's why discover works: it re-records the file.
Yep

Also, it's best to not zip your addons when you're working on them. I put all my WIP scripts in base, then I put a server.cs in Add-ons that loads the files in base.

Yep

Also, it's best to not zip your addons when you're working on them. I put all my WIP scripts in base, then I put a server.cs in Add-ons that loads the files in base.

Code: [Select]
function addDefaultDirectory(%dir) {
if(isDefaultDirectory(%dir))
return;
setModPaths(getModPaths() @ ";" @ %dir);
}

function isDefaultDirectory(%dir) {
%path = strReplace(getModPaths(),";","\t");
for(%i = 0; %i < getFieldCount(%path); %i++)
if(getField(%path, %i) $= %dir)
return true;
return false;
}

addDefaultDirectory("Personal");

Make a folder named Personal in the main Blockland directory, and then you aren't risking doing anything stupid in base. :o

You can't execute/read outside of the default folders, no matter if you use setModPaths or not.

Just use a normal add-on structure just without the zip. It will work.

You can't execute/read outside of the default folders, no matter if you use setModPaths or not.

Just use a normal add-on structure just without the zip. It will work.

Flaw gave me the script, and it appears to work... It tells Blockland that the folder is default... :( I thought.

Just use a normal add-on structure just without the zip. It will work.
This is what I do for all of my add-ons.

Or if you're just testing a script you can stick it in the config folder and you never have to do the discoverfile(); stuff :D

Or if you're just testing a script you can stick it in the config folder and you never have to do the discoverfile(); stuff :D

Already said.

Yep

Also, it's best to not zip your addons when you're working on them. I put all my WIP scripts in base, then I put a server.cs in Add-ons that loads the files in base.

Already said.

Kind (of-ish not-ish)-ish but I guess it works

Or if you're just testing a script you can stick it in the config folder and you never have to do the discoverfile(); stuff :D

Shameless self advertising

This add-on is excellent if you want to test scripts and make changes to them in game.