Jump to content

Adding a Moodle / Indentifying a Water Source


Psymong

Recommended Posts

Hello!

A couple of questions, if you guys don't mind:

 

1. Could somebody explain/link me to a guide to adding a new moodle to the game. I cant seem to find this information anywhere

 

2. Does anybody know the way to identify a water source in the world (i.e a sink), I've tried using "IsWaterSource" but i think that applies to bottles of water in the players inventory.

 

I'm a bit new to lua, so i may need it explained in terms an idiot would understand.

many thanks in advance!

Link to comment
Share on other sites

You can't find information about moodles because no one has managed (or tried) to add custom ones so far I'd say. ;)

I'm on my phone right now so I can't check but you should find the water source stuff in ISworldcontextmenu. I'll check it when i'm back home.

Link to comment
Share on other sites

moodles are programmed in Java and use a defined enum type to give information/text/icon/other information about the moodled, so unless you are going to decompile the source, modify the javaclass, recompile the file it will be impossible to add them.

 

don't know anything about the water :( my guess is that it is in java cause I haven't found anything in the lua scripts that hint at that :/

yet haven't found it in the java classes at the moment :/

Link to comment
Share on other sites

I haven't tried it out yet, but I think you check if it is a water source with:

object:getSprite():getProperties():Is(IsoFlagType.waterPiped)

As I said above, you can find this in the ISWorldObjectContextMenu.lua ;)

 

(this should work for bathtubs etc.)

Link to comment
Share on other sites

Thanks for the info, guys!

I guess I'm aiming a bit high with my first mod. ;)

I can just use player speech\onscreen display instead of moodles for the time being

 

RoboMat, thanks man!

However, i think i'm too much of an amateur to be able to use that properly.

So, im trying to add a new option to the context menu of water sources, what am i doing wrong here?:

newWaterMenu = function(context, worldobjects, player)      if object ~= nil and instanceof(object, "IsoObject") and object:getSprite():getProperties():Is(IsoFlagType.waterPiped) then             context:addOption("New Water Function", worldobjects, newWaterFunction, player);      endendEvents.OnWorldContextMenuCreated.Add(newWaterMenu);

thanks again guys!

Link to comment
Share on other sites

You forgot to iterate through the clicked items:

 

YourModPackage = {};function YourModPackage.createWaterMenu(_context, _worldobjects, _player)    local player = getSpecificPlayer(_player);    for _, object in ipairs(_worldobjects) do        if object ~= nil and instanceof(object, "IsoObject") and object:getSprite():getProperties():Is(IsoFlagType.waterPiped) then            _context:addOption("New Water Function", _worldobjects, YourModPackage.newWaterFunction, player);        end    endendEvents.OnWorldContextMenuCreated.Add(YourModPackage.createWaterMenu);

* didn't test this btw.

 

Btw... you should put all your global functions and variables in a table (in my example YourModPackage) ;)

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...