Blockland Forums > Modification Help
Item Pickup
Flea:
I need an item to not pick up until a variable equals one.
Then it checks to see if another variable equals greater then some number.
Then it needs to check for a free slot.
Then it needs to put the item in that slot if theres an open one.
If not it should say no room or something.
If the variable isnt greater than the number it should say to low or something.
If the first variable doesn't equal one it should say not one or something.
I also need to know how to read a text file (Not every line) and store the first line into a variable.
MrPickle:
--- Code: ---if(!%client.firstvariable = 1 && !%client.secondvariable > 10){
messageclient(%client,"",'Not one or 10');
}
--- End code ---
Something like that. Ill explain to you about and not + or.
&& (and) checks for multiple stuff eg. if(%client.wee && %client.poo){}
|| (or) checks for one eg if(%client.wee || %client.poo){}
! (not) checks for stuff thats not true. eg if(!%client.wee){}
Randy:
File Reading:
--- Quote from: |rudyman| on June 05, 2007, 07:14:23 PM ---As an example, here's a script to read a specific line number in a file.
--- Code: ---function readFileLine(%filepath,%line)
{
%file=new FileObject();
%file.openForRead(%filepath);
// the file path is opened for read, now let's loop through each line
while( %file.isEOF() != True) // same as: while( !%file.isEOF() )
{
%text = %file.readLine();
%i++;
if(%line == %i)
{
return %text;
}
}
}
--- End code ---
--- End quote ---
So to make a variable equal the first line of a file you would do:
--- Code: ---%variable = readFileLine("./file.txt", 0);
--- End code ---
Flea:
what does $= mean like in !$= ,and $=?
I need all the ifs so that i can respond to each. Each if checks something different if i use or i cant specify why they couldn't pick it up.
Game master pro:
--- Quote from: Flea on June 15, 2007, 08:42:18 PM ---what does $= mean like in !$= ,and $=?
I need all the ifs so that i can respond to each. Each if checks something different if i use or i cant specify why they couldn't pick it up.
--- End quote ---
$= is for comparing strings i.e
--- Code: ---%lol = "hi";
%lol2 = "hi";
if(%lol $= %lol2) { return true; }
--- End code ---
Would return true. You can't use == for strings because you just don't.
!$= is for comparing if a string is not equal to another one
--- Code: ---%lol = "hi";
%lol2 = "hi";
if(%lol !$= %lol2) { return true; }
else { return false; }
--- End code ---
That would return false.