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:
— qolelis