Page 94 of 396
Re: Ask a simple question, get a simple answer
Posted: Tue Oct 06, 2015 1:00 am
by Azel
I noticed that when your timer Activates, it calls a method, "moveThat"
Cant you have a global counter that keep tracks of when the instructions inside of moveThat actually execute? Granted, the Timer will always run but the instructions will only execute based on the value of a Party Counter.
Something like:
Code: Select all
function moveThat()
local partyCounter = findEntity("PartyCounter");
if partyCounter then
if partyCounter.counter:getValue() > 0 then
-- Do THOM's magic
end
end
end
Sorry, just thinking of an alternate way to accomplish the same thing
Re: Ask a simple question, get a simple answer
Posted: Tue Oct 06, 2015 2:14 am
by minmay
THOM wrote:Really a simple question but it drives me mad:
I want to add a timer component to the party object which starts NOT at the beginning of the game. Cannot find a command to disable it. I am pretty sure it is very obvious but I am unable to figure it out.
Any help, please?
To start a component disabled, include
in its definition.
You also could have discovered this by looking at the scripting reference or the asset pack.
Re: Ask a simple question, get a simple answer
Posted: Tue Oct 06, 2015 2:38 am
by Azel
minmay wrote:You also could have discovered this by looking at the scripting reference or the asset pack.
The name of this thread is "ask a simple question, get a simple answer"
You seem to think the name is, "dont ask a question, go look at the scripting reference or the asset pack"
Also, nowhere in the Scripting Reference does it answer THOM's question:
http://www.grimrock.net/modding/scripti ... rComponent
Also, the LOG2 Asset Defs.LUA file does not show the "enabled=false" property setting, it simply has this:
Code: Select all
defineObject{
editorIcon = 64,
tags = {
"scripting"
},
name = "timer",
components = {
{
name = "timer",
class = "Timer"
},
{
onStart = function() print('Cannot Scrape Functions'); end,
onPause = function() print('Cannot Scrape Functions'); end,
class = "Controller",
name = "controller",
onStop = function() print('Cannot Scrape Functions'); end
}
},
placement = "floor"
}
In fact, "enabled=false" is nowhere in that Asset file.
Of course, there are well over 100 Script Files also provided in the Asset Pack that could be reviewed to find this answer, but luckily there is a community to discuss things with. Lastly, just like you like to repeatedly point out that there is a scripting reference and asset pack, let me point out that there is a "Reply" button that you do not have to Click every time someone asks a question. Food for thought
Re: Ask a simple question, get a simple answer
Posted: Tue Oct 06, 2015 4:52 am
by minmay
Yes it does. Maybe you should read it yourself.
The components field should contain a list of components to be added or replaced in the base object class. Each component has a class and a name. The name of a component is by default its class in lower case. Each component have the following fields:
class: the class name of the component without the “Component” part. E.g. “Model”.
name: (optional) the name of the component. Convention is to use lower case names.
enabled: (optional) the initial enabled state of the component (default is true).
xyz: (optional) sets the xyz property of the component by calling setXyz() method of the component. Any setter that receives a single parameters can be called using this mechanism.
onXyz: (optional) adds the xyz hook to the component.
...
Component
Base-class for all Components. A Component always belongs to one and only one GameObject. Components can be enabled and disabled. A disabled component usually acts as it would not exist in the game.
Component:addConnector(event, target, action)
Component:disable()
Component:enable()
Component:getConnector(i)
Component:getConnectorCount()
Component:getOffset()
Component:isEnabled()
Component:removeConnector(event, target, action)
Component:setOffset(offset)
Component:setRotationAngles(x, y, z)
Component.onInit(self)
I don't recall telling him not to post. I did imply that it would be a good idea to look at the scripting reference first, simply because that's much faster than waiting for someone to reply.
Re: Ask a simple question, get a simple answer
Posted: Tue Oct 06, 2015 5:30 am
by Azel
minmay wrote:Yes it does. Maybe you should read it yourself.
If it was stated on the scripting reference then you could quote the exact location. It doesn't, so you can't. The "one shot" vs "running mode" is loose language, as is most of the scripting reference; which does not denote exact required syntax - which is what THOM was asking for.
minmay wrote:I did imply that it would be a good idea to look at the scripting reference first, simply because that's much faster than waiting for someone to reply.
Speed isn't always the goal; collaboration yields more benefits. I'm sure anyone who frequents this forum has read one of the hundreds of times you've named dropped the scripting reference and asset pack. Your name dropping is usually wrong (like in this case) and clearly only serves as another of your attempts to act "elite" - which I still believe is highly misplaced. Memorizing someone elses files is cool n all, but why you think that puts you above others is pretty silly.
If someone wishes to post a question instead of reading reference/script files, then it isn't your place to chastise their preference of community collaboration over speed.
Re: Ask a simple question, get a simple answer
Posted: Tue Oct 06, 2015 10:43 am
by THOM
I knewed it was something very simple...
Re: Ask a simple question, get a simple answer
Posted: Wed Oct 07, 2015 11:37 am
by cromcrom
A simple way to destroy this timer once it is activated please ?
Code: Select all
local bandagetimer = spawn("timer",1,1,1,1,1,"bandage_applied")
bandagetimer.timer:setTimerInterval(3)
bandagetimer.timer:setDisableSelf(true)
Re: Ask a simple question, get a simple answer
Posted: Wed Oct 07, 2015 12:35 pm
by Isaac
cromcrom wrote:A simple way to destroy this timer once it is activated please ?
Code: Select all
local bandagetimer = spawn("timer",1,1,1,1,1,"bandage_applied")
bandagetimer.timer:setTimerInterval(3)
bandagetimer.timer:setDisableSelf(true)
Adding a function to your script that destroys the caller can work; just connect the timer to it.
Code: Select all
function destroyCaller(caller)
if caller and caller.go and caller.go.timer then
caller.go:destroyDelayed()
end
print(caller.go.id, 'destroyed')
end
Re: Ask a simple question, get a simple answer
Posted: Wed Oct 07, 2015 1:30 pm
by cromcrom
Thanks a lot, it makes a lot of sense. Cheers.
Re: Ask a simple question, get a simple answer
Posted: Wed Oct 07, 2015 3:18 pm
by cromcrom
I am still banging my head on this:
so, in a function, I create this timer.
Code: Select all
local bandagetimer = spawn("timer",1,1,1,1,1,"bandage_applied")
bandagetimer.timer:setTimerInterval(3)
--bandagetimer.timer:setDisableSelf(true)
--bandagetimer.timer:start()
bandagetimer.timer:addConnector("onActivate", "destroy_timer", "destroyCaller","bandage_applied" )
then, when it activates, it calls this function:
Code: Select all
function destroyCaller(caller)
if findEntity(caller) then
findEntity(caller):destroyDelayed()
end
print(findEntity(caller), 'destroyed')
end
However, I have a "could not look up class name " error. Any help, please? I know I could go the rough way, it does work, but I would like to have a broader destroying function, where I can pass the id as an argument.