Hi again,
another question I hope someone has already found a solution to.
I am trying to make a watch. Meaning an item that shows how much time has passed since the game started.
I thought of simply using a timer that every minute counts a counter upwards. Then the watch, one of the characters has, could change its own description according to how much the counter has already counted and thus presenting all passed minutes.
Now I realized that items only have a onUseItem-Hook. So my ideas for scripting something based on an onLookAtItem-Hook are gone.
Does anyone have a solution for how to do something like that?
Best
Chris
Changing Item description by looking at it
Changing Item description by looking at it
Best
Chris
Chris
Re: Changing Item description by looking at it
Well,
I sadly didn't get the lookAtItem thing going (that would have been nice though), but I got the clock working. It was actually easier than I thought.
I simply created a clock object, that's basically a scroll:
I created a timer that increments a counter every sec and activates a script, which goes as follows:
This script goes thorugh every champ and every item slot of the champ and if there's a "clock"-item (the one we defined) than it changes its scrollText.
Oh, and the newText is a bit ugly. I dont know if there is a way to divide through a number and get an integer rather than a float/double. Well in short the line
turns a number like 121 into 2:1.
So, if you want, you can take this code and adapt it, to make an even better clock
Best
Chris
I sadly didn't get the lookAtItem thing going (that would have been nice though), but I got the clock working. It was actually easier than I thought.
I simply created a clock object, that's basically a scroll:
Code: Select all
cloneObject{
name = "clock",
baseObject = "scroll",
uiName = "Clock",
model = "assets/models/items/compass.fbx",
description = "It's a chronometer. Its two hands move magically\nin circles.",
gfxIndex = 161,
weight = 0.2,
}
Code: Select all
function time()
local newText = "" .. (counter_3:getValue()-(counter_3:getValue()%60))/60 .. ":" .. counter_3:getValue()%60
local itemCnt = 11
local champCnt = 1
while champCnt <= 4 do
itemCnt = 11
while itemCnt <= 31 do
if party:getChampion(champCnt):getItem(itemCnt) ~= nil then
if party:getChampion(champCnt):getItem(itemCnt).name == "clock" then
party:getChampion(champCnt):getItem(itemCnt):setScrollText(newText)
end
end
itemCnt = itemCnt + 1
end
champCnt = champCnt + 1
end
end
Oh, and the newText is a bit ugly. I dont know if there is a way to divide through a number and get an integer rather than a float/double. Well in short the line
Code: Select all
local newText = "" .. (counter_3:getValue()-(counter_3:getValue()%60))/60 .. ":" .. counter_3:getValue()%60
So, if you want, you can take this code and adapt it, to make an even better clock

Best
Chris
Best
Chris
Chris
Re: Changing Item description by looking at it
What if a counter does a set item text by referencing a table of possible texts?
"I'm okay with being referred to as a goddess."
Community Model Request Thread
See what I'm working on right now: Neikun's Workshop
Lead Coordinator for Legends of the Northern Realms Project
Community Model Request Thread
See what I'm working on right now: Neikun's Workshop
Lead Coordinator for Legends of the Northern Realms Project
- Message me to join in!
Re: Changing Item description by looking at it
Hi,
I am not quite sure to which part of the code you are referring.
Are you proposing another way of creating a clock?
I am not quite sure to which part of the code you are referring.
Are you proposing another way of creating a clock?
Best
Chris
Chris
Re: Changing Item description by looking at it
I'm not entirely sure what it'd look like but basically on every count, the script would do another scroll text.
I think in order to do this, you're going to need a scroll with a different icon/model
I think in order to do this, you're going to need a scroll with a different icon/model
"I'm okay with being referred to as a goddess."
Community Model Request Thread
See what I'm working on right now: Neikun's Workshop
Lead Coordinator for Legends of the Northern Realms Project
Community Model Request Thread
See what I'm working on right now: Neikun's Workshop
Lead Coordinator for Legends of the Northern Realms Project
- Message me to join in!
Re: Changing Item description by looking at it
Yes, that was my idea too. I basically created a scroll (and used the compass model) whichs scrollText is updated every second by a timer.
Best
Chris
Chris