HeroEngine Forums
Welcome, Guest. Please login or Register for HeroCloud Account.
Pages: [1] 2

Author Topic: Props and Glomming  (Read 3927 times)

Amarak

  • General Accounts
  • *
  • Posts: 281
    • View Profile
Props and Glomming
« on: Jul 20, 14, 12:20:01 AM »

Hi guys! I am working on making an object with scripts attached, and so far I haven't found exactly how to do this. There is the My First HSL Script tutorial which is close, but it uses MNAC and is non persistent.

 I started trying to use the Props system which I think would work, but I'm not sure how to add my custom classes to the object, which I want to place in the asset library. I don't know how to add my own Decorators along with the default Props Decorators. I saw something about it:

Code: [Select]
shared function OnInstantiationFromSpec( specDerivedObject as NodeRef )
  if not ( specDerivedObject is kindof _VisibleProp )
    GlomClass( "_VisibleProp", specDerivedObject )
  .
  where specDerivedObject is kindof _VisibleProp
    where specDerivedObject is kindof _Prop
      spec as NodeRef of Class _PropSpec = specDerivedObject.GetMySpec()
      where spec is kindof _PropVisualizationDecorator
        specDerivedObject._PropLoD = spec._PropLoD
      .
    .
  .

I believe this is the proper method but which script would I put it in and how would I attach that script to the object?

 To clarify, I am working on making a crafting station where a player can click on it and it will bring up a GUI for making new items. I believe I can GLOM the class onto the object in the Library Commands but I'm not sure about that.

I've also considered Prototypes, but not sure if that would be the correct route. Any suggestions would be greatly appreciated. I've fond this system a lot more convoluted than Unity where you just drag and drop scripts onto objects.  ;)
Logged

Thazager

  • General Accounts
  • *
  • Posts: 1156
  • Never stop learning
    • View Profile
    • Heroes and Villains MMORPG
Re: Props and Glomming
« Reply #1 on: Jul 20, 14, 12:33:52 AM »

While I have not yet used the spec system to make a clickable object, I have had GUIs pop up when the character is near enough to reach the object. This might be one way of doing it. The player could click on Use workstation GUI, to start the crafting. This way uses the triggers to check if the player is near enough and inside the trigger area.

The other way, needs to also check if the player is near enough to reach the object to click it. As I have seen with the monkeytoks, they can be clicked similar to clicking an object, except they can be at any distance which is kind of a problem.  Perhaps the answer is somewhere in between with a combination of the 2 methods.

If the object is a 3D object that the character can carry, you will want more then just GUIs to represent it.
Logged

WorldWideZ

  • World Owners
  • ****
  • Posts: 524
    • View Profile
    • World Wide Zed
Re: Props and Glomming
« Reply #2 on: Jul 20, 14, 12:49:15 AM »

Short hack method to make object clickable , place a asset in game , then use the get node under mouse routine when the player clicks to interrogate what the player is clicking on. use FQN to filter , and then have that launch a GUI window.

Are the crafting stations unique? or are they each the same?

the distance issue can be covered with a vectorlength check , and also can be backed up by a serverside check when the craft request is made
Logged

Amarak

  • General Accounts
  • *
  • Posts: 281
    • View Profile
Re: Props and Glomming
« Reply #3 on: Jul 21, 14, 02:53:13 PM »

Thanks for the suggestions. I've been experimenting and while I can /mnac a script onto an object to make it clickable, I am not sure how to make the node persistent, and more importantly, how to add it to the Asset Library. I tried the GLOMming method in the Asset Library commands but it doesn't seem to GLOM the class onto my instantiated objects.

For example, you should be able (in the Asset Library) to use the command:
 /HEGLOM LIBRARY $GUIDS OPERATIONS 1: myClass
to GLOM a class onto the object as it's instantiated but mine isn't working that way. It just loads my object and not the script/class. Any ideas on that?
Logged

Thazager

  • General Accounts
  • *
  • Posts: 1156
  • Never stop learning
    • View Profile
    • Heroes and Villains MMORPG
Re: Props and Glomming
« Reply #4 on: Jul 21, 14, 07:14:53 PM »

I have only glommed classes onto others through code. I have not done it in command line. I believe glomming needs to be done each time the object is used, which would mean if its done only 1 time in command line it wont be persistent or done each time its used.
Logged

Amarak

  • General Accounts
  • *
  • Posts: 281
    • View Profile
Re: Props and Glomming
« Reply #5 on: Jul 21, 14, 11:34:52 PM »

I'm using the command system in the Asset Library to glom the class onto an object at instantiation. It just doesn't seem to work like the wiki says it should.
Logged

WorldWideZ

  • World Owners
  • ****
  • Posts: 524
    • View Profile
    • World Wide Zed
Re: Props and Glomming
« Reply #6 on: Jul 21, 14, 11:48:15 PM »

if you want persistent stuff start looking at associations and you will want to use edit instances as the play instances are non persistent. I think most people use glomclass() to achieve glomming , and normally check to see if the glom exists and then create if not. This can be done when you click , if its not a clickable item and needs to be perform glom , if it already is then the fields are there already

what wiki page are you looking at?
Logged

Amarak

  • General Accounts
  • *
  • Posts: 281
    • View Profile
Re: Props and Glomming
« Reply #7 on: Jul 22, 14, 01:17:28 AM »

I'm following this page http://hewiki.heroengine.com/wiki//HEGLOM#.2FHEGLOM_Command
Halfway down the page is an example of how to use GLOMming with the Asset Library, mine just doesn't seem to work as expected.
Logged

WorldWideZ

  • World Owners
  • ****
  • Posts: 524
    • View Profile
    • World Wide Zed
Re: Props and Glomming
« Reply #8 on: Jul 22, 14, 01:39:00 AM »

personally i might look at making my own /command that ran my own code as a test. have you traced back the code and understand what it does?
Logged

Amarak

  • General Accounts
  • *
  • Posts: 281
    • View Profile
Re: Props and Glomming
« Reply #9 on: Jul 22, 14, 01:29:56 PM »

I pretty much understand the concepts. I'm wondering if I have to create a prototype for this to work in the Asset Library, since it is an object with a script attached.
Logged

WorldWideZ

  • World Owners
  • ****
  • Posts: 524
    • View Profile
    • World Wide Zed
Re: Props and Glomming
« Reply #10 on: Jul 22, 14, 05:05:50 PM »

While i still think there are better ways to achieve what you want than doing this , lets go through this logically.

have you carried out all steps from the word exercise down? if so what errors did you get ? make sure you clear all the error / chat / console windows before trying to execute the instantiation so new errors can show up.

 
Logged

Amarak

  • General Accounts
  • *
  • Posts: 281
    • View Profile
Re: Props and Glomming
« Reply #11 on: Jul 22, 14, 11:44:06 PM »

I was learning C# and Java, but am still fairly new to programming so I am trying to keep it simple by following the wiki for now. I am open to suggestions for better ways to do things but for World Builders I really need to have assets created in the Asset Library so they can be added to the world as needed with a simple click. :)

I have the http://hewiki.heroengine.com/wiki/$GLOM tutorial working, where it says it is glomming scripts onto the objects so that is good. The other thing I am trying to do is use the same concept to glom the script from http://hewiki.heroengine.com/wiki/Your_First_HSL_Script that moves an object on mouseover, and add it to the Asset Library. The problem is when I instantiate the object from the Library, I get this error:
Invalid class(TutorialTest1) specified, the library command for this object is improperly constructed.

I am using the command exactly as it says, so there must be something wrong with the script even though it works using the /MNAC method.

If you know of an easier way to attach scripts to objects I'd love to learn! Just remember I am totally new to HSL so what may seem basic stuff to you is still confusing to me.
« Last Edit: Jul 23, 14, 02:18:02 AM by Amarak »
Logged

WorldWideZ

  • World Owners
  • ****
  • Posts: 524
    • View Profile
    • World Wide Zed
Re: Props and Glomming
« Reply #12 on: Jul 23, 14, 02:16:46 AM »

is the created asset marked mouse targetable ? have you got a println t the beginning of the shared mouse capture function to inform you of  mouse events? might spam you a bit but you will at least know its triggering a event
Logged

Amarak

  • General Accounts
  • *
  • Posts: 281
    • View Profile
Re: Props and Glomming
« Reply #13 on: Jul 23, 14, 02:23:05 AM »

I modified my previous reply, I am indeed getting an error. Still getting used to Heroblade, I was looking at the Console, but the Error message is in the Chat window. The error is:
Invalid class(TutorialTest1) specified, the library command for this object is improperly constructed.

I find that strange since I am using it according to the wiki.
Logged

WorldWideZ

  • World Owners
  • ****
  • Posts: 524
    • View Profile
    • World Wide Zed
Re: Props and Glomming
« Reply #14 on: Jul 23, 14, 02:47:36 AM »

that says to me that that class is not in your DOM , check its there. remembering of course that this command takes place on the server not the client so the class probably needs to be there as well as on the client
Logged
Pages: [1] 2