Jump to content

MoodleFactory: adding Moodles not supported yet- April 20th


RAINBOW

Recommended Posts

I was on another forum here: 

 

http://www.theindiestone.com/community/viewtopic.php%3Ff=38&t=7202.html

 

where I discovered Moodles are not customisable/moddable yet.  Actually, in truth, I discovered it when I was writing code for my custom trait "Vegetarian", when I reached the point of adding in a custom sickness-  I started coding my own custom "Disease/poison" system, which was going to be put on a custom character token and all in all turn into a nightmare!-

 

And then, I found the afforementioned (Link) forum, explaining it hasn't been implemented yet!

 

If anyone else is currently trying to add/alter Moodles (Oh! A moodle example might be, Panic, Hunger, Boredom, Sickness... Etc ... etc..) it simply isn't supported yet-  

I've written all of my code for the custom vegetarian trait, apart from the code chunk which will implement sickness/sickness amount, I reached this point:

 

--lots of stuff here player:getStats():getSickness();

 

Which I'm certain a few other(Serious) modders have.  

 

Instead, I'm turning my efforts into a tutorial for people looking to learn more about modding.  It basically follows on from Robomats (Excellent) tutorial on adding a custom trait and profession, if you haven't done it yet, check it out here:

 

 http://theindiestone.com/forums/index.php/topic/61-robomats-modding-tutorials-updated-12112013/

 

It's a small follow on.  I'll edit this post once I finish the tutorial, oh, it will be found on our persistent world servers "TUTORIAL" section.  Check it out!

Link to comment
Share on other sites

http://www.sanctuary-pz.com/#!tutorialvegetarian/c1su

 

There's that link to the tutorial I promised-  At the moment it shows you how to hook your custom code into any existing code.  So if, until now, all you've managed to do is "Add" things in by modding, give it a shot.- it's fairly comprehensive- but the format is scrappy I'll clean it up later.


Note: The "Setting up" and other tutorials haven't been put in yet- actually, I'm not going to pretend anyone (Me included) can do as good a job as the robomat tutorial.  So do it first.  don't jump ahead.

Link to comment
Share on other sites

If any other modders or beginners, or the admins have some suggestions or ways to improve the tutorial, let me know, i'll amend it.

Hey man,

like first of all good job on your first tutorial :) The more tutorials the better for the community.

There are some problems with it though. Please keep in mind that I didn't test any of this and it's just based from my oberservation and knowledge about lua.

I already commented on your thread in the help section, that the way you are using the EatFoodAction:perform() call outside of it's class is not how it should work. You only ever need to create an instance of the Timed Action you want to use and then add it to the TA Queue. Back then I still didn't quite get what you were trying to do.

Now I read your tutorial and was quite surprised that it seems to work out. Now I know why it works out. What you are doing still is kind of wrong - let me elaborate.

With this statement:

function ISEatFoodAction:perform()            self.item:getContainer():setDrawDirty(true);        self.item:setJobDelta(0.0); self.character:Eat(self.item);        self.character:getBodyDamage():JustAteFood(self.item);        self.item:UseItem(); -- needed to remove from queue / start next                ISBaseTimedAction.perform(self); end
What you are really doing is overwriting the vanilla :perform() function because it is a public function. Basically you could leave out all the "right-click-context menu" stuff you are doing (because it literally doesn't do anything).

You simply could do what you are doing like this (pseudocode):

 

require('pathToIsEatFoodAction.lua'); -- make sure the file is loaded first so we can overwrite itlocal oldF = ISEatFoodActiom:perform();function ISEatFoodAction:perform()      if somethingIsTrue then          --- do your modding stuff           self.character:Say('I have just eaten something'); -- debug line!      else          -- call the original perform code          oldF()    end  end
Put this into a file and it should get you the behaviour you are trying to achieve.

A function is never executed when it is declared, but only when it is called and it is never called from your right click menu - again this wouldn't even be necessary so you can simply ommit the right click stuff.

Another small thing is that IF you need a rigth click menu sometime make the function call local

--The player has right clicked the menu.local function doStuff(player, context, items) -- stuffendEvents.OnFillInventoryObjectContextMenu.Add(doStuff);
This way you don't pollute the global namespace and you don't have to worry about coming up with a unique function name. The rule of thumb in lua is that you should always use locals whenever it is possible (it is possible almost everywhere ;)).

I suggest that you read a few more in-depth tutorials about lua and how it works. You are already on a good way. I've linked to a few resources in my modding tutorial :)

Link to comment
Share on other sites

This makes alot of sense to me now.  My tutorial needs redoing I fear! -

 

Where you write:

 

local oldF = ISEatFoodAction:perform();

 

and then call it later on, it certainly saves on a whole load of redundant code that occurs when doing it 'my' way!!!

 

I wasn't aware you could store a function like "ISEatFoodAction:perform();" in a local variable, you use "oldF" here.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...