Author Topic: My script isn't doing what i want it too  (Read 1953 times)

yeah, i think so

example 1

function cunt(%i)
{
   if(!%i)
      return "no";
   else
      return "yes";
}


==> echo(cunt(0));
"no"

example 2

function cunt(%i)
{
   if(%i)
      return "no";
   else
      return "yes";
}


==> echo(cunt(1));
"no"
« Last Edit: August 15, 2012, 09:59:06 AM by nerraD »

Even though it was unintentional and probably a fluke, one of your lines of code was actually brilliant.


if(GunImage.projectile == (GunImage.projectile = GunProjectile))
    %client.chatMessage("\c6Gun is already \c3reset\c6.");
else
    %client.chatMessage("\c6Gun \c3reset\c6.");

Even though it was unintentional and probably a fluke, one of your lines of code was actually brilliant.


if(GunImage.projectile == (GunImage.projectile = GunProjectile))
    %client.chatMessage("\c6Gun is already \c3reset\c6.");
else
    %client.chatMessage("\c6Gun \c3reset\c6.");


sorry what? :S
« Last Edit: August 15, 2012, 08:32:10 PM by kimbucktwo »

Basically, it utilized two useful facets of programming - all code is linear and setting a variable returns its value.
So that if statement says something like...

If [the memorized value of the Gun's projectile] is the same as [the value of the Gun's projectile after having been changed] then do stuff.


Perhaps someone else can explain it a bit better :S

Basically, it utilized two useful facets of programming - all code is linear and setting a variable returns its value.
So that if statement says something like...

If [the memorized value of the Gun's projectile] is the same as [the value of the Gun's projectile after having been changed] then do stuff.


Perhaps someone else can explain it a bit better :S

oh, haha, thanks :D i didn't know it needed the extra brackets at the time i wrote it :/ and when i was using the script i first posted on this topic, the console kept giving me a message, along the lines of "value always evaluates to zero"... or something like that
and the script works now :D thanks for all the help

Xalos, what instances can if(GunImage.projectile == (GunImage.projectile = GunProjectile)) be used in?

Like, the brackets bit? (highlighted in bold if you still don't understand)


Nevermind, I've just figured out what I was thinking.
« Last Edit: August 16, 2012, 06:15:06 AM by nerraD »

Even though it was unintentional and probably a fluke, one of your lines of code was actually brilliant.


if(GunImage.projectile == (GunImage.projectile = GunProjectile))
    %client.chatMessage("\c6Gun is already \c3reset\c6.");
else
    %client.chatMessage("\c6Gun \c3reset\c6.");

It shows something cool yeah, but that logic will always return true



But yeah you could basically combine
Code: [Select]
%a = b();
if(%a == 5)
Into one line:
Code: [Select]
if(5 == (%a = b())But honestly don't worry about fancy stuff like this until you can write stuff that works



Anyways this code here
http://forum.blockland.us/index.php?topic=204793.msg5661665#msg5661665
Works absolutely fine for me.
My only idea is that you just copied and pasted it into the existing file and didn't reexec or restart or anything

Anyways this code here
http://forum.blockland.us/index.php?topic=204793.msg5661665#msg5661665
Works absolutely fine for me.
My only idea is that you just copied and pasted it into the existing file and didn't reexec or restart or anything
[/quote]

yea that was kinda weird, i kept reexecing the server.cs, but it didnt work until i turned my laptop on again later, and re opened BL

If the file was changed you have to do discoverFile("add-ons/script_blah.zip"); before doing exec("add-ons/script_blah/server.cs");

or just setmodpaths(getmodpaths());


Not needed
exact same use as discoverFile()

it's just that it refreshes the whole Blockland directory for new files.

exact same use as discoverFile()

it's just that it refreshes the whole Blockland directory for new files.
THus isn't noticeable but needs more processing power

No big deal, it's only a slight increase in processing power.

Resetting the mod paths and using discoverFile is not necessary if you develop add-ons properly (only compress them when releasing).