Jump to content
Psymong

Adding a Moodle / Indentifying a Water Source

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!

Share this post


Link to post
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.

Share this post


Link to post
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 :/

Share this post


Link to post
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.)

Share this post


Link to post
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!

Share this post


Link to post
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) ;)

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...