User Tools

Site Tools


lgscript:faq

Questions


Alright, so, I’m trying out a script, here. I have two lights, one with animlight set to minimum brightness, and another with animlight set to maximum brightness. The script should copy the maximum brightness animlight property and replace the minimum brightness one.

function TurnOn(message)
propertysrv.copyfrom(9, "AnimLight", 5)
lgs.DarkUISrv.TextMessage("It should be on, now.")
return true
end

For some reason, though, it doesn’t. In fact, my line, the propertysrv.copy command, breaks the script so it doesn’t even send the confirmation message. What am I doing wrong?

scarykitties


Don’t you mean lgs.propertysrv.copyfrom, or is there already a local propertysrv = lgs.propertysrv elsewhere in the script?

In any case, you probably don’t want to be adding/removing/copying the AnimLight property. Because it has to work with the renderer, there’s some magic involved that can be messed up if you remove it during the game. Use the AnimLightService instead. Although I’ve discovered that you can change the values of the min and max brightness fields in the property. (The new value doesn’t take effect until you change the light mode.)

For the record, the door properties should also not be added or removed during the game. There’s likely a few others but they don’t come to mind righ tnow.

Magus Telliamed 2009/08/28 15:17


Yes, that’s what was breaking the script. It still doesn’t copy over the Animlight property, but at least the whole script executes.

scarykitties


Like I said, AnimLight doesn’t copy well so what you want to do is get and set each field individually. Except for the mode which you change through animlightservice. — tom


In an experiment, I wrote a short script that is supposed to make an AI patrol when a switch is flipped “on” and stop the patrol when it is flipped “off.” In this case, I have a sword guard with the object ID of 13.

function TurnOn(message)
  lgs.propertysrv.add(13, "AI_Patrol")
  lgs.propertysrv.setlocal(13, "AI_Patrol", "true")
  lgs.DarkUISrv.TextMessage("Patrol Start")
  return true
end
function TurnOff(message)
  lgs.propertysrv.remove(13, "AI_Patrol")
  lgs.DarkUISrv.TextMessage("Patrol End")
  return true
end

The code executes, but it doesn’t actually make the AI patrol. What am I doing wrong?

scarykitties


Thief itself isn’t actually smart enough to know that the string "true" means “true”. Better to use a boolean value for on/off properties. (The numbers 0 and 1 will also work.)

function TurnOn(message)
  lgs.propertysrv.add(13, "AI_Patrol")
  lgs.propertysrv.set(13, "AI_Patrol", true)
  lgs.DarkUISrv.TextMessage("Patrol Start")
  return true
end

SetLocal is for when networking is active, so Thief never really needs it. Well, I guess if you used the multiplayer patch. Even then, a normal set will do most of the time.

Magus Telliamed 2009/08/31 16:13


I just got started yesterday testing lgScript and it was real easy getting started. I have already written a script that simplifies my rope-able crates setup in my upcoming mission a lot. The only problem is that I cannot release my mission until lgScript has been released, or can I?

While writing my first script a few other questions arose as well:

  1. Is it possible to compile my lua-scripts into an osm-file? Would there be any advantage in doing that?
  2. About lgs.PhysSrv.SubscribeMsg: What’s the format for the messages-parameter?
  3. About lgs.DarkHookSrv.InstallPropHook: What’s the listener- and post-parameters used for?
  4. How much cleaning up do I have to do when a script ends? Do I have to, for example, kill timers or is that done automatically (by the garbage collector?)?
  5. Which files do I have to include in my mission-zip (other than lgs.osm, my own lua-scripts and any lua-scripts included with the require-command)?
  6. More documentation? On function parameters for example.
  7. When do you think lgScript will be released for public use?
  8. Is there any way for me to use my newly written script in a public FM without violating the beta-license for lgScript? Could I send it to my beta-testers to begin with?

qolelis


lgscript/faq.txt · Last modified: 2009/10/17 16:02 by qolelis