A weird error with wereables

Keisser
28 Dec 2018, 11:41

Sorry for my bad English in advance.
After creating a first wereable (I am using a default library) item and starting a game I tried to wear it and ran into a strange exception. It says "Error running script: Error compiling expression 'player': Unknown object or variable 'player'". This is definitely due to the fact I have my player object renamed but it looks like that the library tries to refer to player object using a default name hidden somewhere in the depths of library code. Renaming player object back to "player" works, but I would like to avoid it because there are a lot of references to the player object using it's "new" name. How do I bypass that exception?
P.S. I use a standard editor and I don't really work with the game code in code view because I am still a profane to Quest.


The Pixie
28 Dec 2018, 13:17

What do you mean by "I am using a default library"? There are libraries for wearable out there, but they got incorporated into Quest itself, so you do not need to add a library yourself.


mrangel
28 Dec 2018, 16:21

@pixie I took that to mean "I am using the default library"; meaning the default wearables system.

The function SetBonuses contains a single reference to the object name player.

@Keisser
Do you know how to override the default functions? If I'm understanding you correctly, then you may need to modify the function SetBonuses.
Open the function in code view. Towards the end you will find the line set (player, att, n). You should change this to set (game.pov, att, n)

If you need any help with this, I'm sure there will be plenty of people more able to help you.


Keisser
29 Dec 2018, 11:14

Thank you @mrangel, your solution worked perfectly.
Now I faced another minor problem: for some reason, there is a "Drop" verb being displayed in inventory and I see no way to get rid of it. "Object can be dropped" checkbox in editor is disabled and there is no "Drop" verb in verb list but somehow the "Drop" action still appears. This is probably due to the way SetVerbs function works.


Keisser
29 Dec 2018, 11:23

I looked at SetVerbs but I did not found out how it really works so I decided to not to touch anything for now.


mrangel
29 Dec 2018, 12:35

(EDITed: one more typo fix)

I'm looking at the function _SetVerbsForGarment, and it looks a bit odd to me.

I'd probably have it something more like…

automaticverbs = NewStringList()
list add (automaticverbs, Template("LookAt"))
outer = _GetOuterForGarment(game.pov, garment)
if (garment.worn) {
  garmentverbs = GetString (garment, "wornverbs")
  if (outer = null and GetBoolean (garment, "removeable")) {
    list add (automaticverbs, Template("Remove"))
  }
}
else {
  garmentverbs = GetString (garment, "invverbs")
  if (HasScript (garment, "drop") or GetBoolean (garment, "drop")) {
    list add (automaticverbs, Template("Drop"))
  }
  if (not outer = null) {
    outer_layer = outer.wear_layer
  }
  else {
    outer_layer = garment.wear_layer - 1
  }
  if (outer_layer < garment.wear_layer) {
    list add (automaticverbs, Template("Wear"))
  }
}
if (garmentverbs = null or garmentverbs = "") {
  garment.inventoryverbs = automaticverbs
}
else {
  garment.inventoryverbs = ListCompact (ListCombine (automaticverbs, Split(garmentverbs)))
}

I figured that rewriting the function was easier than modifying it, because of the way the existing function uses static lists.
This version should behave the same, except that it only includes the "Drop" verb for garments which are dropable.

(Sorry if there's any errors, I haven't tested it)


Keisser
02 Jan 2019, 00:09

@mrangel thank you for the solution, the "Drop" verb disappeared... Among with the "Wear" verb.
"Wear" can still be added via "Object" tab, but it does not disappear after a wereable is worn.


Dcoder
02 Jan 2019, 00:25

wereables = those able to assume lycanthropic form


mrangel
02 Jan 2019, 09:08

@mrangel thank you for the solution, the "Drop" verb disappeared... Among with the "Wear" verb.

Oops, I was careless. It hides the 'Wear' command if you're already wearing a garment on a higher layer, just like the default one. But I messed up the case where you're not wearing anything.

Should be fixed now


Keisser
03 Jan 2019, 17:40

@mrangel

Error running script: Error compiling expression 'ListCompact (ListCombine (automaticverbs, garmentverbs))': FunctionCallElement: Could find not function 'ListCombine(QuestList`1; String)'

I am starting to think that this library is cursed.


mrangel
03 Jan 2019, 22:54

Ooops; last line
garment.inventoryverbs = ListCompact (ListCombine (automaticverbs, garmentverbs))
should be
garment.inventoryverbs = ListCompact (ListCombine (automaticverbs, Split(garmentverbs)))

Sorry, I wasn't paying enough attention. Code in the post above changed; hoping I haven't made any more mistakes.


Keisser
09 Jan 2019, 19:31

@mrangel Thank you, everything is working perfectly now.
There is a minor misspelling in the code:

if (garnentverbs = null or garmentverbs = "") {

should be garmentverbs


mrangel
10 Jan 2019, 08:32

That's the downside of typing code in the forum, on my phone. Hard to spot stuff like that on a tiny screen :)
Good to see it working.