Author Topic: Hunger Mod development. (with Items) (Beginner torque scripter)  (Read 1985 times)

Hello.
I was making a food mod with items and was wondering how to share a client variable between to add-ons.
Code: [Select]
//some Item code
{
%changefood = %client.food + 40;
%obj.emote(CheeseburgerHealImage);
%obj.tool[%i] = 0;
%obj.weaponCount--;
messageClient(%obj.client,'MsgItemPickup','',%i,0);
serverCmdUnUseTool(%obj.client);
break;
}
[/s]
How can I share the %changefood and the %client.food variable between the base hunger script and the food item add-on.[/s]

Thanks

« Last Edit: December 26, 2017, 04:42:35 PM by soldier101@ »

They're already shared
Just name it the same thing between add-ons

They're already shared
Just name it the same thing between add-ons
I did and it for some reason the food add-on didn't load at all.
It says the food item has syntax errors. I gotta check it out...
« Last Edit: December 23, 2017, 05:12:56 PM by soldier101@ »

Well %client.food will always be shared as long as you're accessing the same %client object
But %changefood you'd need to store on something like a client or player object

I changed the code a lot
Code: [Select]
1 function SteakImage::onFire(%this,%obj,%slot, )
2 {
3
4
5 for(%i=0;%i<5;%i++)
6 {
7 %toolDB = %obj.tool[%i];
8 if(%toolDB $= %this.item.getID())
9 {
10 //%obj.
11                % client.hunger + 20;
               messageClient(% client, '', "\c6You have \c3" @ % client.food @ "\c6 food.");

                % obj.emote(SteakeatImage);
%obj.tool[%i] = 0;
%obj.weaponCount--;
messageClient(%obj.client,'MsgItemPickup','',%i,0);
serverCmdUnUseTool(%obj.client);
break;
}
}
}
I think it keeps giving a syntax error on line 11
I am probably making a really simple syntax error. I am just learning to code with torque script.
Can anyone help me?
« Last Edit: December 23, 2017, 05:42:32 PM by soldier101@ »


1) you have spaces between % and the var name - the script compiler will not recognize that is a local var being referenced
2) %value1 + %value2; is an invalid line since it doesnt change anything iirc. you need to do something like %value1 = %value1 + %value2;

1) you have spaces between % and the var name - the script compiler will not recognize that is a local var being referenced
2) %value1 + %value2; is an invalid line since it doesnt change anything iirc. you need to do something like %value1 = %value1 + %value2;
I changed the code somewhat,
Code: [Select]
function SteakImage::onFire(%this,%obj,%slot, )
{


for(%i=0;%i<5;%i++)
{
%toolDB = %obj.tool[%i];
if(%toolDB $= %this.item.getID())
{
//%obj.
                %addfoodvar = %client.hunger + 40;
        messageClient(% client, '', "\c6You have \c3" @ %client.food @ "\c6 food.");

                %obj.emote(SteakeatImage);
%obj.tool[%i] = 0;
%obj.weaponCount--;
messageClient(%obj.client,'MsgItemPickup','',%i,0);
serverCmdUnUseTool(%obj.client);
break;
}
}
}
The past errors have gone away, but now its angry at the function.
Code: [Select]
(Some error context, with ## on the sides of the halt.)
function SteakImage::onFire(%this,%obj,%slot, )####
[/s]
nevermind
« Last Edit: December 23, 2017, 08:19:31 PM by soldier101@ »

Now It doesn't say it has any syntax errors. It just says
Error Opening zip (Add-Ons/Item_CookedSteak.zip), need to handle this better.
setModPaths: invalid mod directory name: "config"

Many lines later
Error Opening zip (Add-Ons/Item_CookedSteak.zip), need to handle this better.
Now, I have NO idea whats going on...
I am using default Blockland-
Ti's pretty smart too.
I tried embedding the steak add-on into Script_Hunger, and it consoled
 Add-On Item_Steak has been renamed to Script_hunger will not execute
« Last Edit: December 23, 2017, 08:44:58 PM by soldier101@ »

I tried to do it again with a different add-on, and it just ignored it without even consoling it. After I started the game
« Last Edit: December 23, 2017, 08:59:27 PM by soldier101@ »

you have a comma after %slot

the namecheck.txt in the zip file is not matched with the folder name. just delete it.

make sure to restart bl or do setmodpaths(getmodpaths); every time you change a .zip/a .zip’s contents

you have a comma after %slot

Thanks though, I already fixed that before you posted though.

Yeah... that did nothing
I figured That ill just post the current code
https://pastebin.com/wSQKcQjy
Item steak
https://pastebin.com/VY8ibf8L
Hunger script

And here is download to test yourself
https://leopard.hosting/dl/zekfy/1ao00oo%2313.zip
« Last Edit: December 23, 2017, 09:59:39 PM by soldier101@ »

you don't need to use a .zip while developing
it's easier to just use a folder

you don't need to use a .zip while developing
it's easier to just use a folder
ok

Thanks for all the help.
After a while I got my senses together and found out myself.
In the end, (It seems really stupid for me) I was calling the client wrongly.
THis is what it should look like
Code: [Select]
               %obj.client.hunger = %obj.client.hunger + 10;
            messageClient(%obj.client, '', "\c6You have \c3" @ %obj.client.hunger @ "\c6 hunger.");
This is how I had it
Code: [Select]
               % addFoodVar = %client.hunger + 10;
            messageClient(%client, '', "\c6You have \c3" @ % client.hunger @ "\c6 hunger.");
As you see I have messed up a lot.
The code had no idea who the client was either, and I had MANY syntax errors.
« Last Edit: December 26, 2017, 05:26:15 PM by soldier101@ »